Agent: Add missing type hints to MSSQLExploiter

This commit is contained in:
Mike Salvatore 2022-06-14 14:40:48 -04:00
parent 7aca587964
commit e73c9307bf
1 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import logging
from pathlib import PureWindowsPath
from time import sleep
from typing import Sequence, Tuple
import pymssql
@ -84,7 +85,9 @@ class MSSQLExploiter(HostExploiter):
self.exploit_result.propagation_success = True
return self.exploit_result
def _brute_force(self, host, port, users_passwords_pairs_list):
def _brute_force(
self, host: str, port: str, users_passwords_pairs_list: Sequence[Tuple[str, str]]
) -> pymssql.Cursor:
"""
Starts the brute force connection attempts and if needed then init the payload process.
Main loop starts here.
@ -181,11 +184,11 @@ class MSSQLExploiter(HostExploiter):
self._write_agent_launch_command_to_batch_file(agent_path_on_victim)
self.run_payload_file()
def _write_agent_launch_command_to_batch_file(self, agent_path_on_victim):
def _write_agent_launch_command_to_batch_file(self, agent_path_on_victim: PureWindowsPath):
agent_launch_command = self._build_agent_launch_command(agent_path_on_victim)
self._write_command_to_batch_file(agent_launch_command)
def _build_agent_launch_command(self, agent_path_on_victim: PureWindowsPath):
def _build_agent_launch_command(self, agent_path_on_victim: PureWindowsPath) -> str:
agent_args = build_monkey_commandline(
self.host, self.current_depth - 1, agent_path_on_victim
)
@ -203,6 +206,6 @@ class MSSQLExploiter(HostExploiter):
return http_thread
@staticmethod
def _stop_agent_server(http_thread):
def _stop_agent_server(http_thread: LockedHTTPServer):
http_thread.stop()
http_thread.join(LONG_REQUEST_TIMEOUT)