@@ -12,26 +12,32 @@ class Metasploit3 < Msf::Auxiliary
12
12
13
13
def initialize ( info = { } )
14
14
super ( update_info ( info ,
15
- 'Name' => 'DNS Reverse Lookup Enumeration' ,
16
- 'Description' => %q{
15
+ 'Name' => 'DNS Reverse Lookup Enumeration' ,
16
+ 'Description' => %q{
17
17
This module performs DNS reverse lookup against a given IP range in order to
18
18
retrieve valid addresses and names.
19
19
} ,
20
- 'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>' ] ,
21
- 'License' => BSD_LICENSE
20
+ 'Author' =>
21
+ [
22
+ 'Carlos Perez <carlos_perez[at]darkoperator.com>' , # Base code
23
+ 'Thanat0s <thanspam[at]trollprod[dot]org>' # Output, Throttling & Db notes add
24
+ ] ,
25
+ 'License' => BSD_LICENSE
22
26
) )
23
27
24
28
register_options (
25
29
[
26
30
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." ] )
31
+ OptAddress . new ( 'NS' , [ false , "Specify the nameserver to use for queries, otherwise use the system DNS." ] ) ,
32
+ OptString . new ( 'OUT_FILE' , [ false , "Specify a CSV output file" ] )
28
33
] , self . class )
29
34
30
35
register_advanced_options (
31
36
[
32
37
OptInt . new ( 'RETRY' , [ false , "Number of tries to resolve a record if no response is received." , 2 ] ) ,
33
38
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 ] )
39
+ OptInt . new ( 'THREADS' , [ true , "The number of concurrent threads." , 1 ] ) ,
40
+ OptInt . new ( 'THROTTLE' , [ false , "Specify the resolution throttle in query per sec. 0 means unthrottled" , 0 ] )
35
41
] , self . class )
36
42
end
37
43
@@ -55,20 +61,51 @@ def reverselkp(iprange)
55
61
print_status ( "Running reverse lookup against IP range #{ iprange } " )
56
62
ar = Rex ::Socket ::RangeWalker . new ( iprange )
57
63
tl = [ ]
64
+ # Basic Throttling
65
+ sleep_time = 0.0
66
+ if ( datastore [ 'THROTTLE' ] != 0 )
67
+ sleep_time = ( 1.0 /datastore [ 'THROTTLE' ] ) *datastore [ 'THREADS' ]
68
+ print_status ( "Throttle set to #{ datastore [ 'THROTTLE' ] } queries per seconds" )
69
+ end
70
+ # Output..
71
+ if datastore [ 'OUT_FILE' ]
72
+ print_status ( "Scan result saved in #{ datastore [ 'OUT_FILE' ] } " )
73
+ open ( datastore [ 'OUT_FILE' ] , 'w' ) do |f |
74
+ f . puts "; IP, Host"
75
+ end
76
+ end
58
77
while ( true )
59
78
# Spawn threads for each host
79
+ hosts = Hash . new
60
80
while ( tl . length <= @threadnum )
61
81
ip = ar . next_ip
62
82
break if not ip
63
83
tl << framework . threads . spawn ( "Module(#{ self . refname } )-#{ ip } " , false , ip . dup ) do |tip |
64
84
begin
85
+ Rex . sleep ( sleep_time )
65
86
query = @res . query ( tip )
66
87
query . each_ptr do |addresstp |
67
88
print_status ( "Host Name: #{ addresstp } , IP Address: #{ tip . to_s } " )
89
+ if datastore [ 'OUT_FILE' ]
90
+ open ( datastore [ 'OUT_FILE' ] , 'a' ) do |f |
91
+ f . puts "#{ tip . to_s } ,#{ addresstp } "
92
+ end
93
+ end
68
94
report_host (
69
95
:host => tip . to_s ,
70
96
:name => addresstp
71
97
)
98
+ if !hosts [ tip ]
99
+ hosts [ tip ] = Array . new
100
+ end
101
+ hosts [ tip ] . push addresstp
102
+ end
103
+ unless hosts [ tip ] . nil? or hosts [ tip ] . empty?
104
+ report_note (
105
+ :host => tip . to_s ,
106
+ :type => "RDNS_Record" ,
107
+ :data => hosts [ tip ]
108
+ )
72
109
end
73
110
rescue ::Interrupt
74
111
raise $!
0 commit comments