forked from p34709852/monkey
Implement cleanup button
Changed run monkey on island to not depend on ip
This commit is contained in:
parent
fedafa6583
commit
8bada60fcd
|
@ -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
|
||||
|
|
|
@ -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 {
|
|||
<p>
|
||||
<a onClick={this.cleanup} className="btn btn-danger btn-lg">Reset Environment</a>
|
||||
</p>
|
||||
{ this.state.cleaned ?
|
||||
<div className="alert alert-info">
|
||||
<i className="glyphicon glyphicon-info-sign" style={{'marginRight': '5px'}}/>
|
||||
Environment was reset successfully
|
||||
</div>
|
||||
: ''}
|
||||
<p>
|
||||
* BTW you can just continue and <Link to="/run-monkey">run more monkeys</Link> as you wish,
|
||||
and see the results on the <Link to="/infection/map">Infection Map</Link> without deleting anything.
|
||||
|
@ -30,6 +40,25 @@ class StartOverPageComponent extends React.Component {
|
|||
</Col>
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue