From 544ea6926ce6903b221b3e5482ad285defe6f0f5 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sun, 14 May 2017 11:22:46 -0500 Subject: [PATCH] trim leading and trailing whitespace in mail addresses --- lib/msf/core/exploit/smtp_deliver.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/msf/core/exploit/smtp_deliver.rb b/lib/msf/core/exploit/smtp_deliver.rb index c1eef3c137..021d80f525 100644 --- a/lib/msf/core/exploit/smtp_deliver.rb +++ b/lib/msf/core/exploit/smtp_deliver.rb @@ -166,8 +166,11 @@ module Exploit::Remote::SMTPDeliver nsock = connect_login(false) end - raw_send_recv("MAIL FROM: <#{datastore['MAILFROM']}>\r\n", nsock) - res = raw_send_recv("RCPT TO: <#{datastore['MAILTO']}>\r\n", nsock) + mailto = datastore['MAILTO'].strip + mailfrom = datastore['MAILFROM'].strip + + raw_send_recv("MAIL FROM: <#{mailfrom}>\r\n", nsock) + res = raw_send_recv("RCPT TO: <#{mailto}>\r\n", nsock) if res[0..2] == '250' resp = raw_send_recv("DATA\r\n", nsock) @@ -199,7 +202,7 @@ module Exploit::Remote::SMTPDeliver send_status = raw_send_recv("#{full_msg}\r\n.\r\n", nsock) end else - print_error "Server refused to send to <#{datastore['MAILTO']}>" + print_error "Server refused to send to <#{mailto}>" end if not already_connected