Format code using black

This commit is contained in:
Shreya 2021-02-19 00:07:03 +05:30
parent 15107eeea3
commit 8bd30ceb4c
19 changed files with 116 additions and 103 deletions

View File

@ -5,7 +5,7 @@ from infection_monkey.telemetry.attack.attack_telem import AttackTelem
STATUS = ScanStatus.USED
TECHNIQUE = 'T9999'
TECHNIQUE = "T9999"
@pytest.fixture
@ -15,7 +15,6 @@ def attack_telem_test_instance():
def test_attack_telem_send(attack_telem_test_instance, spy_send_telemetry):
attack_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': TECHNIQUE}
expected_data = {"status": STATUS.value, "technique": TECHNIQUE}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -4,8 +4,8 @@ from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.t1005_telem import T1005Telem
GATHERED_DATA_TYPE = '[Type of data collected]'
INFO = '[Additional info]'
GATHERED_DATA_TYPE = "[Type of data collected]"
INFO = "[Additional info]"
STATUS = ScanStatus.USED
@ -16,9 +16,11 @@ def T1005_telem_test_instance():
def test_T1005_send(T1005_telem_test_instance, spy_send_telemetry):
T1005_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': 'T1005',
'gathered_data_type': GATHERED_DATA_TYPE,
'info': INFO}
expected_data = {
"status": STATUS.value,
"technique": "T1005",
"gathered_data_type": GATHERED_DATA_TYPE,
"info": INFO,
}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -15,8 +15,6 @@ def T1035_telem_test_instance():
def test_T1035_send(T1035_telem_test_instance, spy_send_telemetry):
T1035_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': 'T1035',
'usage': USAGE.name}
expected_data = {"status": STATUS.value, "technique": "T1035", "usage": USAGE.name}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -5,7 +5,7 @@ from infection_monkey.telemetry.attack.t1064_telem import T1064Telem
STATUS = ScanStatus.USED
USAGE_STR = '[Usage info]'
USAGE_STR = "[Usage info]"
@pytest.fixture
@ -15,8 +15,6 @@ def T1064_telem_test_instance():
def test_T1064_send(T1064_telem_test_instance, spy_send_telemetry):
T1064_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': 'T1064',
'usage': USAGE_STR}
expected_data = {"status": STATUS.value, "technique": "T1064", "usage": USAGE_STR}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -4,9 +4,9 @@ from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.t1105_telem import T1105Telem
DST_IP = '0.0.0.1'
FILENAME = 'virus.exe'
SRC_IP = '0.0.0.0'
DST_IP = "0.0.0.1"
FILENAME = "virus.exe"
SRC_IP = "0.0.0.0"
STATUS = ScanStatus.USED
@ -17,10 +17,12 @@ def T1105_telem_test_instance():
def test_T1105_send(T1105_telem_test_instance, spy_send_telemetry):
T1105_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': 'T1105',
'filename': FILENAME,
'src': SRC_IP,
'dst': DST_IP}
expected_data = {
"status": STATUS.value,
"technique": "T1105",
"filename": FILENAME,
"src": SRC_IP,
"dst": DST_IP,
}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -15,8 +15,6 @@ def T1106_telem_test_instance():
def test_T1106_send(T1106_telem_test_instance, spy_send_telemetry):
T1106_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': 'T1106',
'usage': USAGE.name}
expected_data = {"status": STATUS.value, "technique": "T1106", "usage": USAGE.name}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -4,7 +4,7 @@ from common.utils.attack_utils import ScanStatus
from infection_monkey.telemetry.attack.t1107_telem import T1107Telem
PATH = 'path/to/file.txt'
PATH = "path/to/file.txt"
STATUS = ScanStatus.USED
@ -15,8 +15,6 @@ def T1107_telem_test_instance():
def test_T1107_send(T1107_telem_test_instance, spy_send_telemetry):
T1107_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': 'T1107',
'path': PATH}
expected_data = {"status": STATUS.value, "technique": "T1107", "path": PATH}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -15,8 +15,6 @@ def T1129_telem_test_instance():
def test_T1129_send(T1129_telem_test_instance, spy_send_telemetry):
T1129_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': 'T1129',
'usage': USAGE.name}
expected_data = {"status": STATUS.value, "technique": "T1129", "usage": USAGE.name}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -5,11 +5,11 @@ from infection_monkey.model import VictimHost
from infection_monkey.telemetry.attack.t1197_telem import T1197Telem
DOMAIN_NAME = 'domain-name'
IP = '127.0.0.1'
DOMAIN_NAME = "domain-name"
IP = "127.0.0.1"
MACHINE = VictimHost(IP, DOMAIN_NAME)
STATUS = ScanStatus.USED
USAGE_STR = '[Usage info]'
USAGE_STR = "[Usage info]"
@pytest.fixture
@ -19,10 +19,11 @@ def T1197_telem_test_instance():
def test_T1197_send(T1197_telem_test_instance, spy_send_telemetry):
T1197_telem_test_instance.send()
expected_data = {'machine': {'domain_name': DOMAIN_NAME,
'ip_addr': IP},
'status': STATUS.value,
'technique': 'T1197',
'usage': USAGE_STR}
expected_data = {
"machine": {"domain_name": DOMAIN_NAME, "ip_addr": IP},
"status": STATUS.value,
"technique": "T1197",
"usage": USAGE_STR,
}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -5,9 +5,9 @@ from infection_monkey.model import VictimHost
from infection_monkey.telemetry.attack.t1222_telem import T1222Telem
COMMAND = 'echo hi'
DOMAIN_NAME = 'domain-name'
IP = '127.0.0.1'
COMMAND = "echo hi"
DOMAIN_NAME = "domain-name"
IP = "127.0.0.1"
MACHINE = VictimHost(IP, DOMAIN_NAME)
STATUS = ScanStatus.USED
@ -19,10 +19,11 @@ def T1222_telem_test_instance():
def test_T1222_send(T1222_telem_test_instance, spy_send_telemetry):
T1222_telem_test_instance.send()
expected_data = {'machine': {'domain_name': DOMAIN_NAME,
'ip_addr': IP},
'status': STATUS.value,
'technique': 'T1222',
'command': COMMAND}
expected_data = {
"machine": {"domain_name": DOMAIN_NAME, "ip_addr": IP},
"status": STATUS.value,
"technique": "T1222",
"command": COMMAND,
}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -5,7 +5,7 @@ from infection_monkey.telemetry.attack.usage_telem import UsageTelem
STATUS = ScanStatus.USED
TECHNIQUE = 'T9999'
TECHNIQUE = "T9999"
USAGE = UsageEnum.SMB
@ -16,8 +16,10 @@ def usage_telem_test_instance():
def test_usage_telem_send(usage_telem_test_instance, spy_send_telemetry):
usage_telem_test_instance.send()
expected_data = {'status': STATUS.value,
'technique': TECHNIQUE,
'usage': USAGE.name}
expected_data = {
"status": STATUS.value,
"technique": TECHNIQUE,
"usage": USAGE.name,
}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -5,11 +5,11 @@ from infection_monkey.model import VictimHost
from infection_monkey.telemetry.attack.victim_host_telem import VictimHostTelem
DOMAIN_NAME = 'domain-name'
IP = '127.0.0.1'
DOMAIN_NAME = "domain-name"
IP = "127.0.0.1"
MACHINE = VictimHost(IP, DOMAIN_NAME)
STATUS = ScanStatus.USED
TECHNIQUE = 'T9999'
TECHNIQUE = "T9999"
@pytest.fixture
@ -19,9 +19,10 @@ def victim_host_telem_test_instance():
def test_victim_host_telem_send(victim_host_telem_test_instance, spy_send_telemetry):
victim_host_telem_test_instance.send()
expected_data = {'machine': {'domain_name': DOMAIN_NAME,
'ip_addr': IP},
'status': STATUS.value,
'technique': TECHNIQUE}
expected_data = {
"machine": {"domain_name": DOMAIN_NAME, "ip_addr": IP},
"status": STATUS.value,
"technique": TECHNIQUE,
}
assert spy_send_telemetry.data == expected_data
assert spy_send_telemetry.telem_category == 'attack'
assert spy_send_telemetry.telem_category == "attack"

View File

@ -11,5 +11,5 @@ def spy_send_telemetry(monkeypatch):
_spy_send_telemetry.telem_category = None
_spy_send_telemetry.data = None
monkeypatch.setattr(ControlClient, 'send_telemetry', _spy_send_telemetry)
monkeypatch.setattr(ControlClient, "send_telemetry", _spy_send_telemetry)
return _spy_send_telemetry

View File

@ -8,22 +8,26 @@ from infection_monkey.telemetry.exploit_telem import ExploitTelem
DOMAIN_NAME = "domain-name"
IP = "0.0.0.0"
HOST = VictimHost(IP, DOMAIN_NAME)
HOST_AS_DICT = {'ip_addr': IP,
'domain_name': DOMAIN_NAME,
'os': {},
'services': {},
'icmp': False,
'monkey_exe': None,
'default_tunnel': None,
'default_server': None}
HOST_AS_DICT = {
"ip_addr": IP,
"domain_name": DOMAIN_NAME,
"os": {},
"services": {},
"icmp": False,
"monkey_exe": None,
"default_tunnel": None,
"default_server": None,
}
EXPLOITER = WmiExploiter(HOST)
EXPLOITER_NAME = 'WmiExploiter'
EXPLOITER_INFO = {'display_name': WmiExploiter._EXPLOITED_SERVICE,
'started': '',
'finished': '',
'vulnerable_urls': [],
'vulnerable_ports': [],
'executed_cmds': []}
EXPLOITER_NAME = "WmiExploiter"
EXPLOITER_INFO = {
"display_name": WmiExploiter._EXPLOITED_SERVICE,
"started": "",
"finished": "",
"vulnerable_urls": [],
"vulnerable_ports": [],
"executed_cmds": [],
}
EXPLOITER_ATTEMPTS = []
RESULT = False

View File

@ -2,10 +2,12 @@ import pytest
from common.data.post_breach_consts import POST_BREACH_JOB_SCHEDULING
from infection_monkey.post_breach.actions.schedule_jobs import ScheduleJobs
from infection_monkey.post_breach.job_scheduling.linux_job_scheduling import \
get_linux_commands_to_schedule_jobs
from infection_monkey.post_breach.job_scheduling.windows_job_scheduling import \
get_windows_commands_to_schedule_jobs
from infection_monkey.post_breach.job_scheduling.linux_job_scheduling import (
get_linux_commands_to_schedule_jobs,
)
from infection_monkey.post_breach.job_scheduling.windows_job_scheduling import (
get_windows_commands_to_schedule_jobs,
)
from infection_monkey.telemetry.post_breach_telem import PostBreachTelem
from infection_monkey.utils.environment import is_windows_os
@ -13,8 +15,11 @@ from infection_monkey.utils.environment import is_windows_os
HOSTNAME = "hostname"
IP = "0.0.0.0"
PBA = ScheduleJobs()
PBA_COMMAND = get_windows_commands_to_schedule_jobs() if is_windows_os() else\
' '.join(get_linux_commands_to_schedule_jobs())
PBA_COMMAND = (
get_windows_commands_to_schedule_jobs()
if is_windows_os()
else " ".join(get_linux_commands_to_schedule_jobs())
)
PBA_NAME = POST_BREACH_JOB_SCHEDULING
RESULT = False

View File

@ -3,17 +3,20 @@ import pytest
from infection_monkey.telemetry.scan_telem import ScanTelem
from infection_monkey.model.host import VictimHost
DOMAIN_NAME = "domain-name"
IP = "0.0.0.0"
HOST = VictimHost(IP, DOMAIN_NAME)
HOST_AS_DICT = {'ip_addr': IP,
'domain_name': DOMAIN_NAME,
'os': {},
'services': {},
'icmp': False,
'monkey_exe': None,
'default_tunnel': None,
'default_server': None}
HOST_AS_DICT = {
"ip_addr": IP,
"domain_name": DOMAIN_NAME,
"os": {},
"services": {},
"icmp": False,
"monkey_exe": None,
"default_tunnel": None,
"default_server": None,
}
HOST_SERVICES = {}

View File

@ -2,6 +2,7 @@ import pytest
from infection_monkey.telemetry.state_telem import StateTelem
IS_DONE = True
VERSION = "version"

View File

@ -2,6 +2,7 @@ import pytest
from infection_monkey.telemetry.system_info_telem import SystemInfoTelem
SYSTEM_INFO = {}

View File

@ -2,6 +2,7 @@ import pytest
from infection_monkey.telemetry.trace_telem import TraceTelem
MSG = "message"