Show warning of new infections only if monkeys are running

This commit is contained in:
Itay Mizeretz 2017-10-17 12:10:23 +03:00
parent b58c4ea622
commit 57e3677fce
2 changed files with 36 additions and 16 deletions

View File

@ -191,10 +191,13 @@ SCHEMA = {
"description": "Determines whether the monkey should scan its subnets additionally" "description": "Determines whether the monkey should scan its subnets additionally"
}, },
"depth": { "depth": {
"title": "Depth" + WARNING_SIGN, "title": "Distance from island",
"type": "integer", "type": "integer",
"default": 2, "default": 2,
"description": "Amount of hops allowed for the monkey to spread" "description":
"Amount of hops allowed for the monkey to spread from the island. "
+ WARNING_SIGN
+ " Note that setting this value too high may result in the monkey propagating too far"
} }
} }
}, },
@ -293,12 +296,14 @@ SCHEMA = {
"description": "Determines the maximum number of machines the monkey is allowed to scan" "description": "Determines the maximum number of machines the monkey is allowed to scan"
}, },
"victims_max_exploit": { "victims_max_exploit": {
"title": "Max victims to exploit" + WARNING_SIGN, "title": "Max victims to exploit",
"type": "integer", "type": "integer",
"default": 7, "default": 7,
"description": "description":
"Determines the maximum number of machines the monkey" "Determines the maximum number of machines the monkey"
" is allowed to successfully exploit" " is allowed to successfully exploit. " + WARNING_SIGN
+ " Note that setting this value too high may result in the monkey propagating to "
"a high number of machines"
}, },
"timeout_between_iterations": { "timeout_between_iterations": {
"title": "Wait time between iterations", "title": "Wait time between iterations",
@ -576,7 +581,7 @@ SCHEMA = {
"type": "object", "type": "object",
"properties": { "properties": {
"exploiter_classes": { "exploiter_classes": {
"title": "Exploits" + WARNING_SIGN, "title": "Exploits",
"type": "array", "type": "array",
"uniqueItems": True, "uniqueItems": True,
"items": { "items": {
@ -590,7 +595,9 @@ SCHEMA = {
"SambaCryExploiter", "SambaCryExploiter",
"ElasticGroovyExploiter" "ElasticGroovyExploiter"
], ],
"description": "Determines which exploits to use" "description":
"Determines which exploits to use. " + WARNING_SIGN
+ " Note that using unsafe exploits may cause crashes of the exploited machine/service"
}, },
"skip_exploit_if_file_exist": { "skip_exploit_if_file_exist": {
"title": "Skip exploit if file exists", "title": "Skip exploit if file exists",

View File

@ -17,7 +17,8 @@ class ConfigurePageComponent extends React.Component {
saved: false, saved: false,
reset: false, reset: false,
sections: [], sections: [],
selectedSection: 'basic' selectedSection: 'basic',
allMonkeysAreDead: true
}; };
} }
@ -36,6 +37,7 @@ class ConfigurePageComponent extends React.Component {
selectedSection: 'basic' selectedSection: 'basic'
}) })
}); });
this.updateMonkeysRunning();
} }
onSubmit = ({formData}) => { onSubmit = ({formData}) => {
@ -99,6 +101,17 @@ class ConfigurePageComponent extends React.Component {
}); });
}; };
updateMonkeysRunning = () => {
fetch('/api')
.then(res => res.json())
.then(res => {
// This check is used to prevent unnecessary re-rendering
this.setState({
allMonkeysAreDead: (!res['completed_steps']['run_monkey']) || (res['completed_steps']['infection_done'])
});
});
};
render() { render() {
let displayedSchema = {}; let displayedSchema = {};
if (this.state.schema.hasOwnProperty('properties')) { if (this.state.schema.hasOwnProperty('properties')) {
@ -120,7 +133,7 @@ class ConfigurePageComponent extends React.Component {
this.state.selectedSection === 'basic_network' ? this.state.selectedSection === 'basic_network' ?
<div className="alert alert-info"> <div className="alert alert-info">
<i className="glyphicon glyphicon-info-sign" style={{'marginRight': '5px'}}/> <i className="glyphicon glyphicon-info-sign" style={{'marginRight': '5px'}}/>
The Monkey scans its subnet if "Local network scan" is ticked. Additionally the monkey will scan machines The Monkey scans its subnet if "Local network scan" is ticked. Additionally the monkey scans machines
according to its range class. according to its range class.
</div> </div>
: <div /> : <div />
@ -131,14 +144,14 @@ class ConfigurePageComponent extends React.Component {
onSubmit={this.onSubmit} onSubmit={this.onSubmit}
onChange={this.onChange}> onChange={this.onChange}>
<div> <div>
<div className="alert alert-info"> { this.state.allMonkeysAreDead ?
<i className="glyphicon glyphicon-info-sign" style={{'marginRight': '5px'}}/> '' :
Changing the configuration will only apply to new infections.
</div>
<div className="alert alert-warning"> <div className="alert alert-warning">
<i className="glyphicon glyphicon-warning-sign" style={{'marginRight': '5px'}}/> <i className="glyphicon glyphicon-warning-sign" style={{'marginRight': '5px'}}/>
Changing config values with the &#9888; mark may result in the monkey propagating too far or using dangerous exploits. Some monkeys are currently running. Note that changing the configuration will only apply to new
infections.
</div> </div>
}
<div className="text-center"> <div className="text-center">
<button type="submit" className="btn btn-success btn-lg" style={{margin: '5px'}}> <button type="submit" className="btn btn-success btn-lg" style={{margin: '5px'}}>
Submit Submit