forked from p15670423/monkey
Merge branch 'monkey_telemetry_fabrication' into performance_fixes
This commit is contained in:
commit
6930e9d8e0
|
@ -32,4 +32,5 @@ To run telemetry performance test follow these steps:
|
|||
1. Run `telem_parser.py` scrip with working directory set to `monkey\envs\monkey_zoo\blackbox`
|
||||
2. Pass integer to indicate the multiplier. For example running `telem_parser.py 4` will replicate
|
||||
telemetries 4 times.
|
||||
3. If you're using pycharm check "Emulate terminal in output console" on debug/run configuraion.
|
||||
3. Run blackbox tests, telemetry performance test will run as part of it.
|
||||
|
|
|
@ -5,7 +5,7 @@ from datetime import timedelta
|
|||
import requests
|
||||
import functools
|
||||
|
||||
from envs.monkey_zoo.blackbox.island_client.supported_reuqest_method import SupportedRequestMethod
|
||||
from envs.monkey_zoo.blackbox.island_client.supported_request_method import SupportedRequestMethod
|
||||
|
||||
import logging
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ from envs.monkey_zoo.blackbox.island_client.island_config_parser import IslandCo
|
|||
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
|
||||
from envs.monkey_zoo.blackbox.log_handlers.test_logs_handler import TestLogsHandler
|
||||
from envs.monkey_zoo.blackbox.tests.exploitation import ExploitationTest
|
||||
from envs.monkey_zoo.blackbox.tests.performance.map_generation import MapGenerationTest
|
||||
from envs.monkey_zoo.blackbox.tests.performance.report_generation import ReportGenerationTest
|
||||
from envs.monkey_zoo.blackbox.tests.performance.telemetry_performance_test import TelemetryPerformanceTest
|
||||
from envs.monkey_zoo.blackbox.utils import gcp_machine_handlers
|
||||
|
||||
|
@ -24,11 +26,11 @@ LOGGER = logging.getLogger(__name__)
|
|||
@pytest.fixture(autouse=True, scope='session')
|
||||
def GCPHandler(request):
|
||||
GCPHandler = gcp_machine_handlers.GCPHandler()
|
||||
#GCPHandler.start_machines(" ".join(GCP_TEST_MACHINE_LIST))
|
||||
#wait_machine_bootup()
|
||||
GCPHandler.start_machines(" ".join(GCP_TEST_MACHINE_LIST))
|
||||
wait_machine_bootup()
|
||||
|
||||
def fin():
|
||||
#GCPHandler.stop_machines(" ".join(GCP_TEST_MACHINE_LIST))
|
||||
GCPHandler.stop_machines(" ".join(GCP_TEST_MACHINE_LIST))
|
||||
pass
|
||||
|
||||
request.addfinalizer(fin)
|
||||
|
@ -90,60 +92,60 @@ class TestMonkeyBlackbox(object):
|
|||
def test_server_online(self, island_client):
|
||||
assert island_client.get_api_status() is not None
|
||||
|
||||
#def test_ssh_exploiter(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "SSH.conf", "SSH_exploiter_and_keys")
|
||||
#
|
||||
#def test_hadoop_exploiter(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "HADOOP.conf", "Hadoop_exploiter", 6 * 60)
|
||||
#
|
||||
#def test_mssql_exploiter(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "MSSQL.conf", "MSSQL_exploiter")
|
||||
#
|
||||
#def test_smb_and_mimikatz_exploiters(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "SMB_MIMIKATZ.conf", "SMB_exploiter_mimikatz")
|
||||
#
|
||||
#def test_smb_pth(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "SMB_PTH.conf", "SMB_PTH")
|
||||
#
|
||||
#def test_elastic_exploiter(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "ELASTIC.conf", "Elastic_exploiter")
|
||||
#
|
||||
#def test_struts_exploiter(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "STRUTS2.conf", "Strtuts2_exploiter")
|
||||
#
|
||||
#def test_weblogic_exploiter(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "WEBLOGIC.conf", "Weblogic_exploiter")
|
||||
#
|
||||
#def test_shellshock_exploiter(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "SHELLSHOCK.conf", "Shellschock_exploiter")
|
||||
#
|
||||
#def test_tunneling(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "TUNNELING.conf", "Tunneling_exploiter", 15 * 60)
|
||||
#
|
||||
#def test_wmi_and_mimikatz_exploiters(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "WMI_MIMIKATZ.conf", "WMI_exploiter,_mimikatz")
|
||||
#
|
||||
#def test_wmi_pth(self, island_client):
|
||||
# TestMonkeyBlackbox.run_exploitation_test(island_client, "WMI_PTH.conf", "WMI_PTH")
|
||||
#
|
||||
#def test_report_generation_performance(self, island_client):
|
||||
# """
|
||||
# This test includes the SSH + Elastic + Hadoop + MSSQL machines all in one test
|
||||
# for a total of 8 machines including the Monkey Island.
|
||||
#
|
||||
# Is has 2 analyzers - the regular one which checks all the Monkeys
|
||||
# and the Timing one which checks how long the report took to execute
|
||||
# """
|
||||
# TestMonkeyBlackbox.run_performance_test(ReportGenerationTest,
|
||||
# island_client,
|
||||
# "PERFORMANCE.conf",
|
||||
# timeout_in_seconds=10*60)
|
||||
#
|
||||
#def test_map_generation_performance(self, island_client):
|
||||
# TestMonkeyBlackbox.run_performance_test(MapGenerationTest,
|
||||
# island_client,
|
||||
# "PERFORMANCE.conf",
|
||||
# timeout_in_seconds=10*60)
|
||||
def test_ssh_exploiter(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "SSH.conf", "SSH_exploiter_and_keys")
|
||||
|
||||
def test_hadoop_exploiter(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "HADOOP.conf", "Hadoop_exploiter", 6 * 60)
|
||||
|
||||
def test_mssql_exploiter(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "MSSQL.conf", "MSSQL_exploiter")
|
||||
|
||||
def test_smb_and_mimikatz_exploiters(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "SMB_MIMIKATZ.conf", "SMB_exploiter_mimikatz")
|
||||
|
||||
def test_smb_pth(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "SMB_PTH.conf", "SMB_PTH")
|
||||
|
||||
def test_elastic_exploiter(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "ELASTIC.conf", "Elastic_exploiter")
|
||||
|
||||
def test_struts_exploiter(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "STRUTS2.conf", "Strtuts2_exploiter")
|
||||
|
||||
def test_weblogic_exploiter(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "WEBLOGIC.conf", "Weblogic_exploiter")
|
||||
|
||||
def test_shellshock_exploiter(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "SHELLSHOCK.conf", "Shellschock_exploiter")
|
||||
|
||||
def test_tunneling(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "TUNNELING.conf", "Tunneling_exploiter", 15 * 60)
|
||||
|
||||
def test_wmi_and_mimikatz_exploiters(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "WMI_MIMIKATZ.conf", "WMI_exploiter,_mimikatz")
|
||||
|
||||
def test_wmi_pth(self, island_client):
|
||||
TestMonkeyBlackbox.run_exploitation_test(island_client, "WMI_PTH.conf", "WMI_PTH")
|
||||
|
||||
def test_report_generation_performance(self, island_client):
|
||||
"""
|
||||
This test includes the SSH + Elastic + Hadoop + MSSQL machines all in one test
|
||||
for a total of 8 machines including the Monkey Island.
|
||||
|
||||
Is has 2 analyzers - the regular one which checks all the Monkeys
|
||||
and the Timing one which checks how long the report took to execute
|
||||
"""
|
||||
TestMonkeyBlackbox.run_performance_test(ReportGenerationTest,
|
||||
island_client,
|
||||
"PERFORMANCE.conf",
|
||||
timeout_in_seconds=10*60)
|
||||
|
||||
def test_map_generation_performance(self, island_client):
|
||||
TestMonkeyBlackbox.run_performance_test(MapGenerationTest,
|
||||
island_client,
|
||||
"PERFORMANCE.conf",
|
||||
timeout_in_seconds=10*60)
|
||||
|
||||
def test_telem_performance(self, island_client):
|
||||
TelemetryPerformanceTest(island_client).test_telemetry_performance()
|
||||
|
|
|
@ -2,7 +2,7 @@ import logging
|
|||
|
||||
from envs.monkey_zoo.blackbox.analyzers.performance_analyzer import PerformanceAnalyzer
|
||||
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
|
||||
from envs.monkey_zoo.blackbox.island_client.supported_reuqest_method import SupportedRequestMethod
|
||||
from envs.monkey_zoo.blackbox.island_client.supported_request_method import SupportedRequestMethod
|
||||
from envs.monkey_zoo.blackbox.tests.basic_test import BasicTest
|
||||
from envs.monkey_zoo.blackbox.tests.performance.performance_test_config import PerformanceTestConfig
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from tqdm import tqdm
|
|||
|
||||
from envs.monkey_zoo.blackbox.analyzers.performance_analyzer import PerformanceAnalyzer
|
||||
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
|
||||
from envs.monkey_zoo.blackbox.island_client.supported_reuqest_method import SupportedRequestMethod
|
||||
from envs.monkey_zoo.blackbox.island_client.supported_request_method import SupportedRequestMethod
|
||||
from envs.monkey_zoo.blackbox.tests.performance.performance_test_config import PerformanceTestConfig
|
||||
from envs.monkey_zoo.blackbox.tests.performance.utils.telem_parser import TelemParser
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class TelemParser:
|
|||
telems = TelemParser.get_all_telemetries()
|
||||
telem_contents = [json.loads(telem['content']) for telem in telems]
|
||||
monkeys = self.get_monkeys_from_telems(telem_contents)
|
||||
for i in tqdm(range(self.multiplier), desc="Batch of fabricated telemetries"):
|
||||
for i in tqdm(range(self.multiplier), desc="Batch of fabricated telemetries", position=1):
|
||||
for monkey in monkeys:
|
||||
monkey.change_fake_data()
|
||||
fake_telem_batch = copy.deepcopy(telems)
|
||||
|
@ -34,7 +34,7 @@ class TelemParser:
|
|||
|
||||
@staticmethod
|
||||
def fabricate_monkeys_in_telems(telems: List[Dict], monkeys: List[FakeMonkey]):
|
||||
for telem in tqdm(telems, desc="Teletry"):
|
||||
for telem in tqdm(telems, desc="Telemetries fabricated", position=2):
|
||||
for monkey in monkeys:
|
||||
if monkey.on_island:
|
||||
continue
|
||||
|
@ -51,7 +51,7 @@ class TelemParser:
|
|||
|
||||
@staticmethod
|
||||
def save_teletries_to_files(telems: List[Dict]):
|
||||
for telem in telems:
|
||||
for telem in (tqdm(telems, desc="Telemetries saved to files", position=3)):
|
||||
TelemParser.save_telemetry_to_file(telem)
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Reference in New Issue