Telemetry implementation started

This commit is contained in:
VakarisZ 2019-03-20 18:46:00 +02:00
parent 287f0ee6e3
commit 98814b4963
3 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1 @@
__author__ = 'VakarisZ'

View File

@ -0,0 +1,41 @@
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, machine=None):
self.technique = technique
self.result = status
self.data = {'machine': machine, 'status': status, 'monkey_guid': GUID}
self.data.update(data)
def send(self):
if not WormConfiguration.current_server:
return
try:
reply = requests.post("https://%s/api/%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)

View File

@ -0,0 +1,22 @@
import flask_restful
from flask import request, send_from_directory, Response
from cc.services.config import ConfigService, PBA_WINDOWS_FILENAME_PATH, PBA_LINUX_FILENAME_PATH, UPLOADS_DIR
from cc.auth import jwt_required
import os
from werkzeug.utils import secure_filename
import logging
import copy
__author__ = 'VakarisZ'
LOG = logging.getLogger(__name__)
class Attack(flask_restful.Resource):
"""
ATT&CK endpoint used to retrieve matrix related info
"""
@jwt_required()
def post(self, attack_type):