Skip to content

Commit d26303e

Browse files
committed
Merge pull request #1 from jvazquez-r7/review-2681
Clean chargen_probe
2 parents a199dc3 + eba164d commit d26303e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

modules/auxiliary/scanner/chargen/chargen_probe.rb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,14 @@ def initialize
3131
'License' => MSF_LICENSE,
3232
'References' =>
3333
[
34-
[ 'CVE', 'CVE-1999-0103' ],
34+
[ 'CVE', '1999-0103' ],
3535
[ 'URL', 'https://www.cert.be/pro/docs/chargensnmp-ddos-attacks-rise' ],
3636
[ 'URL', 'http://tools.ietf.org/html/rfc864' ],
3737
],
3838
'DisclosureDate' => 'Feb 08 1996')
3939

4040
register_options([
41-
Opt::RPORT(19),
42-
OptInt.new('TIMEOUT', [true, 'Timeout for the Chargen probe', 5]),
41+
Opt::RPORT(19)
4342
])
4443

4544
deregister_options('RHOST')
@@ -49,24 +48,21 @@ def run_host(rhost)
4948
begin
5049
connect_udp
5150
pkt = Rex::Text.rand_text_alpha_lower(1)
52-
req = udp_sock.write(pkt)
51+
udp_sock.write(pkt)
52+
r = udp_sock.recvfrom(65535, 0.1)
5353

54-
while ((res = udp_sock.recvfrom(65535,0.1)) && (res[1]))
55-
56-
vprint_status("#{rhost}:#{rport} - Response: #{res[0].to_s}")
57-
58-
res = res[0].to_s.strip
54+
if r and r[1]
55+
vprint_status("#{rhost}:#{rport} - Response: #{r[0].to_s}")
56+
res = r[0].to_s.strip
5957
if (res.match(/ABCDEFGHIJKLMNOPQRSTUVWXYZ/i) || res.match(/0123456789/))
6058
print_good("#{rhost}:#{rport} answers with #{res.length} bytes (headers + UDP payload)")
6159
report_service(:host => rhost, :port => rport, :name => "chargen", :info => res.length)
6260
end
6361
end
64-
65-
disconnect_udp
66-
rescue ::Interrupt
67-
raise $!
6862
rescue ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionRefused
6963
nil
64+
ensure
65+
disconnect_udp if self.udp_sock
7066
end
7167
end
7268
end

0 commit comments

Comments
 (0)