Skip to content

Commit 036f063

Browse files
committed
Fix a stack trace when no SMB response is received
1 parent 18f5203 commit 036f063

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

modules/exploits/windows/smb/ms17_010_eternalblue.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ def smb_eternalblue(process_name, grooms)
187187
print_status("Receiving response from exploit packet")
188188
code, raw = smb1_get_response(sock)
189189

190+
if code.nil?
191+
print_error("Did not receive a response from exploit packet")
192+
end
193+
190194
if code == 0xc000000d #STATUS_INVALID_PARAMETER (0xC000000D)
191195
print_good("ETERNALBLUE overwrite completed successfully (0xC000000D)!")
192196
end
@@ -226,6 +230,10 @@ def smb1_anonymous_connect_ipc()
226230

227231
code, raw, response = smb1_get_response(sock)
228232

233+
if code.nil?
234+
raise RubySMB::Error::UnexpectedStatusCode, "No response to login request"
235+
end
236+
229237
unless code == 0 # WindowsError::NTStatus::STATUS_SUCCESS
230238
raise RubySMB::Error::UnexpectedStatusCode, "Error with anonymous login"
231239
end
@@ -290,6 +298,7 @@ def smb1_free_hole(start)
290298

291299
def smb1_get_response(sock)
292300
raw = sock.get_once
301+
return nil unless raw
293302
response = RubySMB::SMB1::SMBHeader.read(raw[4..-1])
294303
code = response.nt_status
295304
return code, raw, response

0 commit comments

Comments
 (0)