@@ -64,17 +64,17 @@ def initialize(info = {})
64
64
end
65
65
66
66
def stats_recv ( pcap = self . capture )
67
- return ( 0 ) if not pcap
67
+ return ( 0 ) unless pcap
68
68
pcap . stats [ 'recv' ]
69
69
end
70
70
71
71
def stats_drop ( pcap = self . capture )
72
- return ( 0 ) if not pcap
72
+ return ( 0 ) unless pcap
73
73
pcap . stats [ 'drop' ]
74
74
end
75
75
76
76
def stats_ifdrop ( pcap = self . capture )
77
- return ( 0 ) if not pcap
77
+ return ( 0 ) unless pcap
78
78
pcap . stats [ 'ifdrop' ]
79
79
end
80
80
@@ -133,7 +133,7 @@ def open_pcap(opts={})
133
133
end
134
134
135
135
def close_pcap
136
- return if not self . capture
136
+ return unless self . capture
137
137
self . capture = nil
138
138
self . arp_capture = nil
139
139
GC . start ( )
@@ -147,7 +147,7 @@ def capture_extract_ies(raw)
147
147
148
148
while ( idx < raw . length )
149
149
len = raw [ idx +1 ]
150
- return set if not len
150
+ return set unless len
151
151
set [ raw [ idx ] ] ||= [ ]
152
152
set [ raw [ idx ] ] . push ( raw [ idx + 2 , len ] )
153
153
idx += len + 2
@@ -161,7 +161,7 @@ def capture_extract_ies(raw)
161
161
# signal handling of Ruby 1.9
162
162
#
163
163
def each_packet
164
- return if not capture
164
+ return unless capture
165
165
begin
166
166
@capture_count = 0
167
167
reader = framework . threads . spawn ( "PcapReceiver" , false ) do
@@ -218,7 +218,7 @@ def inject_eth(args={})
218
218
219
219
def inject_pcap ( pcap_file , filter = nil , delay = 0 , pcap = self . capture )
220
220
check_pcaprub_loaded
221
- if not pcap
221
+ unless pcap
222
222
raise RuntimeError , "Could not access the capture process (remember to open_pcap first!)"
223
223
end
224
224
@@ -234,7 +234,7 @@ def inject_pcap(pcap_file, filter=nil, delay = 0, pcap=self.capture)
234
234
capture_file . setfilter ( filter ) if filter
235
235
while ( pkt = capture_file . next ) do
236
236
pcap . inject ( pkt )
237
- Kernel . select ( nil , nil , nil , ( delay * 1.0 ) /1000 )
237
+ Rex . sleep ( ( delay * 1.0 ) /1000 )
238
238
end
239
239
GC . start
240
240
end
@@ -283,7 +283,7 @@ def inject_reply(proto=:udp, pcap=self.capture)
283
283
# UDP packet using the regular socket to learn the source host's
284
284
# and gateway's mac addresses.
285
285
def lookup_eth ( addr = nil , iface = nil )
286
- raise RuntimeError , "Could not access the capture process." if not self . arp_capture
286
+ raise RuntimeError , "Could not access the capture process." unless self . arp_capture
287
287
288
288
self . arp_cache ||= { }
289
289
self . dst_cache ||= { }
@@ -336,7 +336,7 @@ def arp(target_ip=nil)
336
336
return self . arp_cache [ target_ip ] if self . arp_cache [ target_ip ]
337
337
return self . arp_cache [ :gateway ] unless should_arp? target_ip
338
338
source_ip = Rex ::Socket . source_address ( target_ip )
339
- raise RuntimeError , "Could not access the capture process." if not self . arp_capture
339
+ raise RuntimeError , "Could not access the capture process." unless self . arp_capture
340
340
p = arp_packet ( target_ip , source_ip )
341
341
inject_eth ( :eth_type => 0x0806 ,
342
342
:payload => p ,
@@ -515,7 +515,7 @@ def get_ipv4_broadcast(dev, num=0)
515
515
def get_ipv6_addr_count ( dev )
516
516
check_pcaprub_loaded
517
517
dev = get_interface_guid ( dev )
518
- raise RuntimeError , "IPv6 information is not available on this platform" if not ::NetworkInterface . const_defined? ( :AF_INET6 )
518
+ raise RuntimeError , "IPv6 information is not available on this platform" unless ::NetworkInterface . const_defined? ( :AF_INET6 )
519
519
addrs = NetworkInterface . addresses ( dev )
520
520
raise RuntimeError , "Interface #{ dev } do not exists" if !addrs
521
521
addrs [ NetworkInterface ::AF_INET6 ] . length
@@ -525,7 +525,7 @@ def get_ipv6_addr_count(dev)
525
525
def get_ipv6_addr ( dev , num = 0 )
526
526
check_pcaprub_loaded
527
527
dev = get_interface_guid ( dev )
528
- raise RuntimeError , "IPv6 information is not available on this platform" if not ::NetworkInterface . const_defined? ( :AF_INET6 )
528
+ raise RuntimeError , "IPv6 information is not available on this platform" unless ::NetworkInterface . const_defined? ( :AF_INET6 )
529
529
addrs = NetworkInterface . addresses ( dev )
530
530
raise RuntimeError , "Interface #{ dev } do not exists" if !addrs
531
531
raise RuntimeError , "Interface #{ dev } do not have an ipv6 address at position #{ num } " if addrs [ NetworkInterface ::AF_INET6 ] . length < num + 1
@@ -536,7 +536,7 @@ def get_ipv6_addr(dev, num=0)
536
536
def get_ipv6_netmask ( dev , num = 0 )
537
537
check_pcaprub_loaded
538
538
dev = get_interface_guid ( dev )
539
- raise RuntimeError , "IPv6 information is not available on this platform" if not ::NetworkInterface . const_defined? ( :AF_INET6 )
539
+ raise RuntimeError , "IPv6 information is not available on this platform" unless ::NetworkInterface . const_defined? ( :AF_INET6 )
540
540
addrs = NetworkInterface . addresses ( dev )
541
541
raise RuntimeError , "Interface #{ dev } do not exists" if !addrs
542
542
raise RuntimeError , "Interface #{ dev } do not have an ipv6 address at position #{ num } " if addrs [ NetworkInterface ::AF_INET6 ] . length < num + 1
0 commit comments