@@ -39,7 +39,6 @@ def initialize(info = {})
39
39
[
40
40
OptInt . new ( 'UDP_SECRET' , [ true , 'The 32-bit cookie for UDP probe requests.' , 1297303091 ] ) ,
41
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.' ] ) ,
42
- OptInt . new ( 'NETMASK' , [ false , 'The local network mask. This is used to decide if an address is in the local network.' , 24 ] ) ,
43
42
] , Msf ::Exploit ::Capture
44
43
)
45
44
@@ -402,9 +401,11 @@ def check_pcaprub_loaded
402
401
def lookupnet
403
402
check_pcaprub_loaded
404
403
dev = datastore [ 'INTERFACE' ] || ::Pcap . lookupdev
405
- mask = datastore [ 'NETMASK' ] || 24
406
404
begin
407
- my_net = IPAddr . new ( "#{ Pcap . lookupnet ( dev ) . first } /#{ mask } " )
405
+ my_ip , my_mask = Pcap . lookupnet ( dev )
406
+ # convert the netmask obtained from the relevant interface to CIDR
407
+ cidr_mask = my_mask . to_s ( 2 ) . count ( '1' )
408
+ my_net = IPAddr . new ( "#{ my_ip } /#{ cidr_mask } " )
408
409
rescue RuntimeError => e
409
410
@pcaprub_error = e
410
411
print_status ( "Cannot stat device: #{ @pcaprub_error } " )
@@ -414,10 +415,7 @@ def lookupnet
414
415
end
415
416
416
417
def should_arp? ( ip )
417
- @mydev ||= datastore [ 'INTERFACE' ] || ::Pcap . lookupdev
418
- @mymask ||= datastore [ 'NETMASK' ] || 24
419
- @mynet ||= lookupnet
420
- @mynet . include? ( IPAddr . new ( ip ) )
418
+ lookupnet . include? ( IPAddr . new ( ip ) )
421
419
end
422
420
423
421
attr_accessor :capture , :arp_cache , :arp_capture , :dst_cache
0 commit comments