コード例 #1
0
ファイル: monkey_exploitation.py プロジェクト: vanyell/monkey
def get_monkey_exploited() -> List[MonkeyExploitation]:
    exploited_nodes_monkeys_launched = [
        NodeService.get_displayed_node_by_id(monkey["_id"], True)
        for monkey in mongo.db.monkey.find({}, {"_id": 1})
        if not NodeService.get_monkey_manual_run(NodeService.get_monkey_by_id(monkey["_id"]))
    ]

    # The node got exploited, but no monkeys got launched.
    # For example the exploited machine was too old.
    exploited_nodes_monkeys_failed = [
        NodeService.get_displayed_node_by_id(node["_id"], True)
        for node in mongo.db.node.find({"exploited": True}, {"_id": 1})
    ]

    exploited = exploited_nodes_monkeys_launched + exploited_nodes_monkeys_failed

    exploited = [
        MonkeyExploitation(
            label=exploited_node["label"],
            ip_addresses=exploited_node["ip_addresses"],
            domain_name=exploited_node["domain_name"],
            exploits=get_exploits_used_on_node(exploited_node),
        )
        for exploited_node in exploited
    ]

    logger.info("Exploited nodes generated for reporting")

    return exploited
コード例 #2
0
    def get_exploited():
        exploited_with_monkeys = \
            [NodeService.get_displayed_node_by_id(monkey['_id'], True) for monkey in
             mongo.db.monkey.find({}, {'_id': 1}) if
             not NodeService.get_monkey_manual_run(NodeService.get_monkey_by_id(monkey['_id']))]

        exploited_without_monkeys = [
            NodeService.get_displayed_node_by_id(node['_id'], True)
            for node in mongo.db.node.find({'exploited': True}, {'_id': 1})
        ]

        exploited = exploited_with_monkeys + exploited_without_monkeys

        exploited = [{
            'label':
            exploited_node['label'],
            'ip_addresses':
            exploited_node['ip_addresses'],
            'domain_name':
            exploited_node['domain_name'],
            'exploits':
            list(
                set([
                    ReportService.EXPLOIT_DISPLAY_DICT[exploit['exploiter']]
                    for exploit in exploited_node['exploits']
                    if exploit['result']
                ]))
        } for exploited_node in exploited]

        logger.info('Exploited nodes generated for reporting')

        return exploited