2021-03-08 23:13:35 +08:00
|
|
|
import argparse
|
|
|
|
import pathlib
|
|
|
|
from typing import Type
|
|
|
|
|
|
|
|
from envs.monkey_zoo.blackbox.config_templates.config_template import ConfigTemplate
|
2021-03-08 23:27:57 +08:00
|
|
|
from envs.monkey_zoo.blackbox.config_templates.drupal import Drupal
|
2021-03-08 23:13:35 +08:00
|
|
|
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
|
2021-08-24 16:29:36 +08:00
|
|
|
from envs.monkey_zoo.blackbox.config_templates.powershell import PowerShell
|
2021-03-08 23:13:35 +08:00
|
|
|
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
|
2021-04-07 05:55:44 +08:00
|
|
|
from envs.monkey_zoo.blackbox.island_client.island_config_parser import IslandConfigParser
|
|
|
|
from envs.monkey_zoo.blackbox.island_client.monkey_island_client import MonkeyIslandClient
|
2021-03-08 23:13:35 +08:00
|
|
|
|
2021-03-09 16:23:35 +08:00
|
|
|
DST_DIR_NAME = "generated_configs"
|
2021-03-08 23:13:35 +08:00
|
|
|
DST_DIR_PATH = pathlib.Path(pathlib.Path(__file__).parent.absolute(), DST_DIR_NAME)
|
|
|
|
|
2021-03-09 16:23:35 +08:00
|
|
|
parser = argparse.ArgumentParser(description="Generate config files.")
|
|
|
|
parser.add_argument(
|
|
|
|
"island_ip",
|
|
|
|
metavar="IP:PORT",
|
|
|
|
help="Island endpoint. Example: 123.123.123.123:5000",
|
|
|
|
)
|
2021-03-08 23:13:35 +08:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
island_client = MonkeyIslandClient(args.island_ip)
|
|
|
|
|
|
|
|
|
|
|
|
CONFIG_TEMPLATES = [
|
|
|
|
Elastic,
|
|
|
|
Hadoop,
|
|
|
|
Mssql,
|
|
|
|
Performance,
|
2021-08-24 16:29:36 +08:00
|
|
|
PowerShell,
|
2021-03-08 23:13:35 +08:00
|
|
|
ShellShock,
|
|
|
|
SmbMimikatz,
|
|
|
|
SmbPth,
|
|
|
|
Ssh,
|
|
|
|
Struts2,
|
|
|
|
Tunneling,
|
|
|
|
Weblogic,
|
|
|
|
WmiMimikatz,
|
|
|
|
WmiPth,
|
2021-03-08 23:27:57 +08:00
|
|
|
Zerologon,
|
2021-03-09 16:23:35 +08:00
|
|
|
Drupal,
|
2021-03-08 23:13:35 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
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):
|
2021-03-09 16:23:35 +08:00
|
|
|
with open(file_path, "w") as file:
|
2021-03-08 23:13:35 +08:00
|
|
|
file.write(contents)
|
|
|
|
|
|
|
|
|
2021-03-09 16:23:35 +08:00
|
|
|
if __name__ == "__main__":
|
2021-03-08 23:13:35 +08:00
|
|
|
generate_templates()
|