forked from p34709852/monkey
New directory for monkey and it's files
This commit is contained in:
parent
3cd85ff85a
commit
0268fa833f
|
@ -107,6 +107,9 @@ class Configuration(object):
|
||||||
dropper_target_path_win_32 = r"C:\Windows\monkey32.exe"
|
dropper_target_path_win_32 = r"C:\Windows\monkey32.exe"
|
||||||
dropper_target_path_win_64 = r"C:\Windows\monkey64.exe"
|
dropper_target_path_win_64 = r"C:\Windows\monkey64.exe"
|
||||||
dropper_target_path_linux = '/tmp/monkey'
|
dropper_target_path_linux = '/tmp/monkey'
|
||||||
|
# Monkey dir paths
|
||||||
|
monkey_dir_linux = '/tmp/monkey_dir'
|
||||||
|
monkey_dir_windows = r'C:\Windows\temp\monkey_dir'
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# Kill file
|
# Kill file
|
||||||
|
|
|
@ -76,6 +76,9 @@ class InfectionMonkey(object):
|
||||||
LOG.info("Monkey couldn't find server. Going down.")
|
LOG.info("Monkey couldn't find server. Going down.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Create a dir for monkey files if there isn't one
|
||||||
|
utils.create_monkey_dir()
|
||||||
|
|
||||||
if WindowsUpgrader.should_upgrade():
|
if WindowsUpgrader.should_upgrade():
|
||||||
self._upgrading_to_64 = True
|
self._upgrading_to_64 = True
|
||||||
self._singleton.unlock()
|
self._singleton.unlock()
|
||||||
|
@ -216,6 +219,7 @@ class InfectionMonkey(object):
|
||||||
self._singleton.unlock()
|
self._singleton.unlock()
|
||||||
|
|
||||||
InfectionMonkey.self_delete()
|
InfectionMonkey.self_delete()
|
||||||
|
utils.remove_monkey_dir()
|
||||||
LOG.info("Monkey is shutting down")
|
LOG.info("Monkey is shutting down")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from infection_monkey.config import WormConfiguration
|
from infection_monkey.config import WormConfiguration
|
||||||
|
@ -35,3 +36,25 @@ def utf_to_ascii(string):
|
||||||
# Converts utf string to ascii. Safe to use even if string is already ascii.
|
# Converts utf string to ascii. Safe to use even if string is already ascii.
|
||||||
udata = string.decode("utf-8")
|
udata = string.decode("utf-8")
|
||||||
return udata.encode("ascii", "ignore")
|
return udata.encode("ascii", "ignore")
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
def remove_monkey_dir():
|
||||||
|
"""
|
||||||
|
Removes monkey's root directory
|
||||||
|
"""
|
||||||
|
if is_windows_os():
|
||||||
|
shutil.rmtree(WormConfiguration.monkey_dir_windows, ignore_errors=True)
|
||||||
|
else:
|
||||||
|
shutil.rmtree(WormConfiguration.monkey_dir_linux, ignore_errors=True)
|
||||||
|
|
|
@ -423,7 +423,19 @@ SCHEMA = {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": 60,
|
"default": 60,
|
||||||
"description": "Time to keep tunnel open before going down after last exploit (in seconds)"
|
"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": {
|
"classes": {
|
||||||
|
|
Loading…
Reference in New Issue