Permalink
Browse files

Only perform reverse lookups against DB hosts

This commit adds a boolean option to limit reverse lookups to
existing hosts. Reverse lookups are threaded anyway, and this
helps all the more with quick name lookups for known IPs.

Testing: populate DB with some hosts, run reverse lookup with
IPRANGE set to 0.0.0.0/0.
  • Loading branch information...
1 parent a29df25 commit 116059103d543d8680f454121bbad4c1ba3d0f79 RageLtMan committed Oct 4, 2012
Showing with 13 additions and 3 deletions.
  1. +13 −3 modules/auxiliary/gather/enum_dns.rb
@@ -52,6 +52,7 @@ def initialize(info = {})
OptInt.new('RETRY_INTERVAL', [ false, "Number of seconds to wait before doing a retry", 2]),
OptInt.new('THREADS', [ true, "Number of threads to use for BRT and RVL", 1]),
OptBool.new('BRT_REPORT_HOST', [false, "Add hosts found via bruteforce to DB", false]),
+ OptBool.new('RVL_EXISTING_ONLY', [false, "Only perform lookups on hosts in DB", true]),
OptBool.new('TCP_DNS', [false, "Run queries over TCP", false]),
], self.class)
end
@@ -350,13 +351,22 @@ def bruteipv6(target, wordlist, nssrv, wldcrd = nil)
#-------------------------------------------------------------------------------
- def reverselkp(iprange,nssrv)
+ def reverselkp(iprange,nssrv,existing_only)
print_status("Running reverse lookup against IP range #{iprange}")
if not nssrv.nil?
@res.nameserver = (nssrv)
@nsinuse = nssrv
end
- ar = Rex::Socket::RangeWalker.new(iprange)
+ if existing_only
+ rng = Rex::Socket::RangeWalker.new(iprange)
+ ws = Mdm::Workspace.where(:name => self.workspace).first
+ lookup_hosts = ws.hosts.map(&:address).keep_if do |addr|
+ rng.include?(addr)
+ end
+ ar = Rex::Socket::RangeWalker.new(lookup_hosts)
+ else
+ ar = Rex::Socket::RangeWalker.new(iprange)
+ end
while (true)
# Spawn threads for each host
while (@dns_enum_threads.length < @threadnum)
@@ -612,7 +622,7 @@ def run
end
if(datastore['ENUM_RVL'] and datastore['IPRANGE'] and not datastore['IPRANGE'].empty?)
- reverselkp(datastore['IPRANGE'],datastore['NS'])
+ reverselkp(datastore['IPRANGE'],datastore['NS'],datastore['RVL_EXISTING_ONLY'])
end
# Do not let module finish while threads exist
while not @dns_enum_threads.empty? do

0 comments on commit 1160591

Please sign in to comment.