Skip to content

Commit 800cdcc

Browse files
author
Brent Cook
committed
Land rapid7#8737, better handle sudden disconnects with SMTP servers
2 parents 6849e51 + 0f31edf commit 800cdcc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/msf/core/exploit/smtp_deliver.rb

100644100755
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def send_message(data)
184184

185185
raw_send_recv("MAIL FROM: <#{mailfrom}>\r\n", nsock)
186186
res = raw_send_recv("RCPT TO: <#{mailto}>\r\n", nsock)
187-
if res[0..2] == '250'
187+
if res && res[0..2] == '250'
188188
resp = raw_send_recv("DATA\r\n", nsock)
189189

190190
# If the user supplied a Date field, use that, else use the current
@@ -242,10 +242,12 @@ def raw_send_recv(cmd, nsock=self.sock)
242242
# to dump it all.
243243
vprint_status("C: #{((cmd.length > 120) ? cmd[0,120] + "..." : cmd).strip}")
244244
end
245-
246-
nsock.put(cmd)
247-
res = nsock.get_once
248-
245+
begin
246+
nsock.put(cmd)
247+
res = nsock.get_once
248+
rescue
249+
return nil
250+
end
249251
# Don't truncate the server output because it might be helpful for
250252
# debugging.
251253
vprint_status("S: #{res.strip}") if res

0 commit comments

Comments
 (0)