diff --git a/monkey_island/cc/resources/local_run.py b/monkey_island/cc/resources/local_run.py index 1923f948f..f9b5b3302 100644 --- a/monkey_island/cc/resources/local_run.py +++ b/monkey_island/cc/resources/local_run.py @@ -9,11 +9,12 @@ import flask_restful from cc.resources.monkey_download import get_monkey_executable from cc.island_config import ISLAND_PORT from cc.services.node import NodeService +from cc.utils import local_ip_addresses __author__ = 'Barak' -def run_local_monkey(island_address): +def run_local_monkey(): import platform import subprocess import stat @@ -35,7 +36,7 @@ def run_local_monkey(island_address): # run the monkey try: - args = ["%s m0nk3y -s %s:%s" % (target_path, island_address, ISLAND_PORT)] + args = ["%s m0nk3y -s %s:%s" % (target_path, local_ip_addresses()[0], ISLAND_PORT)] if sys.platform == "win32": args = "".join(args) pid = subprocess.Popen(args, shell=True).pid @@ -51,8 +52,8 @@ class LocalRun(flask_restful.Resource): def post(self): body = json.loads(request.data) - if body.get('action') == 'run' and body.get('ip') is not None: - local_run = run_local_monkey(island_address=body.get('ip')) + if body.get('action') == 'run': + local_run = run_local_monkey() return jsonify(is_running=local_run[0]) # default action diff --git a/monkey_island/cc/ui/src/components/pages/StartOverPage.js b/monkey_island/cc/ui/src/components/pages/StartOverPage.js index bcad07527..603e72456 100644 --- a/monkey_island/cc/ui/src/components/pages/StartOverPage.js +++ b/monkey_island/cc/ui/src/components/pages/StartOverPage.js @@ -5,6 +5,10 @@ import {Link} from 'react-router-dom'; class StartOverPageComponent extends React.Component { constructor(props) { super(props); + + this.state = { + cleaned: false + }; } render() { @@ -22,6 +26,12 @@ class StartOverPageComponent extends React.Component {

Reset Environment

+ { this.state.cleaned ? +
+ + Environment was reset successfully +
+ : ''}

* BTW you can just continue and run more monkeys as you wish, and see the results on the Infection Map without deleting anything. @@ -30,6 +40,25 @@ class StartOverPageComponent extends React.Component { ); } + + cleanup() { + // TODO: fix + /* + this.setState({ + cleaned: false + }); + */ + fetch('/api?action=reset') + .then(res => res.json()) + .then(res => { + if (res["status"] == "OK") { + // TODO: fix this + this.setState({ + cleaned: true + }); + } + }); + } } export default StartOverPageComponent;