forked from p15670423/monkey
cc: Process exploit data on backend for ransomware stats reporting
This commit is contained in:
parent
a95adfb5b6
commit
2212029f0b
|
@ -2,10 +2,10 @@ import flask_restful
|
|||
from flask import jsonify
|
||||
|
||||
from monkey_island.cc.resources.auth.auth import jwt_required
|
||||
from monkey_island.cc.services.ransomware_report import get_exploitation_details
|
||||
from monkey_island.cc.services.ransomware_report import get_propagation_stats
|
||||
|
||||
|
||||
class RansomwareReport(flask_restful.Resource):
|
||||
@jwt_required
|
||||
def get(self):
|
||||
return jsonify({"report": None, "propagation": get_exploitation_details()})
|
||||
return jsonify({"report": None, "propagation_stats": get_propagation_stats()})
|
||||
|
|
|
@ -1,8 +1,28 @@
|
|||
from typing import Dict, List
|
||||
|
||||
from monkey_island.cc.services.reporting.report import ReportService
|
||||
|
||||
|
||||
def get_exploitation_details():
|
||||
def get_propagation_stats() -> Dict:
|
||||
scanned = ReportService.get_scanned()
|
||||
exploited = ReportService.get_exploited()
|
||||
|
||||
return {"scanned": scanned, "exploited": exploited}
|
||||
return {
|
||||
"num_scanned_nodes": len(scanned),
|
||||
"num_exploited_nodes": len(exploited),
|
||||
"count_per_exploit": _get_exploit_counts(exploited),
|
||||
}
|
||||
|
||||
|
||||
def _get_exploit_counts(exploited: List[Dict]) -> Dict:
|
||||
exploit_counts = {}
|
||||
|
||||
for node in exploited:
|
||||
exploits = node["exploits"]
|
||||
for exploit in exploits:
|
||||
if exploit in exploit_counts:
|
||||
exploit_counts[exploit] += 1
|
||||
else:
|
||||
exploit_counts[exploit] = 1
|
||||
|
||||
return exploit_counts
|
||||
|
|
Loading…
Reference in New Issue