Agent, UI: Remove internal-logging from config
The config is called after the log path is set, so the logging config had no affect on the log path.
This commit is contained in:
parent
71328ea2b1
commit
3c745f697f
|
@ -67,15 +67,6 @@ class Configuration(object):
|
|||
|
||||
return result
|
||||
|
||||
###########################
|
||||
# logging config
|
||||
###########################
|
||||
|
||||
dropper_log_directory_linux = "/tmp/"
|
||||
dropper_log_directory_windows = "%temp%\\"
|
||||
monkey_log_directory_linux = "/tmp/"
|
||||
monkey_log_directory_windows = "%temp%\\"
|
||||
|
||||
###########################
|
||||
# dropper config
|
||||
###########################
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
"dropper_date_reference_path_windows": "%windir%\\system32\\kernel32.dll",
|
||||
"dropper_date_reference_path_linux": "/bin/sh",
|
||||
"dropper_log_directory_linux": "/tmp/",
|
||||
"dropper_log_directory_windows": "%temp%\\",
|
||||
"dropper_set_date": true,
|
||||
"dropper_target_path_win_64": "C:\\Windows\\temp\\monkey64.exe",
|
||||
"dropper_target_path_linux": "/tmp/monkey",
|
||||
|
@ -38,8 +36,6 @@
|
|||
"MSSQLFingerprint",
|
||||
"ElasticFinger"
|
||||
],
|
||||
"monkey_log_directory_windows": "%temp%\\",
|
||||
"monkey_log_directory_linux": "/tmp/",
|
||||
"ping_scan_timeout": 10000,
|
||||
"smb_download_timeout": 300,
|
||||
"smb_service_name": "InfectionMonkey",
|
||||
|
|
|
@ -16,7 +16,7 @@ from infection_monkey.config import EXTERNAL_CONFIG_FILE, WormConfiguration
|
|||
from infection_monkey.dropper import MonkeyDrops
|
||||
from infection_monkey.model import DROPPER_ARG, MONKEY_ARG
|
||||
from infection_monkey.monkey import InfectionMonkey
|
||||
from infection_monkey.utils.monkey_log_path import get_dropper_log_path, get_monkey_log_path
|
||||
from infection_monkey.utils.monkey_log_path import get_log_path
|
||||
|
||||
logger = None
|
||||
|
||||
|
@ -80,10 +80,10 @@ def main():
|
|||
|
||||
try:
|
||||
if MONKEY_ARG == monkey_mode:
|
||||
log_path = get_monkey_log_path()
|
||||
log_path = get_log_path("agent")
|
||||
monkey_cls = InfectionMonkey
|
||||
elif DROPPER_ARG == monkey_mode:
|
||||
log_path = get_dropper_log_path()
|
||||
log_path = get_log_path("dropper")
|
||||
monkey_cls = MonkeyDrops
|
||||
else:
|
||||
return True
|
||||
|
|
|
@ -52,7 +52,7 @@ from infection_monkey.utils.monkey_dir import (
|
|||
get_monkey_dir_path,
|
||||
remove_monkey_dir,
|
||||
)
|
||||
from infection_monkey.utils.monkey_log_path import get_monkey_log_path
|
||||
from infection_monkey.utils.monkey_log_path import get_log_path
|
||||
from infection_monkey.utils.signal_handler import register_signal_handlers, reset_signal_handlers
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -288,7 +288,7 @@ class InfectionMonkey:
|
|||
|
||||
@staticmethod
|
||||
def _send_log():
|
||||
monkey_log_path = get_monkey_log_path()
|
||||
monkey_log_path = get_log_path("agent")
|
||||
if os.path.exists(monkey_log_path):
|
||||
with open(monkey_log_path, "r") as f:
|
||||
log = f.read()
|
||||
|
|
|
@ -1,41 +1,23 @@
|
|||
import os
|
||||
import string
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from random import SystemRandom
|
||||
|
||||
from infection_monkey.config import WormConfiguration
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
def get_monkey_log_path():
|
||||
@lru_cache(maxsize=None)
|
||||
def get_log_path(monkey_arg: str):
|
||||
return (
|
||||
os.path.expandvars(
|
||||
_generate_random_log_filepath(WormConfiguration.monkey_log_directory_windows, "agent")
|
||||
)
|
||||
os.path.expandvars(_generate_random_log_filepath(monkey_arg))
|
||||
if sys.platform == "win32"
|
||||
else _generate_random_log_filepath(WormConfiguration.monkey_log_directory_linux, "agent")
|
||||
else _generate_random_log_filepath(monkey_arg)
|
||||
)
|
||||
|
||||
|
||||
def get_dropper_log_path():
|
||||
return (
|
||||
os.path.expandvars(
|
||||
_generate_random_log_filepath(
|
||||
WormConfiguration.dropper_log_directory_windows, "dropper"
|
||||
)
|
||||
)
|
||||
if sys.platform == "win32"
|
||||
else _generate_random_log_filepath(WormConfiguration.dropper_log_directory_linux, "dropper")
|
||||
)
|
||||
|
||||
|
||||
def _generate_random_log_filepath(log_directory: str, monkey_arg: str) -> str:
|
||||
safe_random = SystemRandom()
|
||||
random_string = "".join(
|
||||
[safe_random.choice(string.ascii_lowercase + string.digits) for _ in range(8)]
|
||||
)
|
||||
def _generate_random_log_filepath(monkey_arg: str) -> str:
|
||||
prefix = f"infection-monkey-{monkey_arg}-"
|
||||
suffix = f"-{time.strftime('%Y-%m-%d-%H-%M-%S', time.gmtime())}.log"
|
||||
log_file_path = os.path.join(log_directory, prefix + random_string + suffix)
|
||||
|
||||
return log_file_path
|
||||
_, monkey_log_path = tempfile.mkstemp(suffix=suffix, prefix=prefix)
|
||||
|
||||
return monkey_log_path
|
||||
|
|
|
@ -184,36 +184,6 @@ INTERNAL = {
|
|||
},
|
||||
},
|
||||
},
|
||||
"logging": {
|
||||
"title": "Logging",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"dropper_log_directory_linux": {
|
||||
"title": "Dropper log directory path on Linux",
|
||||
"type": "string",
|
||||
"default": "/tmp/",
|
||||
"description": "The directory path of the dropper log file on Linux",
|
||||
},
|
||||
"dropper_log_directory_windows": {
|
||||
"title": "Dropper log directory path on Windows",
|
||||
"type": "string",
|
||||
"default": "%temp%\\",
|
||||
"description": "The directory path of the dropper log file on Windows",
|
||||
},
|
||||
"monkey_log_directory_linux": {
|
||||
"title": "Monkey log directory path on Linux",
|
||||
"type": "string",
|
||||
"default": "/tmp/",
|
||||
"description": "The directory path of the monkey log file on Linux",
|
||||
},
|
||||
"monkey_log_directory_windows": {
|
||||
"title": "Monkey log directory path on Windows",
|
||||
"type": "string",
|
||||
"default": "%temp%\\",
|
||||
"description": "The directory path of the monkey log file on Windows",
|
||||
},
|
||||
},
|
||||
},
|
||||
"exploits": {
|
||||
"title": "Exploits",
|
||||
"type": "object",
|
||||
|
|
|
@ -5,7 +5,6 @@ import {Nav} from 'react-bootstrap';
|
|||
const sectionOrder = [
|
||||
'network',
|
||||
'island_server',
|
||||
'logging',
|
||||
'exploits',
|
||||
'dropper',
|
||||
'classes',
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
"depth": 2,
|
||||
"dropper_date_reference_path_linux": "/bin/sh",
|
||||
"dropper_date_reference_path_windows": "%windir%\\system32\\kernel32.dll",
|
||||
"dropper_log_directory_linux": "/tmp/",
|
||||
"dropper_log_directory_windows": "%temp%\\",
|
||||
"dropper_set_date": true,
|
||||
"dropper_target_path_linux": "/tmp/monkey",
|
||||
"dropper_target_path_win_64": "C:\\Windows\\temp\\monkey64.exe",
|
||||
|
@ -71,8 +69,6 @@
|
|||
"keep_tunnel_open_time": 60,
|
||||
"local_network_scan": true,
|
||||
"max_depth": null,
|
||||
"monkey_log_directory_linux": "/tmp/",
|
||||
"monkey_log_directory_windows": "%temp%\\",
|
||||
"ping_scan_timeout": 1000,
|
||||
"post_breach_actions": [
|
||||
"CommunicateAsBackdoorUser",
|
||||
|
|
|
@ -106,12 +106,6 @@
|
|||
"dropper_target_path_linux": "/tmp/monkey",
|
||||
"dropper_target_path_win_64": "C:\\Windows\\temp\\monkey64.exe"
|
||||
},
|
||||
"logging": {
|
||||
"dropper_log_directory_linux": "/tmp/",
|
||||
"dropper_log_directory_windows": "%temp%\\",
|
||||
"monkey_log_directory_linux": "/tmp/",
|
||||
"monkey_log_directory_windows": "%temp%\\"
|
||||
},
|
||||
"exploits": {
|
||||
"exploit_lm_hash_list": [],
|
||||
"exploit_ntlm_hash_list": [],
|
||||
|
|
Loading…
Reference in New Issue