Small refactor, values to island's config added.

This commit is contained in:
VakarisZ 2019-03-20 14:02:53 +02:00
parent eb1cb91704
commit d61c080848
3 changed files with 22 additions and 10 deletions

View File

@ -219,7 +219,6 @@ class InfectionMonkey(object):
self._singleton.unlock()
InfectionMonkey.self_delete()
utils.remove_monkey_dir()
LOG.info("Monkey is shutting down")
@staticmethod
@ -234,6 +233,7 @@ class InfectionMonkey(object):
if WormConfiguration.self_delete_in_cleanup \
and -1 == sys.executable.find('python'):
try:
utils.remove_monkey_dir()
if "win32" == sys.platform:
from _subprocess import SW_HIDE, STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE
startupinfo = subprocess.STARTUPINFO()

View File

@ -42,19 +42,19 @@ def create_monkey_dir():
"""
Creates directory for monkey and related files
"""
if is_windows_os():
if not os.path.exists(WormConfiguration.monkey_dir_windows):
os.mkdir(WormConfiguration.monkey_dir_windows)
else:
if not os.path.exists(WormConfiguration.monkey_log_path_linux):
os.mkdir(WormConfiguration.monkey_dir_linux)
if not os.path.exists(get_monkey_dir_path()):
os.mkdir(get_monkey_dir_path())
def remove_monkey_dir():
"""
Removes monkey's root directory
"""
shutil.rmtree(get_monkey_dir_path(), ignore_errors=True)
def get_monkey_dir_path():
if is_windows_os():
shutil.rmtree(WormConfiguration.monkey_dir_windows, ignore_errors=True)
return WormConfiguration.monkey_dir_windows
else:
shutil.rmtree(WormConfiguration.monkey_dir_linux, ignore_errors=True)
return WormConfiguration.monkey_dir_linux

View File

@ -423,7 +423,19 @@ SCHEMA = {
"type": "integer",
"default": 60,
"description": "Time to keep tunnel open before going down after last exploit (in seconds)"
}
},
"monkey_dir_windows": {
"title": "Monkey's windows directory",
"type": "string",
"default": r"C:\Windows\temp\monkey_dir",
"description": "Directory containing all monkey files on windows"
},
"monkey_dir_linux": {
"title": "Monkey's linux directory",
"type": "string",
"default": "/tmp/monkey_dir",
"description": "Directory containing all monkey files on linux"
},
}
},
"classes": {