forked from p15670423/monkey
Add V after generating report
This commit is contained in:
parent
e2a622d117
commit
15b4a8778b
|
@ -6,6 +6,7 @@ import flask_restful
|
||||||
from cc.database import mongo
|
from cc.database import mongo
|
||||||
from cc.services.config import ConfigService
|
from cc.services.config import ConfigService
|
||||||
from cc.services.node import NodeService
|
from cc.services.node import NodeService
|
||||||
|
from cc.services.report import ReportService
|
||||||
|
|
||||||
from cc.utils import local_ip_addresses
|
from cc.utils import local_ip_addresses
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@ class Root(flask_restful.Resource):
|
||||||
mongo.db.telemetry.drop()
|
mongo.db.telemetry.drop()
|
||||||
mongo.db.node.drop()
|
mongo.db.node.drop()
|
||||||
mongo.db.edge.drop()
|
mongo.db.edge.drop()
|
||||||
|
mongo.db.report.drop()
|
||||||
ConfigService.init_config()
|
ConfigService.init_config()
|
||||||
return jsonify(status='OK')
|
return jsonify(status='OK')
|
||||||
elif action == "killall":
|
elif action == "killall":
|
||||||
|
@ -37,5 +39,6 @@ class Root(flask_restful.Resource):
|
||||||
|
|
||||||
def get_completed_steps(self):
|
def get_completed_steps(self):
|
||||||
is_any_exists = NodeService.is_any_monkey_exists()
|
is_any_exists = NodeService.is_any_monkey_exists()
|
||||||
is_any_alive = NodeService.is_any_monkey_alive()
|
infection_done = NodeService.is_monkey_finished_running()
|
||||||
return dict(run_server=True, run_monkey=is_any_exists, infection_done=(is_any_exists and not is_any_alive))
|
report_done = ReportService.is_report_generated()
|
||||||
|
return dict(run_server=True, run_monkey=is_any_exists, infection_done=infection_done, report_done=report_done)
|
||||||
|
|
|
@ -281,6 +281,10 @@ class NodeService:
|
||||||
def is_any_monkey_exists():
|
def is_any_monkey_exists():
|
||||||
return mongo.db.monkey.find_one({}) is not None
|
return mongo.db.monkey.find_one({}) is not None
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_monkey_finished_running():
|
||||||
|
return NodeService.is_any_monkey_exists() and not NodeService.is_any_monkey_alive()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_credentials_to_monkey(monkey_id, creds):
|
def add_credentials_to_monkey(monkey_id, creds):
|
||||||
mongo.db.monkey.update(
|
mongo.db.monkey.update(
|
||||||
|
|
|
@ -362,13 +362,27 @@ class ReportService:
|
||||||
|
|
||||||
return warnings_byte_array
|
return warnings_byte_array
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_report_generated():
|
||||||
|
generated_report = mongo.db.report.find_one({'name': 'generated_report'})
|
||||||
|
if generated_report is None:
|
||||||
|
return False
|
||||||
|
return generated_report['value']
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_report_generated():
|
||||||
|
mongo.db.report.update(
|
||||||
|
{'name': 'generated_report'},
|
||||||
|
{'$set': {'value': True}},
|
||||||
|
upsert=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_report():
|
def get_report():
|
||||||
issues = ReportService.get_issues()
|
issues = ReportService.get_issues()
|
||||||
config_users = ReportService.get_config_users()
|
config_users = ReportService.get_config_users()
|
||||||
config_passwords = ReportService.get_config_passwords()
|
config_passwords = ReportService.get_config_passwords()
|
||||||
|
|
||||||
return \
|
report = \
|
||||||
{
|
{
|
||||||
'overview':
|
'overview':
|
||||||
{
|
{
|
||||||
|
@ -395,6 +409,12 @@ class ReportService:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finished_run = NodeService.is_monkey_finished_running()
|
||||||
|
if finished_run:
|
||||||
|
ReportService.set_report_generated()
|
||||||
|
|
||||||
|
return report
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def did_exploit_type_succeed(exploit_type):
|
def did_exploit_type_succeed(exploit_type):
|
||||||
return mongo.db.edge.count(
|
return mongo.db.edge.count(
|
||||||
|
|
|
@ -28,7 +28,8 @@ class AppComponent extends React.Component {
|
||||||
completedSteps: {
|
completedSteps: {
|
||||||
run_server: true,
|
run_server: true,
|
||||||
run_monkey: false,
|
run_monkey: false,
|
||||||
infection_done: false
|
infection_done: false,
|
||||||
|
report_done: false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -102,6 +103,9 @@ class AppComponent extends React.Component {
|
||||||
<NavLink to="/report">
|
<NavLink to="/report">
|
||||||
<span className="number">4.</span>
|
<span className="number">4.</span>
|
||||||
Security Report
|
Security Report
|
||||||
|
{ this.state.completedSteps.report_done ?
|
||||||
|
<Icon name="check" className="pull-right checkmark text-success"/>
|
||||||
|
: ''}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
Loading…
Reference in New Issue