示例#1
0
 def reset_db():
     remove_PBA_files()
     # We can't drop system collections.
     [
         mongo.db[x].drop() for x in mongo.db.collection_names()
         if not x.startswith('system.')
     ]
     ConfigService.init_config()
     AttackConfig.reset_config()
     logger.info('DB was reset')
     return jsonify(status='OK')
示例#2
0
 def reset_db():
     logger.info("Resetting database")
     # We can't drop system collections.
     [
         Database.drop_collection(x) for x in mongo.db.collection_names()
         if not x.startswith("system.")
         and not x == AttackMitigations.COLLECTION_NAME
     ]
     ConfigService.init_config()
     AttackConfig.reset_config()
     logger.info("DB was reset")
     return jsonify(status="OK")
示例#3
0
文件: database.py 项目: zkbupt/monkey
 def reset_db():
     logger.info('Resetting database')
     remove_PBA_files()
     # We can't drop system collections.
     [
         Database.drop_collection(x) for x in mongo.db.collection_names()
         if not x.startswith('system.')
         and not x == AttackMitigations.COLLECTION_NAME
     ]
     ConfigService.init_config()
     AttackConfig.reset_config()
     logger.info('DB was reset')
     return jsonify(status='OK')
示例#4
0
 def generate_new_report():
     """
     Generates new report based on telemetries, replaces old report in db with new one.
     :return: Report object
     """
     report = \
         {
             'techniques': {},
             'meta': {'latest_monkey_modifytime': Monkey.get_latest_modifytime()},
             'name': REPORT_NAME
         }
     for tech_id, tech_info in list(
             AttackConfig.get_techniques_for_report().items()):
         try:
             technique_report_data = TECHNIQUES[tech_id].get_report_data()
             technique_report_data.update(tech_info)
             report['techniques'].update({tech_id: technique_report_data})
         except KeyError as e:
             LOG.error(
                 "Attack technique does not have it's report component added "
                 "to attack report service. %s" % e)
     mongo.db.attack_report.replace_one({'name': REPORT_NAME},
                                        report,
                                        upsert=True)
     return report
示例#5
0
 def get(self):
     return current_app.response_class(
         json.dumps({"configuration": AttackConfig.get_config()},
                    indent=None,
                    separators=(",", ":"),
                    sort_keys=False) + "\n",
         mimetype=current_app.config['JSONIFY_MIMETYPE'])
示例#6
0
 def post(self):
     """
     Based on request content this endpoint either resets ATT&CK configuration or updates it.
     :return: Technique types dict with techniques on reset and nothing on update
     """
     config_json = json.loads(request.data)
     if 'reset_attack_matrix' in config_json:
         AttackConfig.reset_config()
         return jsonify(configuration=AttackConfig.get_config()['properties'])
     else:
         AttackConfig.update_config({'properties': json.loads(request.data)})
         AttackConfig.apply_to_monkey_config()
         return {}
示例#7
0
 def get(self):
     return jsonify(configuration=AttackConfig.get_config()['properties'])
示例#8
0
文件: __init__.py 项目: zkbupt/monkey
 def _is_enabled_in_config(cls) -> bool:
     return AttackConfig.get_technique_values()[cls.tech_id]
示例#9
0
文件: __init__.py 项目: zkbupt/monkey
 def technique_title(cls):
     """
     :return: techniques title. E.g. "T1110 Brute force"
     """
     return AttackConfig.get_technique(cls.tech_id)['title']