From 17db25b00bb4ea358672c34222d7c29a47381a3a Mon Sep 17 00:00:00 2001
From: Mike Salvatore <mike.s.salvatore@gmail.com>
Date: Tue, 3 May 2022 08:22:53 -0400
Subject: [PATCH] Agent: Log MSSQL error when authentication fails

---
 monkey/infection_monkey/exploit/mssqlexec.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/monkey/infection_monkey/exploit/mssqlexec.py b/monkey/infection_monkey/exploit/mssqlexec.py
index f6b44471a..c765c2de5 100644
--- a/monkey/infection_monkey/exploit/mssqlexec.py
+++ b/monkey/infection_monkey/exploit/mssqlexec.py
@@ -242,7 +242,8 @@ class MSSQLExploiter(HostExploiter):
                 self.report_login_attempt(True, user, password)
                 cursor = conn.cursor()
                 return cursor
-            except pymssql.OperationalError:
+            except pymssql.OperationalError as err:
+                logger.info(f"Connection to MSSQL failed: {err}")
                 self.report_login_attempt(False, user, password)
                 # Combo didn't work, hopping to the next one
                 pass