ui improvements

This commit is contained in:
Barak Argaman 2017-09-18 14:18:57 +03:00
parent 1081c84d38
commit 84f903cecd
6 changed files with 72 additions and 17 deletions

View File

@ -16,7 +16,7 @@ class Root(flask_restful.Resource):
action = request.args.get('action') action = request.args.get('action')
if not action: if not action:
return jsonify(ip_addresses=local_ip_addresses(), mongo=str(mongo.db)) return jsonify(ip_addresses=local_ip_addresses(), mongo=str(mongo.db), completed_steps=self.get_completed_steps())
elif action == "reset": elif action == "reset":
mongo.db.config.drop() mongo.db.config.drop()
@ -31,3 +31,7 @@ class Root(flask_restful.Resource):
return 200 return 200
else: else:
return make_response(400, {'error': 'unknown action'}) return make_response(400, {'error': 'unknown action'})
def get_completed_steps(self):
# TODO implement
return dict(run_server=True, run_monkey=False, infection_done=False)

View File

@ -19,6 +19,22 @@ let logoImage = require('../images/monkey-logo.png');
let guardicoreLogoImage = require('../images/guardicore-logo.png'); let guardicoreLogoImage = require('../images/guardicore-logo.png');
class AppComponent extends React.Component { class AppComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
completedSteps: {
run_server: true,
run_monkey: false,
infection_done: false
}
};
}
updateStatus = () => {
fetch('/api')
.then(res => res.json())
.then(res => this.setState({completedSteps: res['completed_steps']}));
}
render() { render() {
return ( return (
<Router> <Router>
@ -34,19 +50,27 @@ class AppComponent extends React.Component {
<NavLink to="/" exact={true}> <NavLink to="/" exact={true}>
<span className="number">1.</span> <span className="number">1.</span>
Run C&C Server Run C&C Server
<Icon name="check" className="pull-right checkmark text-success"/> { this.state.completedSteps.run_server ?
<Icon name="check" className="pull-right checkmark text-success"/>
: ''}
</NavLink> </NavLink>
</li> </li>
<li> <li>
<NavLink to="/run-monkey"> <NavLink to="/run-monkey">
<span className="number">2.</span> <span className="number">2.</span>
Run Monkey Run Monkey
{ this.state.completedSteps.run_monkey ?
<Icon name="check" className="pull-right checkmark text-success"/>
: ''}
</NavLink> </NavLink>
</li> </li>
<li> <li>
<NavLink to="/infection/map"> <NavLink to="/infection/map">
<span className="number">3.</span> <span className="number">3.</span>
Infection Map Infection Map
{ this.state.completedSteps.infection_done ?
<Icon name="check" className="pull-right checkmark text-success"/>
: ''}
</NavLink> </NavLink>
</li> </li>
<li> <li>
@ -70,7 +94,7 @@ class AppComponent extends React.Component {
</ul> </ul>
<hr/> <hr/>
<div className="guardicore-link"> <div className="guardicore-link text-center">
<span>Powered by</span> <span>Powered by</span>
<a href="http://www.guardicore.com" target="_blank"> <a href="http://www.guardicore.com" target="_blank">
<img src={guardicoreLogoImage} alt="GuardiCore"/> <img src={guardicoreLogoImage} alt="GuardiCore"/>
@ -79,13 +103,13 @@ class AppComponent extends React.Component {
</Col> </Col>
<Col sm={9} md={10} smOffset={3} mdOffset={2} className="main"> <Col sm={9} md={10} smOffset={3} mdOffset={2} className="main">
<Route exact path="/" component={RunServerPage}/> <Route exact path="/" render={(props) => ( <RunServerPage onStatusChange={this.updateStatus} /> )} />
<Route path="/configure" component={ConfigurePage}/> <Route path="/configure" render={(props) => ( <ConfigurePage onStatusChange={this.updateStatus} /> )} />
<Route path="/run-monkey" component={RunMonkeyPage}/> <Route path="/run-monkey" render={(props) => ( <RunMonkeyPage onStatusChange={this.updateStatus} /> )} />
<Route path="/infection/map" component={MapPage}/> <Route path="/infection/map" render={(props) => ( <MapPage onStatusChange={this.updateStatus} /> )} />
<Route path="/infection/logs" component={FullLogsPage}/> <Route path="/infection/logs" render={(props) => ( <FullLogsPage onStatusChange={this.updateStatus} /> )} />
<Route path="/start-over" component={StartOverPage}/> <Route path="/start-over" render={(props) => ( <StartOverPage onStatusChange={this.updateStatus} /> )} />
<Route path="/report" component={ReportPage}/> <Route path="/report" render={(props) => ( <ReportPage onStatusChange={this.updateStatus} /> )} />
</Col> </Col>
</Row> </Row>
</Grid> </Grid>

View File

@ -44,6 +44,7 @@ class ConfigurePageComponent extends React.Component {
schema: res.schema, schema: res.schema,
configuration: res.configuration configuration: res.configuration
}); });
this.props.onStatusChange();
}); });
}; };

View File

@ -55,10 +55,34 @@ class MapPageComponent extends React.Component {
select: event => this.selectionChanged(event) select: event => this.selectionChanged(event)
}; };
edgeGroupToColor(group) {
switch (group) {
case 'exploited':
return '#c00';
break;
case 'tunnel':
return '#aaa';
break;
case 'scan':
return '#f90';
break;
case 'island':
return '#aaa';
break;
}
return 'black';
}
componentDidMount() { componentDidMount() {
fetch('/api/netmap') fetch('/api/netmap')
.then(res => res.json()) .then(res => res.json())
.then(res => this.setState({graph: res})); .then(res => {
res.edges.forEach(edge => {
edge.color = this.edgeGroupToColor(edge.group);
});
this.setState({graph: res});
this.props.onStatusChange();
});
} }
selectionChanged(event) { selectionChanged(event) {
@ -93,15 +117,15 @@ class MapPageComponent extends React.Component {
placeholder="Find on map" placeholder="Find on map"
style={{'marginBottom': '1em'}}/> style={{'marginBottom': '1em'}}/>
<PreviewPane item={this.state.selected} type={this.state.selectedType} /> <div style={{'overflow': 'auto', 'marginBottom': '1em'}}>
<Link to="/infection/logs" className="btn btn-default pull-left" style={{'width': '48%'}}>Monkey Telemetry</Link>
<div> <button onClick={this.killAllMonkeys} className="btn btn-danger pull-right" style={{'width': '48%'}}>
<Link to="/infection/logs" className="btn btn-default btn-block" style={{'marginBottom': '0.5em'}}>Monkey Telemetry</Link>
<button onClick={this.killAllMonkeys} className="btn btn-danger btn-block">
<Icon name="stop-circle" style={{'marginRight': '0.5em'}}></Icon> <Icon name="stop-circle" style={{'marginRight': '0.5em'}}></Icon>
Kill All Monkeys Kill All Monkeys
</button> </button>
</div> </div>
<PreviewPane item={this.state.selected} type={this.state.selectedType} />
</Col> </Col>
</div> </div>
); );

View File

@ -27,6 +27,7 @@ class RunMonkeyPageComponent extends React.Component {
.then(res => this.setState({ .then(res => this.setState({
isRunningOnIsland: res['is_running'] isRunningOnIsland: res['is_running']
})); }));
this.props.onStatusChange();
} }
generateCmd(ip) { generateCmd(ip) {
@ -45,6 +46,7 @@ class RunMonkeyPageComponent extends React.Component {
this.setState({ this.setState({
isRunningOnIsland: res['is_running'] isRunningOnIsland: res['is_running']
}); });
this.props.onStatusChange();
}); });
}; };

View File

@ -91,7 +91,7 @@ body {
li .checkmark { li .checkmark {
font-size: 1.3em; font-size: 1.3em;
margin-right: -15px; margin-right: -10px;
} }
hr { hr {