@@ -37,8 +37,16 @@ def initialize(info = {})
37
37
38
38
register_advanced_options (
39
39
[
40
- OptInt . new ( 'UDP_SECRET' , [ true , 'The 32-bit cookie for UDP probe requests.' , 1297303091 ] ) ,
41
- OptAddress . new ( 'GATEWAY' , [ false , 'The gateway IP address. This will be used rather than a random remote address for the UDP probe, if set.' ] ) ,
40
+ OptInt . new ( 'SECRET' , [ true , 'A 32-bit cookie for probe requests.' , 'MSF!' . unpack ( 'N' ) ] ) ,
41
+ OptAddress . new ( 'GATEWAY_PROBE_HOST' ,
42
+ [
43
+ true ,
44
+ 'Send a TTL=1 random UDP datagram to this host to discover the default gateway\'s MAC' ,
45
+ 'www.metasploit.com' ] )
46
+ OptPort . new ( 'GATEWAY_PROBE_PORT' ,
47
+ [
48
+ false ,
49
+ 'The port on GATEWAY_PROBE_HOST to send a random UDP probe to (random if 0 or unset)' ] )
42
50
] , Msf ::Exploit ::Capture
43
51
)
44
52
@@ -116,7 +124,7 @@ def open_pcap(opts={})
116
124
self . capture = ::Pcap . open_live ( dev , len , true , tim )
117
125
if do_arp
118
126
self . arp_capture = ::Pcap . open_live ( dev , 512 , true , tim )
119
- preamble = datastore [ 'UDP_SECRET ' ] . to_i
127
+ preamble = datastore [ 'SECRET ' ] . to_i
120
128
arp_filter = "arp[6:2] = 2 or (udp[8:4] = #{ preamble } )"
121
129
self . arp_capture . setfilter ( arp_filter )
122
130
end
@@ -303,19 +311,18 @@ def lookup_eth(addr=nil, iface=nil)
303
311
end
304
312
305
313
def probe_gateway ( addr )
306
- dst_host = ( datastore [ 'GATEWAY' ] || IPAddr . new ( ( rand ( 16777216 ) + 2969567232 ) , Socket :: AF_INET ) . to_s )
307
- dst_port = rand ( 30000 ) + 1024
308
- preamble = [ datastore [ 'UDP_SECRET ' ] ] . pack ( "N" )
314
+ dst_host = datastore [ 'GATEWAY_PROBE_HOST' ]
315
+ dst_port = datastore [ 'GATEWAY_PROBE_PORT' ] == 0 ? rand ( 30000 ) + 1024 : datastore [ 'GATEWAY_PROBE_PORT' ]
316
+ preamble = [ datastore [ 'SECRET ' ] ] . pack ( "N" )
309
317
secret = "#{ preamble } #{ Rex ::Text . rand_text ( rand ( 0xff ) +1 ) } "
310
318
311
319
begin
312
320
UDPSocket . open do |sock |
313
321
sock . setsockopt ( ::Socket ::IPPROTO_IP , ::Socket ::IP_TTL , 1 )
314
322
sock . send ( secret , 0 , dst_host , dst_port )
315
323
end
316
- #UDPSocket.open.send(secret, 0, dst_host, dst_port)
317
324
rescue Errno ::ENETUNREACH
318
- # This happens on networks with no gatway . We'll need to use a
325
+ # This happens on networks with no gateway . We'll need to use a
319
326
# fake source hardware address.
320
327
self . arp_cache [ Rex ::Socket . source_address ( addr ) ] = "00:00:00:00:00:00"
321
328
end
0 commit comments