agent: Add separate function to set log levels for sensitive packages in powershell exploiter

This commit is contained in:
Shreya Malviya 2021-08-20 23:44:12 +05:30
parent dc4a5fbb85
commit 04125e5e14
1 changed files with 8 additions and 4 deletions

View File

@ -31,14 +31,18 @@ class PowershellExploiter(HostExploiter):
_EXPLOITED_SERVICE = "PowerShell Remoting (WinRM)" _EXPLOITED_SERVICE = "PowerShell Remoting (WinRM)"
def __init__(self, host: VictimHost): def __init__(self, host: VictimHost):
# If pypsrp will inherit root logger, it will log extensive and potentially sensitive info PowershellExploiter._set_sensitive_packages_log_level_to_error()
logging.getLogger("pypsrp").setLevel(logging.ERROR)
logging.getLogger(spnego.__name__).setLevel(logging.ERROR)
logging.getLogger(connectionpool.__name__).setLevel(logging.ERROR)
super().__init__(host) super().__init__(host)
self.client = None self.client = None
@staticmethod
def _set_sensitive_packages_log_level_to_error():
# If root logger is inherited, extensive and potentially sensitive info could be logged
sensitive_packages = [pypsrp, spnego, connectionpool]
for package in sensitive_packages:
logging.getLogger(package.__name__).setLevel(logging.ERROR)
def _exploit_host(self): def _exploit_host(self):
try: try:
self.client = self.exploit_without_credentials() self.client = self.exploit_without_credentials()