diff --git a/monkey/infection_monkey/exploit/powershell.py b/monkey/infection_monkey/exploit/powershell.py index 134ae907c..6f0a27ac4 100644 --- a/monkey/infection_monkey/exploit/powershell.py +++ b/monkey/infection_monkey/exploit/powershell.py @@ -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()