From a2bdc693880ad2a408746c9d07adec7fecea8947 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 24 Aug 2021 12:03:42 -0400 Subject: [PATCH] Agent: Log and report exploitation attempts from PowerShellExploiter --- monkey/infection_monkey/exploit/powershell.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/exploit/powershell.py b/monkey/infection_monkey/exploit/powershell.py index 36d10f709..6fbae703e 100644 --- a/monkey/infection_monkey/exploit/powershell.py +++ b/monkey/infection_monkey/exploit/powershell.py @@ -53,9 +53,20 @@ class PowerShellExploiter(HostExploiter): for username, password in credentials: try: client = self._authenticate(username, password) + + LOG.info( + "Successfully logged into {self.host.ip_addr} using Powershell. User: " + "{username}" + ) + self.report_login_attempt(True, username, password) + return client - except Exception: - pass + except Exception as ex: # noqa: F841 + LOG.debug( + "Error logging into {self.host.ip_addr} using Powershell. User: " + "{username}, Error: {ex}" + ) + self.report_login_attempt(False, username, password) return None