Skip to content

Commit 9d82e5a

Browse files
committed
Land rapid7#8487, fixups for ETERNALBLUE DCE/RPC code
2 parents 0c79279 + 72ff4fb commit 9d82e5a

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

modules/exploits/windows/smb/ms17_010_eternalblue.rb

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,22 @@ def smb_eternalblue(process_name, grooms)
153153
client, tree, sock, os = smb1_anonymous_connect_ipc()
154154
print_good("Connection established for exploitation.")
155155

156-
if !verify_target(os)
156+
if verify_target(os)
157+
print_good('Target OS selected valid for OS indicated by SMB reply')
158+
else
159+
print_warning('Target OS selected not valid for OS indicated by SMB reply')
160+
print_warning('Disable VerifyTarget option to proceed manually...')
157161
raise EternalBlueError, 'Unable to continue with improper OS Target.'
158162
end
159163

160-
if !verify_arch
164+
# cool buffer print no matter what, will be helpful when people post debug issues
165+
print_core_buffer(os)
166+
167+
if verify_arch
168+
print_good('Target arch selected valid for arch indicated by DCE/RPC reply')
169+
else
170+
print_warning('Target arch selected not valid for arch indicated by DCE/RPC reply')
171+
print_warning('Disable VerifyArch option to proceed manually...')
161172
raise EternalBlueError, 'Unable to continue with improper OS Arch.'
162173
end
163174

@@ -234,18 +245,8 @@ def verify_target(os)
234245
break
235246
end
236247
end
237-
238-
if ret
239-
print_good('Target OS selected valid for OS indicated by SMB reply')
240-
else
241-
print_warning('Target OS selected not valid for OS indicated by SMB reply')
242-
print_warning('Disable VerifyTarget option to proceed manually...')
243-
end
244248
end
245249

246-
# cool buffer print no matter what, will be helpful when people post debug issues
247-
print_core_buffer(os)
248-
249250
return ret
250251
end
251252

@@ -263,10 +264,15 @@ def verify_arch
263264
'71710533-beba-4937-8319-b5dbef9ccc36', '1.0'
264265
).first
265266

266-
sock = connect(false,
267-
'RHOST' => rhost,
268-
'RPORT' => 135
269-
)
267+
begin
268+
sock = connect(false,
269+
'RHOST' => rhost,
270+
'RPORT' => 135
271+
)
272+
rescue Rex::ConnectionError => e
273+
print_error(e.to_s)
274+
return false
275+
end
270276

271277
sock.put(pkt)
272278

@@ -300,13 +306,6 @@ def verify_arch
300306
end
301307
end
302308

303-
if ret
304-
print_good('Target arch selected valid for OS indicated by DCE/RPC reply')
305-
else
306-
print_warning('Target arch selected not valid for OS indicated by DCE/RPC reply')
307-
print_warning('Disable VerifyArch option to proceed manually...')
308-
end
309-
310309
ret
311310
end
312311

0 commit comments

Comments
 (0)