From f2bf5328904987f8bb5ed0d07d9bddf0d68670a1 Mon Sep 17 00:00:00 2001 From: TheZenTester <96437320+TheZenTester@users.noreply.github.com> Date: Fri, 21 Apr 2023 10:42:34 -0700 Subject: [PATCH] Fix bug logging multiple IPs to email body Updating `external_test` function to only send 1 IP address in the message body. Currently, as written, if there is a targets list of multiple IP addresses, and a successful e-mail is sent, it will append all IP addresses/server names attempted in the for loop to that point. --- SMTPTester.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SMTPTester.py b/SMTPTester.py index d7c0f63..b4c4b9f 100644 --- a/SMTPTester.py +++ b/SMTPTester.py @@ -94,7 +94,7 @@ def external_test(smtp_targets, port, fromaddr, recipient, data, subject, debug) for target in smtp_targets: LOGGER.info("[*] Checking host " + target + ':' + str(port)) LOGGER.info("[*] Testing for mail relaying (external)") - data += "\nVulnerable server is: %s" % target + tgt_server = "\n\n\nVulnerable server is: %s" % target try: if fromaddr and recipient: # checking we have both to and from addresses with SMTP(target, port) as current_target: @@ -110,7 +110,7 @@ def external_test(smtp_targets, port, fromaddr, recipient, data, subject, debug) # message["Bcc"] = receiver_email # Recommended for mass emails # Add body to email - message.attach(MIMEText(data, "plain")) + message.attach(MIMEText(data + tgt_server, "plain")) # # Open PDF file in binary mode # with open(attachment, "rb") as attached: