forked from p15670423/monkey
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:
parent
b871398682
commit
e70d1c714b
|
@ -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,10 +82,13 @@ class PowerShellExploiter(HostExploiter):
|
|||
ssl=ssl,
|
||||
auth=auth,
|
||||
encryption=encryption,
|
||||
) as client:
|
||||
# attempt to execute dir command to know if authentication was successful
|
||||
client.execute_cmd("dir")
|
||||
return 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:
|
||||
arch = self._get_host_arch()
|
||||
|
|
Loading…
Reference in New Issue