forked from p34709852/monkey
Added reverted telemetry files
This commit is contained in:
parent
80266f537d
commit
2e2b77226d
|
@ -17,6 +17,8 @@ from infection_monkey.system_info import SystemInfoCollector
|
||||||
from infection_monkey.system_singleton import SystemSingleton
|
from infection_monkey.system_singleton import SystemSingleton
|
||||||
from infection_monkey.windows_upgrader import WindowsUpgrader
|
from infection_monkey.windows_upgrader import WindowsUpgrader
|
||||||
from infection_monkey.post_breach.post_breach_handler import PostBreach
|
from infection_monkey.post_breach.post_breach_handler import PostBreach
|
||||||
|
from infection_monkey.transport.attack_telems.base_telem import ScanStatus
|
||||||
|
from infection_monkey.transport.attack_telems.victim_host_telem import VictimHostTelem
|
||||||
|
|
||||||
__author__ = 'itamar'
|
__author__ = 'itamar'
|
||||||
|
|
||||||
|
@ -179,9 +181,11 @@ class InfectionMonkey(object):
|
||||||
for exploiter in [exploiter(machine) for exploiter in self._exploiters]:
|
for exploiter in [exploiter(machine) for exploiter in self._exploiters]:
|
||||||
if self.try_exploiting(machine, exploiter):
|
if self.try_exploiting(machine, exploiter):
|
||||||
host_exploited = True
|
host_exploited = True
|
||||||
|
VictimHostTelem('T1210', ScanStatus.USED.value, machine=machine).send()
|
||||||
break
|
break
|
||||||
if not host_exploited:
|
if not host_exploited:
|
||||||
self._fail_exploitation_machines.add(machine)
|
self._fail_exploitation_machines.add(machine)
|
||||||
|
VictimHostTelem('T1210', ScanStatus.SCANNED.value, machine=machine).send()
|
||||||
if not self._keep_running:
|
if not self._keep_running:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'VakarisZ'
|
|
@ -0,0 +1,51 @@
|
||||||
|
from enum import Enum
|
||||||
|
from infection_monkey.config import WormConfiguration, GUID
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from infection_monkey.control import ControlClient
|
||||||
|
import logging
|
||||||
|
|
||||||
|
__author__ = "VakarisZ"
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ScanStatus(Enum):
|
||||||
|
# Technique wasn't scanned
|
||||||
|
UNSCANNED = 0
|
||||||
|
# Technique was attempted/scanned
|
||||||
|
SCANNED = 1
|
||||||
|
# Technique was attempted and succeeded
|
||||||
|
USED = 2
|
||||||
|
|
||||||
|
|
||||||
|
class AttackTelem(object):
|
||||||
|
|
||||||
|
def __init__(self, technique, status, data=None):
|
||||||
|
"""
|
||||||
|
Default ATT&CK telemetry constructor
|
||||||
|
:param technique: Technique ID. E.g. T111
|
||||||
|
:param status: int from ScanStatus Enum
|
||||||
|
:param data: Other data relevant to the attack technique
|
||||||
|
"""
|
||||||
|
self.technique = technique
|
||||||
|
self.result = status
|
||||||
|
self.data = {'status': status, 'id': GUID}
|
||||||
|
if data:
|
||||||
|
self.data.update(data)
|
||||||
|
|
||||||
|
def send(self):
|
||||||
|
"""
|
||||||
|
Sends telemetry to island
|
||||||
|
"""
|
||||||
|
if not WormConfiguration.current_server:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
requests.post("https://%s/api/attack/%s" % (WormConfiguration.current_server, self.technique),
|
||||||
|
data=json.dumps(self.data),
|
||||||
|
headers={'content-type': 'application/json'},
|
||||||
|
verify=False,
|
||||||
|
proxies=ControlClient.proxies)
|
||||||
|
except Exception as exc:
|
||||||
|
LOG.warn("Error connecting to control server %s: %s",
|
||||||
|
WormConfiguration.current_server, exc)
|
|
@ -0,0 +1,21 @@
|
||||||
|
from infection_monkey.transport.attack_telems.base_telem import AttackTelem
|
||||||
|
|
||||||
|
__author__ = "VakarisZ"
|
||||||
|
|
||||||
|
|
||||||
|
class VictimHostTelem(AttackTelem):
|
||||||
|
|
||||||
|
def __init__(self, technique, status, machine, data=None):
|
||||||
|
"""
|
||||||
|
ATT&CK telemetry that parses and sends VictimHost's (remote machine's) data
|
||||||
|
:param technique: Technique ID. E.g. T111
|
||||||
|
:param status: int from ScanStatus Enum
|
||||||
|
:param machine: VictimHost obj from model/host.py
|
||||||
|
:param data: Other data relevant to the attack technique
|
||||||
|
"""
|
||||||
|
super(VictimHostTelem, self).__init__(technique, status, data)
|
||||||
|
victim_host = {'hostname': machine.domain_name, 'ip': machine.ip_addr}
|
||||||
|
if data:
|
||||||
|
self.data.update(data)
|
||||||
|
if machine:
|
||||||
|
self.data.update({'machine': victim_host})
|
|
@ -30,6 +30,7 @@ from cc.resources.telemetry_feed import TelemetryFeed
|
||||||
from cc.resources.pba_file_download import PBAFileDownload
|
from cc.resources.pba_file_download import PBAFileDownload
|
||||||
from cc.services.config import ConfigService
|
from cc.services.config import ConfigService
|
||||||
from cc.resources.pba_file_upload import FileUpload
|
from cc.resources.pba_file_upload import FileUpload
|
||||||
|
from cc.resources.attack_telem import AttackTelem
|
||||||
|
|
||||||
__author__ = 'Barak'
|
__author__ = 'Barak'
|
||||||
|
|
||||||
|
@ -123,5 +124,6 @@ def init_app(mongo_url):
|
||||||
'/api/fileUpload/<string:file_type>?load=<string:filename>',
|
'/api/fileUpload/<string:file_type>?load=<string:filename>',
|
||||||
'/api/fileUpload/<string:file_type>?restore=<string:filename>')
|
'/api/fileUpload/<string:file_type>?restore=<string:filename>')
|
||||||
api.add_resource(RemoteRun, '/api/remote-monkey', '/api/remote-monkey/')
|
api.add_resource(RemoteRun, '/api/remote-monkey', '/api/remote-monkey/')
|
||||||
|
api.add_resource(AttackTelem, '/api/attack/<string:technique>')
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import flask_restful
|
||||||
|
from flask import request
|
||||||
|
import json
|
||||||
|
from cc.services.attack.attack_telem import set_results
|
||||||
|
import logging
|
||||||
|
|
||||||
|
__author__ = 'VakarisZ'
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class AttackTelem(flask_restful.Resource):
|
||||||
|
"""
|
||||||
|
ATT&CK endpoint used to retrieve matrix related info from monkey
|
||||||
|
"""
|
||||||
|
|
||||||
|
def post(self, technique):
|
||||||
|
"""
|
||||||
|
Gets ATT&CK telemetry data and stores it in the database
|
||||||
|
:param technique: Technique ID, e.g. T1111
|
||||||
|
"""
|
||||||
|
data = json.loads(request.data)
|
||||||
|
set_results(technique, data)
|
||||||
|
return {}
|
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'VakarisZ'
|
Loading…
Reference in New Issue