Skip to content

Commit d493c48

Browse files
committed
add thottling,notes insert and output to dns_rev_lookup
1 parent f46b4ab commit d493c48

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

modules/auxiliary/gather/dns_reverse_lookup.rb

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,29 @@ class Metasploit3 < Msf::Auxiliary
1212

1313
def initialize(info = {})
1414
super(update_info(info,
15-
'Name' => 'DNS Reverse Lookup Enumeration',
16-
'Description' => %q{
15+
'Name' => 'DNS Reverse Lookup Enumeration',
16+
'Description' => %q{
1717
This module performs DNS reverse lookup against a given IP range in order to
1818
retrieve valid addresses and names.
1919
},
20-
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>' ],
21-
'License' => BSD_LICENSE
20+
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>', # Base code
21+
'Thanat0s <thanatos[at]trollprod[dot]org>'], # Output, Throttling & Db notes add
22+
'License' => BSD_LICENSE
2223
))
2324

2425
register_options(
2526
[
2627
OptAddressRange.new('RANGE', [true, 'IP range to perform reverse lookup against.']),
27-
OptAddress.new('NS', [ false, "Specify the nameserver to use for queries, otherwise use the system DNS." ])
28+
OptAddress.new('NS', [ false, "Specify the nameserver to use for queries, otherwise use the system DNS." ]),
29+
OptString.new('OUT_FILE', [ false, "Specify a CSV output file" ])
2830
], self.class)
2931

3032
register_advanced_options(
3133
[
3234
OptInt.new('RETRY', [ false, "Number of tries to resolve a record if no response is received.", 2]),
3335
OptInt.new('RETRY_INTERVAL', [ false, "Number of seconds to wait before doing a retry.", 2]),
34-
OptInt.new('THREADS', [ true, "The number of concurrent threads.", 1])
36+
OptInt.new('THREADS', [ true, "The number of concurrent threads.", 1]),
37+
OptInt.new('THROTTLE', [ false, "Specify the resolution throttle in query per sec. 0 means unthrottled",0 ])
3538
], self.class)
3639
end
3740

@@ -55,21 +58,50 @@ def reverselkp(iprange)
5558
print_status("Running reverse lookup against IP range #{iprange}")
5659
ar = Rex::Socket::RangeWalker.new(iprange)
5760
tl = []
61+
# Basic Throttling
62+
sleep_time = 0.0
63+
if (datastore['THROTTLE'] != 0)
64+
sleep_time = (1.0/datastore['THROTTLE'])/datastore['THREADS']
65+
print_status("Throttle set to #{datastore['THROTTLE']} queries per seconds")
66+
end
67+
# Output..
68+
if datastore['OUT_FILE']
69+
print_status("Scan result saved in #{datastore['OUT_FILE']}")
70+
open(datastore['OUT_FILE'], 'w') do |f|
71+
f.puts "; IP, Host"
72+
end
73+
end
5874
while (true)
5975
# Spawn threads for each host
6076
while (tl.length <= @threadnum)
6177
ip = ar.next_ip
78+
hosts = Array.new
6279
break if not ip
6380
tl << framework.threads.spawn("Module(#{self.refname})-#{ip}", false, ip.dup) do |tip|
6481
begin
82+
sleep(sleep_time)
6583
query = @res.query(tip)
6684
query.each_ptr do |addresstp|
67-
print_status("Host Name: #{addresstp}, IP Address: #{tip.to_s}")
85+
print_status("#Host Name: #{addresstp}, IP Address: #{tip.to_s}")
86+
if datastore['OUT_FILE']
87+
open(datastore['OUT_FILE'], 'a') do |f|
88+
f.puts "#{tip.to_s},#{addresstp}"
89+
end
90+
end
6891
report_host(
6992
:host => tip.to_s,
7093
:name => addresstp
7194
)
95+
hosts.push addresstp
96+
end
97+
if !hosts.empty?
98+
report_note(
99+
:host => tip.to_s,
100+
:type => "RDNS_Record",
101+
:data => hosts
102+
)
72103
end
104+
hosts = Array.new
73105
rescue ::Interrupt
74106
raise $!
75107
rescue ::Rex::ConnectionError

0 commit comments

Comments
 (0)