Skip to content

Commit 2ab779a

Browse files
committed
Land rapid7#6010, capture_sendto fixes
2 parents 0bacb3d + fc9a757 commit 2ab779a

File tree

12 files changed

+31
-21
lines changed

12 files changed

+31
-21
lines changed

lib/msf/core/auxiliary/udp_scanner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def scanner_spoof_send(data, ip, port, srcip, num_packets=1)
8686
p.recalc
8787
print_status("Sending #{num_packets} packet(s) to #{ip} from #{srcip}")
8888
1.upto(num_packets) do |x|
89-
capture_sendto(p, ip)
89+
break unless capture_sendto(p, ip)
9090
end
9191
close_pcap
9292
end

modules/auxiliary/bnat/bnat_scan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def run_host(ip)
8989

9090
ackbpf = "tcp [8:4] == 0x#{(p.tcp_seq + 1).to_s(16)}"
9191
pcap.setfilter("tcp and tcp[13] == 18 and not host #{ip} and src port #{p.tcp_dst} and dst port #{p.tcp_src} and #{ackbpf}")
92-
capture_sendto(p, ip)
92+
break unless capture_sendto(p, ip)
9393
reply = probe_reply(pcap, to)
9494
next if reply.nil?
9595

modules/auxiliary/dos/mdns/avahi_portzero.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ def run
4545
p.udp_dport = datastore['RPORT'].to_i
4646
p.payload = Rex::Text.rand_text(rand(0x20)) # UDP needs at least one data byte, may as well send a few.
4747
p.recalc
48-
capture_sendto(p, rhost)
49-
48+
capture_sendto(p, rhost) and print_status("Avahi should be down now")
5049
close_pcap
51-
52-
print_status("Avahi should be down now")
5350
end
5451
end

modules/auxiliary/dos/tcp/synflood.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def run
6060
p.tcp_sport = sport
6161
p.tcp_seq = rand(0x100000000)
6262
p.recalc
63-
capture_sendto(p,rhost)
63+
break unless capture_sendto(p,rhost)
6464
sent += 1
6565
end
6666

modules/auxiliary/scanner/ip/ipidseq.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def run_host(ip)
6969

7070
probe = buildprobe(shost, sport, ip, rport)
7171

72-
capture_sendto(probe, ip)
72+
next unless capture_sendto(probe, ip)
7373

7474
reply = probereply(pcap, to)
7575

modules/auxiliary/scanner/portscan/ack.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,22 @@ def run_batch(hosts)
5555

5656
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0
5757

58+
# we copy the hosts because some may not be reachable and need to be ejected
59+
host_queue = hosts.dup
5860
# Spread the load across the hosts
5961
ports.each do |dport|
60-
hosts.each do |dhost|
62+
host_queue.each do |dhost|
6163
shost, sport = getsource(dhost)
6264

6365
pcap.setfilter(getfilter(shost, sport, dhost, dport))
6466

6567
begin
6668
probe = buildprobe(shost, sport, dhost, dport)
6769

68-
capture_sendto(probe, dhost)
70+
unless capture_sendto(probe, dhost)
71+
host_queue.delete(dhost)
72+
next
73+
end
6974

7075
reply = probereply(pcap, to)
7176

modules/auxiliary/scanner/portscan/syn.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,22 @@ def run_batch(hosts)
5353

5454
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0
5555

56+
# we copy the hosts because some may not be reachable and need to be ejected
57+
host_queue = hosts.dup
5658
# Spread the load across the hosts
5759
ports.each do |dport|
58-
hosts.each do |dhost|
60+
host_queue.each do |dhost|
5961
shost, sport = getsource(dhost)
6062

6163
self.capture.setfilter(getfilter(shost, sport, dhost, dport))
6264

6365
begin
6466
probe = buildprobe(shost, sport, dhost, dport)
6567

66-
capture_sendto(probe, dhost)
68+
unless capture_sendto(probe, dhost)
69+
host_queue.delete(dhost)
70+
next
71+
end
6772

6873
reply = probereply(self.capture, to)
6974

modules/auxiliary/scanner/portscan/xmas.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,22 @@ def run_batch(hosts)
5555

5656
to = (datastore['TIMEOUT'] || 500).to_f / 1000.0
5757

58+
# we copy the hosts because some may not be reachable and need to be ejected
59+
host_queue = hosts.dup
5860
# Spread the load across the hosts
5961
ports.each do |dport|
60-
hosts.each do |dhost|
62+
host_queue.each do |dhost|
6163
shost, sport = getsource(dhost)
6264

6365
pcap.setfilter(getfilter(shost, sport, dhost, dport))
6466

6567
begin
6668
probe = buildprobe(shost, sport, dhost, dport)
6769

68-
capture_sendto(probe, dhost)
70+
unless capture_sendto(probe, dhost)
71+
host_queue.delete(dhost)
72+
next
73+
end
6974

7075
reply = probereply(pcap, to)
7176

modules/auxiliary/scanner/rogue/rogue_send.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def run_host(ip)
4343

4444
pcap = self.capture
4545

46-
capture_sendto(build_tcp_syn(ip), ip)
47-
48-
capture_sendto(build_icmp(ip), ip)
46+
capture_sendto(build_tcp_syn(ip), ip) and capture_sendto(build_icmp(ip), ip)
4947

5048
close_pcap
5149
end

modules/exploits/multi/ids/snort_dce_rpc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def exploit
9797

9898
print_status("#{rhost}:#{rport} Sending crafted SMB packet from #{shost}...")
9999

100-
capture_sendto(p, rhost)
100+
return unless capture_sendto(p, rhost)
101101

102102
handler
103103
end

0 commit comments

Comments
 (0)