Agent: Remove context manager from _authenticate()

Since the PowerShellExploiter's _authenticate() method returns the
client object, it doesn't make sense for it to be constructed in a
context manager.
This commit is contained in:
Mike Salvatore 2021-08-25 13:29:15 -04:00
parent b871398682
commit e70d1c714b
1 changed files with 8 additions and 6 deletions

View File

@ -74,8 +74,7 @@ class PowerShellExploiter(HostExploiter):
def _authenticate(self, username: Optional[str], password: Optional[str]) -> Client:
(ssl, auth, encryption) = utils.get_powershell_client_params(password)
with Client(
client = Client(
self.host.ip_addr,
username=username,
password=password,
@ -83,9 +82,12 @@ class PowerShellExploiter(HostExploiter):
ssl=ssl,
auth=auth,
encryption=encryption,
) as client:
connection_timeout=3,
)
# attempt to execute dir command to know if authentication was successful
client.execute_cmd("dir")
return client
def _execute_monkey_agent_on_victim(self) -> bool: