From b65524a85dde5cc8be7840636af6e88a84bc2430 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 8 Mar 2021 15:41:22 +0200 Subject: [PATCH 1/5] Refactored "island_configs" dir to "config_templates" dir in blackbox --- .../__init__.py | 0 .../base_template.py | 2 +- .../config_template.py | 0 .../drupal.py | 0 .../elastic.py | 4 +-- .../hadoop.py | 2 +- .../mssql.py | 2 +- .../performance.py | 2 +- .../shellshock.py | 2 +- .../smb_mimikatz.py | 2 +- .../smb_pth.py | 2 +- .../ssh.py | 2 +- .../struts2.py | 2 +- .../tunneling.py | 2 +- .../weblogic.py | 2 +- .../wmi_mimikatz.py | 2 +- .../wmi_pth.py | 2 +- .../zerologon.py | 2 +- .../island_client/island_config_parser.py | 2 +- envs/monkey_zoo/blackbox/test_blackbox.py | 32 +++++++++---------- 20 files changed, 33 insertions(+), 33 deletions(-) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/__init__.py (100%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/base_template.py (85%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/config_template.py (100%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/drupal.py (100%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/elastic.py (63%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/hadoop.py (77%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/mssql.py (89%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/performance.py (97%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/shellshock.py (77%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/smb_mimikatz.py (91%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/smb_pth.py (91%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/ssh.py (91%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/struts2.py (77%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/tunneling.py (94%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/weblogic.py (78%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/wmi_mimikatz.py (92%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/wmi_pth.py (91%) rename envs/monkey_zoo/blackbox/{island_configs => config_templates}/zerologon.py (83%) diff --git a/envs/monkey_zoo/blackbox/island_configs/__init__.py b/envs/monkey_zoo/blackbox/config_templates/__init__.py similarity index 100% rename from envs/monkey_zoo/blackbox/island_configs/__init__.py rename to envs/monkey_zoo/blackbox/config_templates/__init__.py diff --git a/envs/monkey_zoo/blackbox/island_configs/base_template.py b/envs/monkey_zoo/blackbox/config_templates/base_template.py similarity index 85% rename from envs/monkey_zoo/blackbox/island_configs/base_template.py rename to envs/monkey_zoo/blackbox/config_templates/base_template.py index 13a480286..9ebea6f1f 100644 --- a/envs/monkey_zoo/blackbox/island_configs/base_template.py +++ b/envs/monkey_zoo/blackbox/config_templates/base_template.py @@ -1,4 +1,4 @@ -from envs.monkey_zoo.blackbox.island_configs.config_template import ConfigTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate # Disables a lot of config values not required for a specific feature test diff --git a/envs/monkey_zoo/blackbox/island_configs/config_template.py b/envs/monkey_zoo/blackbox/config_templates/config_template.py similarity index 100% rename from envs/monkey_zoo/blackbox/island_configs/config_template.py rename to envs/monkey_zoo/blackbox/config_templates/config_template.py diff --git a/envs/monkey_zoo/blackbox/island_configs/drupal.py b/envs/monkey_zoo/blackbox/config_templates/drupal.py similarity index 100% rename from envs/monkey_zoo/blackbox/island_configs/drupal.py rename to envs/monkey_zoo/blackbox/config_templates/drupal.py diff --git a/envs/monkey_zoo/blackbox/island_configs/elastic.py b/envs/monkey_zoo/blackbox/config_templates/elastic.py similarity index 63% rename from envs/monkey_zoo/blackbox/island_configs/elastic.py rename to envs/monkey_zoo/blackbox/config_templates/elastic.py index 97598f718..1385366a8 100644 --- a/envs/monkey_zoo/blackbox/island_configs/elastic.py +++ b/envs/monkey_zoo/blackbox/config_templates/elastic.py @@ -1,7 +1,7 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate -from envs.monkey_zoo.blackbox.island_configs.config_template import ConfigTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate class Elastic(ConfigTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/hadoop.py b/envs/monkey_zoo/blackbox/config_templates/hadoop.py similarity index 77% rename from envs/monkey_zoo/blackbox/island_configs/hadoop.py rename to envs/monkey_zoo/blackbox/config_templates/hadoop.py index 8c42b8ee3..0d26c4b64 100644 --- a/envs/monkey_zoo/blackbox/island_configs/hadoop.py +++ b/envs/monkey_zoo/blackbox/config_templates/hadoop.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class Hadoop(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/mssql.py b/envs/monkey_zoo/blackbox/config_templates/mssql.py similarity index 89% rename from envs/monkey_zoo/blackbox/island_configs/mssql.py rename to envs/monkey_zoo/blackbox/config_templates/mssql.py index 5406494ee..1190e5c82 100644 --- a/envs/monkey_zoo/blackbox/island_configs/mssql.py +++ b/envs/monkey_zoo/blackbox/config_templates/mssql.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class Mssql(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/performance.py b/envs/monkey_zoo/blackbox/config_templates/performance.py similarity index 97% rename from envs/monkey_zoo/blackbox/island_configs/performance.py rename to envs/monkey_zoo/blackbox/config_templates/performance.py index 3a9a48e9f..e9e34727d 100644 --- a/envs/monkey_zoo/blackbox/island_configs/performance.py +++ b/envs/monkey_zoo/blackbox/config_templates/performance.py @@ -1,4 +1,4 @@ -from envs.monkey_zoo.blackbox.island_configs.config_template import ConfigTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate class Performance(ConfigTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/shellshock.py b/envs/monkey_zoo/blackbox/config_templates/shellshock.py similarity index 77% rename from envs/monkey_zoo/blackbox/island_configs/shellshock.py rename to envs/monkey_zoo/blackbox/config_templates/shellshock.py index 27e0dc34d..d7e72d61d 100644 --- a/envs/monkey_zoo/blackbox/island_configs/shellshock.py +++ b/envs/monkey_zoo/blackbox/config_templates/shellshock.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class ShellShock(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/smb_mimikatz.py b/envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py similarity index 91% rename from envs/monkey_zoo/blackbox/island_configs/smb_mimikatz.py rename to envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py index aed4ee9c7..314a0875b 100644 --- a/envs/monkey_zoo/blackbox/island_configs/smb_mimikatz.py +++ b/envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class SmbMimikatz(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/smb_pth.py b/envs/monkey_zoo/blackbox/config_templates/smb_pth.py similarity index 91% rename from envs/monkey_zoo/blackbox/island_configs/smb_pth.py rename to envs/monkey_zoo/blackbox/config_templates/smb_pth.py index 3bb92347e..966116f6d 100644 --- a/envs/monkey_zoo/blackbox/island_configs/smb_pth.py +++ b/envs/monkey_zoo/blackbox/config_templates/smb_pth.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class SmbPth(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/ssh.py b/envs/monkey_zoo/blackbox/config_templates/ssh.py similarity index 91% rename from envs/monkey_zoo/blackbox/island_configs/ssh.py rename to envs/monkey_zoo/blackbox/config_templates/ssh.py index a0c3a285e..7f36a9dc2 100644 --- a/envs/monkey_zoo/blackbox/island_configs/ssh.py +++ b/envs/monkey_zoo/blackbox/config_templates/ssh.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class Ssh(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/struts2.py b/envs/monkey_zoo/blackbox/config_templates/struts2.py similarity index 77% rename from envs/monkey_zoo/blackbox/island_configs/struts2.py rename to envs/monkey_zoo/blackbox/config_templates/struts2.py index a94ae714a..9f1633744 100644 --- a/envs/monkey_zoo/blackbox/island_configs/struts2.py +++ b/envs/monkey_zoo/blackbox/config_templates/struts2.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class Struts2(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/tunneling.py b/envs/monkey_zoo/blackbox/config_templates/tunneling.py similarity index 94% rename from envs/monkey_zoo/blackbox/island_configs/tunneling.py rename to envs/monkey_zoo/blackbox/config_templates/tunneling.py index 9badf1a17..0e44765ef 100644 --- a/envs/monkey_zoo/blackbox/island_configs/tunneling.py +++ b/envs/monkey_zoo/blackbox/config_templates/tunneling.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class Tunneling(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/weblogic.py b/envs/monkey_zoo/blackbox/config_templates/weblogic.py similarity index 78% rename from envs/monkey_zoo/blackbox/island_configs/weblogic.py rename to envs/monkey_zoo/blackbox/config_templates/weblogic.py index 8632f0efa..d9167a923 100644 --- a/envs/monkey_zoo/blackbox/island_configs/weblogic.py +++ b/envs/monkey_zoo/blackbox/config_templates/weblogic.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class Weblogic(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/wmi_mimikatz.py b/envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py similarity index 92% rename from envs/monkey_zoo/blackbox/island_configs/wmi_mimikatz.py rename to envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py index 11b0fc026..8be744f6c 100644 --- a/envs/monkey_zoo/blackbox/island_configs/wmi_mimikatz.py +++ b/envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class WmiMimikatz(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/wmi_pth.py b/envs/monkey_zoo/blackbox/config_templates/wmi_pth.py similarity index 91% rename from envs/monkey_zoo/blackbox/island_configs/wmi_pth.py rename to envs/monkey_zoo/blackbox/config_templates/wmi_pth.py index a435f25e4..84d950a86 100644 --- a/envs/monkey_zoo/blackbox/island_configs/wmi_pth.py +++ b/envs/monkey_zoo/blackbox/config_templates/wmi_pth.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class WmiPth(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_configs/zerologon.py b/envs/monkey_zoo/blackbox/config_templates/zerologon.py similarity index 83% rename from envs/monkey_zoo/blackbox/island_configs/zerologon.py rename to envs/monkey_zoo/blackbox/config_templates/zerologon.py index 6b84589fb..7e0fef8d8 100644 --- a/envs/monkey_zoo/blackbox/island_configs/zerologon.py +++ b/envs/monkey_zoo/blackbox/config_templates/zerologon.py @@ -1,6 +1,6 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate class Zerologon(BaseTemplate): diff --git a/envs/monkey_zoo/blackbox/island_client/island_config_parser.py b/envs/monkey_zoo/blackbox/island_client/island_config_parser.py index d9e81957e..5b7211f87 100644 --- a/envs/monkey_zoo/blackbox/island_client/island_config_parser.py +++ b/envs/monkey_zoo/blackbox/island_client/island_config_parser.py @@ -4,7 +4,7 @@ import dpath.util from typing_extensions import Type from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient -from envs.monkey_zoo.blackbox.island_configs.config_template import ConfigTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate class IslandConfigParser: diff --git a/envs/monkey_zoo/blackbox/test_blackbox.py b/envs/monkey_zoo/blackbox/test_blackbox.py index ff2e2cde2..bfcf32fba 100644 --- a/envs/monkey_zoo/blackbox/test_blackbox.py +++ b/envs/monkey_zoo/blackbox/test_blackbox.py @@ -12,22 +12,22 @@ from envs.monkey_zoo.blackbox.island_client.island_config_parser import \ IslandConfigParser from envs.monkey_zoo.blackbox.island_client.monkey_island_client import \ MonkeyIslandClient -from envs.monkey_zoo.blackbox.island_configs.config_template import ConfigTemplate -from envs.monkey_zoo.blackbox.island_configs.drupal import Drupal -from envs.monkey_zoo.blackbox.island_configs.elastic import Elastic -from envs.monkey_zoo.blackbox.island_configs.hadoop import Hadoop -from envs.monkey_zoo.blackbox.island_configs.mssql import Mssql -from envs.monkey_zoo.blackbox.island_configs.performance import Performance -from envs.monkey_zoo.blackbox.island_configs.shellshock import ShellShock -from envs.monkey_zoo.blackbox.island_configs.smb_mimikatz import SmbMimikatz -from envs.monkey_zoo.blackbox.island_configs.smb_pth import SmbPth -from envs.monkey_zoo.blackbox.island_configs.ssh import Ssh -from envs.monkey_zoo.blackbox.island_configs.struts2 import Struts2 -from envs.monkey_zoo.blackbox.island_configs.tunneling import Tunneling -from envs.monkey_zoo.blackbox.island_configs.weblogic import Weblogic -from envs.monkey_zoo.blackbox.island_configs.wmi_mimikatz import WmiMimikatz -from envs.monkey_zoo.blackbox.island_configs.wmi_pth import WmiPth -from envs.monkey_zoo.blackbox.island_configs.zerologon import Zerologon +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate +from envs.monkey_zoo.blackbox.config_templates.drupal import Drupal +from envs.monkey_zoo.blackbox.config_templates.elastic import Elastic +from envs.monkey_zoo.blackbox.config_templates.hadoop import Hadoop +from envs.monkey_zoo.blackbox.config_templates.mssql import Mssql +from envs.monkey_zoo.blackbox.config_templates.performance import Performance +from envs.monkey_zoo.blackbox.config_templates.shellshock import ShellShock +from envs.monkey_zoo.blackbox.config_templates.smb_mimikatz import SmbMimikatz +from envs.monkey_zoo.blackbox.config_templates.smb_pth import SmbPth +from envs.monkey_zoo.blackbox.config_templates.ssh import Ssh +from envs.monkey_zoo.blackbox.config_templates.struts2 import Struts2 +from envs.monkey_zoo.blackbox.config_templates.tunneling import Tunneling +from envs.monkey_zoo.blackbox.config_templates.weblogic import Weblogic +from envs.monkey_zoo.blackbox.config_templates.wmi_mimikatz import WmiMimikatz +from envs.monkey_zoo.blackbox.config_templates.wmi_pth import WmiPth +from envs.monkey_zoo.blackbox.config_templates.zerologon import Zerologon from envs.monkey_zoo.blackbox.log_handlers.test_logs_handler import \ TestLogsHandler from envs.monkey_zoo.blackbox.tests.exploitation import ExploitationTest From 5f41ce54c6627c30419418dcc77eeecc36bf8677 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 8 Mar 2021 17:13:35 +0200 Subject: [PATCH 2/5] Added config file generation script, which can generate config files from config templates. --- envs/monkey_zoo/blackbox/utils/README.md | 9 +++ .../utils/config_generation_script.py | 69 +++++++++++++++++++ .../utils/generated_configs/.gitignore | 1 + 3 files changed, 79 insertions(+) create mode 100644 envs/monkey_zoo/blackbox/utils/README.md create mode 100644 envs/monkey_zoo/blackbox/utils/config_generation_script.py create mode 100644 envs/monkey_zoo/blackbox/utils/generated_configs/.gitignore diff --git a/envs/monkey_zoo/blackbox/utils/README.md b/envs/monkey_zoo/blackbox/utils/README.md new file mode 100644 index 000000000..b5d8e9125 --- /dev/null +++ b/envs/monkey_zoo/blackbox/utils/README.md @@ -0,0 +1,9 @@ +# BlackBox utility scripts + +## Config generation script + +This script is used to generate config files for manual tests. +Config file will be generated according to the templates in `envs/monkey_zoo/blackbox/config_templates`. + +Run `envs/monkey_zoo/blackbox/utils/config_generation_script.py` to populate +`envs/monkey_zoo/blackbox/utils/generated_configs` directory with configuration files. diff --git a/envs/monkey_zoo/blackbox/utils/config_generation_script.py b/envs/monkey_zoo/blackbox/utils/config_generation_script.py new file mode 100644 index 000000000..7ecee6bd7 --- /dev/null +++ b/envs/monkey_zoo/blackbox/utils/config_generation_script.py @@ -0,0 +1,69 @@ +import argparse +import pathlib +from typing import Type + +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate +from envs.monkey_zoo.blackbox.config_templates.elastic import Elastic +from envs.monkey_zoo.blackbox.config_templates.hadoop import Hadoop +from envs.monkey_zoo.blackbox.config_templates.mssql import Mssql +from envs.monkey_zoo.blackbox.config_templates.performance import Performance +from envs.monkey_zoo.blackbox.config_templates.shellshock import ShellShock +from envs.monkey_zoo.blackbox.config_templates.smb_mimikatz import SmbMimikatz +from envs.monkey_zoo.blackbox.config_templates.smb_pth import SmbPth +from envs.monkey_zoo.blackbox.config_templates.ssh import Ssh +from envs.monkey_zoo.blackbox.config_templates.struts2 import Struts2 +from envs.monkey_zoo.blackbox.config_templates.tunneling import Tunneling +from envs.monkey_zoo.blackbox.config_templates.weblogic import Weblogic +from envs.monkey_zoo.blackbox.config_templates.wmi_mimikatz import WmiMimikatz +from envs.monkey_zoo.blackbox.config_templates.wmi_pth import WmiPth +from envs.monkey_zoo.blackbox.config_templates.zerologon import Zerologon +from envs.monkey_zoo.blackbox.island_client.island_config_parser import IslandConfigParser +from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient + +DST_DIR_NAME = 'generated_configs' +DST_DIR_PATH = pathlib.Path(pathlib.Path(__file__).parent.absolute(), DST_DIR_NAME) + +parser = argparse.ArgumentParser(description='Generate config files.') +parser.add_argument('island_ip', metavar='IP:PORT', + help='Island endpoint. Example: 123.123.123.123:5000') + +args = parser.parse_args() +island_client = MonkeyIslandClient(args.island_ip) + + +CONFIG_TEMPLATES = [ + Elastic, + Hadoop, + Mssql, + Performance, + ShellShock, + SmbMimikatz, + SmbPth, + Ssh, + Struts2, + Tunneling, + Weblogic, + WmiMimikatz, + WmiPth, + Zerologon +] + + +def generate_templates(): + for template in CONFIG_TEMPLATES: + save_template_as_config(template) + + +def save_template_as_config(template: Type[ConfigTemplate]): + file_path = pathlib.Path(DST_DIR_PATH, f"{template.__name__}.conf") + file_contents = IslandConfigParser.get_raw_config(template, island_client) + save_to_file(file_path, file_contents) + + +def save_to_file(file_path, contents): + with open(file_path, 'w') as file: + file.write(contents) + + +if __name__ == '__main__': + generate_templates() diff --git a/envs/monkey_zoo/blackbox/utils/generated_configs/.gitignore b/envs/monkey_zoo/blackbox/utils/generated_configs/.gitignore new file mode 100644 index 000000000..9c558e357 --- /dev/null +++ b/envs/monkey_zoo/blackbox/utils/generated_configs/.gitignore @@ -0,0 +1 @@ +. From 6a6dd6711392c28c084afcd1474997869e593aaa Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 8 Mar 2021 17:16:32 +0200 Subject: [PATCH 3/5] Refactored config templates to inherit from ConfigTemplate class instead of BaseTemplate --- envs/monkey_zoo/blackbox/config_templates/drupal.py | 5 +++-- envs/monkey_zoo/blackbox/config_templates/hadoop.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/mssql.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/shellshock.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/smb_pth.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/ssh.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/struts2.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/tunneling.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/weblogic.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/wmi_pth.py | 3 ++- envs/monkey_zoo/blackbox/config_templates/zerologon.py | 3 ++- 13 files changed, 27 insertions(+), 14 deletions(-) diff --git a/envs/monkey_zoo/blackbox/config_templates/drupal.py b/envs/monkey_zoo/blackbox/config_templates/drupal.py index da2b41ac6..e202219dc 100644 --- a/envs/monkey_zoo/blackbox/config_templates/drupal.py +++ b/envs/monkey_zoo/blackbox/config_templates/drupal.py @@ -1,9 +1,10 @@ from copy import copy -from envs.monkey_zoo.blackbox.island_configs.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Drupal(BaseTemplate): +class Drupal(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/hadoop.py b/envs/monkey_zoo/blackbox/config_templates/hadoop.py index 0d26c4b64..d136068e5 100644 --- a/envs/monkey_zoo/blackbox/config_templates/hadoop.py +++ b/envs/monkey_zoo/blackbox/config_templates/hadoop.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Hadoop(BaseTemplate): +class Hadoop(ConfigTemplate): config_values = copy(BaseTemplate.config_values) diff --git a/envs/monkey_zoo/blackbox/config_templates/mssql.py b/envs/monkey_zoo/blackbox/config_templates/mssql.py index 1190e5c82..003f9f8d3 100644 --- a/envs/monkey_zoo/blackbox/config_templates/mssql.py +++ b/envs/monkey_zoo/blackbox/config_templates/mssql.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Mssql(BaseTemplate): +class Mssql(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/shellshock.py b/envs/monkey_zoo/blackbox/config_templates/shellshock.py index d7e72d61d..71d968e0b 100644 --- a/envs/monkey_zoo/blackbox/config_templates/shellshock.py +++ b/envs/monkey_zoo/blackbox/config_templates/shellshock.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class ShellShock(BaseTemplate): +class ShellShock(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py b/envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py index 314a0875b..f563bc8d1 100644 --- a/envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py +++ b/envs/monkey_zoo/blackbox/config_templates/smb_mimikatz.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class SmbMimikatz(BaseTemplate): +class SmbMimikatz(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/smb_pth.py b/envs/monkey_zoo/blackbox/config_templates/smb_pth.py index 966116f6d..edee4cdbd 100644 --- a/envs/monkey_zoo/blackbox/config_templates/smb_pth.py +++ b/envs/monkey_zoo/blackbox/config_templates/smb_pth.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class SmbPth(BaseTemplate): +class SmbPth(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_value_list = { diff --git a/envs/monkey_zoo/blackbox/config_templates/ssh.py b/envs/monkey_zoo/blackbox/config_templates/ssh.py index 7f36a9dc2..90871e52b 100644 --- a/envs/monkey_zoo/blackbox/config_templates/ssh.py +++ b/envs/monkey_zoo/blackbox/config_templates/ssh.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Ssh(BaseTemplate): +class Ssh(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/struts2.py b/envs/monkey_zoo/blackbox/config_templates/struts2.py index 9f1633744..6eb399568 100644 --- a/envs/monkey_zoo/blackbox/config_templates/struts2.py +++ b/envs/monkey_zoo/blackbox/config_templates/struts2.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Struts2(BaseTemplate): +class Struts2(ConfigTemplate): config_values = copy(BaseTemplate.config_values) diff --git a/envs/monkey_zoo/blackbox/config_templates/tunneling.py b/envs/monkey_zoo/blackbox/config_templates/tunneling.py index 0e44765ef..ac735eea4 100644 --- a/envs/monkey_zoo/blackbox/config_templates/tunneling.py +++ b/envs/monkey_zoo/blackbox/config_templates/tunneling.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Tunneling(BaseTemplate): +class Tunneling(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/weblogic.py b/envs/monkey_zoo/blackbox/config_templates/weblogic.py index d9167a923..482f7abf9 100644 --- a/envs/monkey_zoo/blackbox/config_templates/weblogic.py +++ b/envs/monkey_zoo/blackbox/config_templates/weblogic.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Weblogic(BaseTemplate): +class Weblogic(ConfigTemplate): config_values = copy(BaseTemplate.config_values) diff --git a/envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py b/envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py index 8be744f6c..b6dbc0c88 100644 --- a/envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py +++ b/envs/monkey_zoo/blackbox/config_templates/wmi_mimikatz.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class WmiMimikatz(BaseTemplate): +class WmiMimikatz(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/wmi_pth.py b/envs/monkey_zoo/blackbox/config_templates/wmi_pth.py index 84d950a86..ddc5cfaba 100644 --- a/envs/monkey_zoo/blackbox/config_templates/wmi_pth.py +++ b/envs/monkey_zoo/blackbox/config_templates/wmi_pth.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class WmiPth(BaseTemplate): +class WmiPth(ConfigTemplate): config_values = copy(BaseTemplate.config_values) config_values.update({ diff --git a/envs/monkey_zoo/blackbox/config_templates/zerologon.py b/envs/monkey_zoo/blackbox/config_templates/zerologon.py index 7e0fef8d8..28afa281f 100644 --- a/envs/monkey_zoo/blackbox/config_templates/zerologon.py +++ b/envs/monkey_zoo/blackbox/config_templates/zerologon.py @@ -1,9 +1,10 @@ from copy import copy from envs.monkey_zoo.blackbox.config_templates.base_template import BaseTemplate +from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate -class Zerologon(BaseTemplate): +class Zerologon(ConfigTemplate): config_values = copy(BaseTemplate.config_values) From c234891330defabf496c2dd444023ae9eb16c99f Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 8 Mar 2021 17:27:57 +0200 Subject: [PATCH 4/5] Minor fixes in config file generation script: added island IP param in docs and added Drupal to configs --- envs/monkey_zoo/blackbox/utils/README.md | 2 +- envs/monkey_zoo/blackbox/utils/config_generation_script.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/envs/monkey_zoo/blackbox/utils/README.md b/envs/monkey_zoo/blackbox/utils/README.md index b5d8e9125..638e54c92 100644 --- a/envs/monkey_zoo/blackbox/utils/README.md +++ b/envs/monkey_zoo/blackbox/utils/README.md @@ -5,5 +5,5 @@ This script is used to generate config files for manual tests. Config file will be generated according to the templates in `envs/monkey_zoo/blackbox/config_templates`. -Run `envs/monkey_zoo/blackbox/utils/config_generation_script.py` to populate +Run `envs/monkey_zoo/blackbox/utils/config_generation_script.py island_ip:5000` to populate `envs/monkey_zoo/blackbox/utils/generated_configs` directory with configuration files. diff --git a/envs/monkey_zoo/blackbox/utils/config_generation_script.py b/envs/monkey_zoo/blackbox/utils/config_generation_script.py index 7ecee6bd7..f11fb31f4 100644 --- a/envs/monkey_zoo/blackbox/utils/config_generation_script.py +++ b/envs/monkey_zoo/blackbox/utils/config_generation_script.py @@ -3,6 +3,7 @@ import pathlib from typing import Type from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate +from envs.monkey_zoo.blackbox.config_templates.drupal import Drupal from envs.monkey_zoo.blackbox.config_templates.elastic import Elastic from envs.monkey_zoo.blackbox.config_templates.hadoop import Hadoop from envs.monkey_zoo.blackbox.config_templates.mssql import Mssql @@ -45,7 +46,8 @@ CONFIG_TEMPLATES = [ Weblogic, WmiMimikatz, WmiPth, - Zerologon + Zerologon, + Drupal ] From a4aee364b450e39608a214ece163f9c8ca702813 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 9 Mar 2021 10:23:35 +0200 Subject: [PATCH 5/5] Ran black on config generation script --- .../utils/config_generation_script.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/envs/monkey_zoo/blackbox/utils/config_generation_script.py b/envs/monkey_zoo/blackbox/utils/config_generation_script.py index f11fb31f4..603e9fe4d 100644 --- a/envs/monkey_zoo/blackbox/utils/config_generation_script.py +++ b/envs/monkey_zoo/blackbox/utils/config_generation_script.py @@ -18,15 +18,22 @@ from envs.monkey_zoo.blackbox.config_templates.weblogic import Weblogic from envs.monkey_zoo.blackbox.config_templates.wmi_mimikatz import WmiMimikatz from envs.monkey_zoo.blackbox.config_templates.wmi_pth import WmiPth from envs.monkey_zoo.blackbox.config_templates.zerologon import Zerologon -from envs.monkey_zoo.blackbox.island_client.island_config_parser import IslandConfigParser -from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient +from envs.monkey_zoo.blackbox.island_client.island_config_parser import ( + IslandConfigParser, +) +from envs.monkey_zoo.blackbox.island_client.monkey_island_client import ( + MonkeyIslandClient, +) -DST_DIR_NAME = 'generated_configs' +DST_DIR_NAME = "generated_configs" DST_DIR_PATH = pathlib.Path(pathlib.Path(__file__).parent.absolute(), DST_DIR_NAME) -parser = argparse.ArgumentParser(description='Generate config files.') -parser.add_argument('island_ip', metavar='IP:PORT', - help='Island endpoint. Example: 123.123.123.123:5000') +parser = argparse.ArgumentParser(description="Generate config files.") +parser.add_argument( + "island_ip", + metavar="IP:PORT", + help="Island endpoint. Example: 123.123.123.123:5000", +) args = parser.parse_args() island_client = MonkeyIslandClient(args.island_ip) @@ -47,7 +54,7 @@ CONFIG_TEMPLATES = [ WmiMimikatz, WmiPth, Zerologon, - Drupal + Drupal, ] @@ -63,9 +70,9 @@ def save_template_as_config(template: Type[ConfigTemplate]): def save_to_file(file_path, contents): - with open(file_path, 'w') as file: + with open(file_path, "w") as file: file.write(contents) -if __name__ == '__main__': +if __name__ == "__main__": generate_templates()