Agent: Set client parameters if password is "" in PowerShellExploiter

This commit is contained in:
Mike Salvatore 2021-08-24 11:53:48 -04:00
parent fb18c1cbd4
commit 8209fa55df
1 changed files with 7 additions and 0 deletions

View File

@ -89,11 +89,18 @@ class PowerShellExploiter(HostExploiter):
return [credentials for credentials in self._config.get_exploit_user_password_pairs()] return [credentials for credentials in self._config.get_exploit_user_password_pairs()]
def _authenticate(self, username: Optional[str], password: Optional[str]) -> Client: def _authenticate(self, username: Optional[str], password: Optional[str]) -> Client:
ssl = password != ""
auth = "negotiate" if password != "" else "basic"
encryption = "auto" if password != "" else "never"
with Client( with Client(
self.host.ip_addr, self.host.ip_addr,
username=username, username=username,
password=password, password=password,
cert_validation=False, cert_validation=False,
ssl=ssl,
auth=auth,
encryption=encryption,
) as client: ) as client:
# attempt to execute dir command to know if authentication was successful # attempt to execute dir command to know if authentication was successful
client.execute_cmd("dir") client.execute_cmd("dir")