2010-05-03 17:13:09 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-10-19 04:58:50 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require "net/dns/resolver"
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
include Msf::Auxiliary::Report
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2012-03-26 21:08:39 +00:00
|
|
|
'Name' => 'DNS Record Scanner and Enumerator ',
|
2010-09-20 08:06:27 +00:00
|
|
|
'Description' => %q{
|
2012-03-26 21:20:00 +00:00
|
|
|
This module can be used to gather information about a domain from a
|
|
|
|
given DNS server by performing various DNS queries such as zone
|
|
|
|
transfers, reverse lookups, SRV record bruteforcing, and other techniques.
|
2012-03-26 21:08:39 +00:00
|
|
|
|
2010-09-20 08:06:27 +00:00
|
|
|
},
|
|
|
|
'Author' => [ 'Carlos Perez <carlos_perez[at]darkoperator.com>' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Version' => '$Revision$',
|
|
|
|
'References' =>
|
|
|
|
[
|
2010-05-03 17:13:09 +00:00
|
|
|
['CVE', '1999-0532'],
|
2010-05-05 18:18:51 +00:00
|
|
|
['OSVDB', '492'],
|
2010-05-03 17:13:09 +00:00
|
|
|
]
|
|
|
|
))
|
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('DOMAIN', [ true, "The target domain name"]),
|
2012-03-26 21:08:39 +00:00
|
|
|
OptBool.new('ENUM_AXFR', [ true, 'Initiate a zone transfer against each NS record', true]),
|
2012-06-15 15:33:23 +00:00
|
|
|
OptBool.new('ENUM_TLD', [ true, 'Perform a TLD expansion by replacing the TLD with the IANA TLD list', false]),
|
2009-10-19 04:58:50 +00:00
|
|
|
OptBool.new('ENUM_STD', [ true, 'Enumerate standard record types (A,MX,NS,TXT and SOA)', true]),
|
2012-03-26 21:08:39 +00:00
|
|
|
OptBool.new('ENUM_BRT', [ true, 'Brute force subdomains and hostnames via the supplied wordlist', false]),
|
2010-03-15 00:37:26 +00:00
|
|
|
OptBool.new('ENUM_IP6', [ true, 'Brute force hosts with IPv6 AAAA records',false]),
|
2009-11-10 03:08:16 +00:00
|
|
|
OptBool.new('ENUM_RVL', [ true, 'Reverse lookup a range of IP addresses', false]),
|
2009-10-19 04:58:50 +00:00
|
|
|
OptBool.new('ENUM_SRV', [ true, 'Enumerate the most common SRV records', true]),
|
2012-03-26 21:08:39 +00:00
|
|
|
OptPath.new('WORDLIST', [ false, "Wordlist for domain name bruteforcing", ::File.join(Msf::Config.install_root, "data", "wordlists", "namelist.txt")]),
|
|
|
|
OptAddress.new('NS', [ false, "Specify the nameserver to use for queries (default is system DNS)" ]),
|
2009-11-10 03:08:16 +00:00
|
|
|
OptAddressRange.new('IPRANGE', [false, "The target address range or CIDR identifier"]),
|
2012-03-26 21:08:39 +00:00
|
|
|
OptBool.new('STOP_WLDCRD', [ true, 'Stops bruteforce enumeration if wildcard resolution is detected', false])
|
2009-10-19 04:58:50 +00:00
|
|
|
], self.class)
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
register_advanced_options(
|
|
|
|
[
|
|
|
|
OptInt.new('RETRY', [ false, "Number of times to try to resolve a record if no response is received", 2]),
|
|
|
|
OptInt.new('RETRY_INTERVAL', [ false, "Number of seconds to wait before doing a retry", 2]),
|
|
|
|
], self.class)
|
|
|
|
end
|
2009-11-08 00:16:00 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
def switchdns(target)
|
|
|
|
if not datastore['NS'].nil?
|
|
|
|
print_status("Using DNS Server: #{datastore['NS']}")
|
|
|
|
@res.nameserver=(datastore['NS'])
|
|
|
|
@nsinuse = datastore['NS']
|
|
|
|
else
|
|
|
|
querysoa = @res.query(target, "SOA")
|
|
|
|
if (querysoa)
|
|
|
|
(querysoa.answer.select { |i| i.class == Net::DNS::RR::SOA}).each do |rr|
|
|
|
|
query1soa = @res.search(rr.mname)
|
2009-11-08 00:16:00 +00:00
|
|
|
if (query1soa and query1soa.answer[0])
|
2009-10-19 04:58:50 +00:00
|
|
|
print_status("Setting DNS Server to #{target} NS: #{query1soa.answer[0].address}")
|
|
|
|
@res.nameserver=(query1soa.answer[0].address)
|
|
|
|
@nsinuse = query1soa.answer[0].address
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
def wildcard(target)
|
|
|
|
rendsub = rand(10000).to_s
|
|
|
|
query = @res.query("#{rendsub}.#{target}", "A")
|
|
|
|
if query.answer.length != 0
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("This domain has wildcards enabled!!")
|
2009-10-19 04:58:50 +00:00
|
|
|
query.answer.each do |rr|
|
2010-08-30 01:30:57 +00:00
|
|
|
print_status("Wildcard IP for #{rendsub}.#{target} is: #{rr.address.to_s}") if rr.class != Net::DNS::RR::CNAME
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
def genrcd(target)
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Retrieving general DNS records")
|
2009-10-19 04:58:50 +00:00
|
|
|
query = @res.search(target)
|
|
|
|
if (query)
|
|
|
|
query.answer.each do |rr|
|
|
|
|
next unless rr.class == Net::DNS::RR::A
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Domain: #{target} IP address: #{rr.address} Record: A ")
|
2009-11-08 00:16:00 +00:00
|
|
|
report_note(:host => rr.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2009-10-19 04:58:50 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2009-10-19 04:58:50 +00:00
|
|
|
:data => "#{rr.address.to_s},#{target},A")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
query = @res.query(target, "SOA")
|
|
|
|
if (query)
|
|
|
|
(query.answer.select { |i| i.class == Net::DNS::RR::SOA}).each do |rr|
|
|
|
|
query1 = @res.search(rr.mname)
|
|
|
|
if (query1)
|
|
|
|
query1.answer.each do |ip|
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Start of Authority: #{rr.mname} IP address: #{ip.address} Record: SOA")
|
2009-11-08 00:16:00 +00:00
|
|
|
report_note(:host => ip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2009-10-19 04:58:50 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2009-10-19 04:58:50 +00:00
|
|
|
:data => "#{ip.address.to_s},#{rr.mname},SOA")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
query = @res.query(target, "NS")
|
|
|
|
if (query)
|
|
|
|
(query.answer.select { |i| i.class == Net::DNS::RR::NS}).each do |rr|
|
|
|
|
query1 = @res.search(rr.nsdname)
|
|
|
|
if (query1)
|
|
|
|
query1.answer.each do |ip|
|
|
|
|
next unless ip.class == Net::DNS::RR::A
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Name Server: #{rr.nsdname} IP address: #{ip.address} Record: NS")
|
2009-11-08 00:16:00 +00:00
|
|
|
report_note(:host => ip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2009-10-19 04:58:50 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2009-10-19 04:58:50 +00:00
|
|
|
:data => "#{ip.address.to_s},#{rr.nsdname},NS")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
query = @res.query(target, "MX")
|
|
|
|
if (query)
|
|
|
|
(query.answer.select { |i| i.class == Net::DNS::RR::MX}).each do |rr|
|
|
|
|
print_status("Name: #{rr.exchange} Preference: #{rr.preference} Record: MX")
|
2009-11-08 00:16:00 +00:00
|
|
|
report_note(:host => @nsinuse.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2009-10-19 04:58:50 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2009-10-19 04:58:50 +00:00
|
|
|
:data => "#{rr.exchange},MX")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
query = @res.query(target, "TXT")
|
|
|
|
if (query)
|
|
|
|
query.answer.each do |rr|
|
2012-05-04 18:23:27 +00:00
|
|
|
print_status(rr.inspect)
|
|
|
|
print_status("Text: #{rr.inspect}")
|
2009-10-19 04:58:50 +00:00
|
|
|
report_note(:host => @nsinuse.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2009-10-19 04:58:50 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2012-05-04 18:23:27 +00:00
|
|
|
:data => rr.inspect)
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#---------------------------------------------------------------------------------
|
2009-11-10 03:08:16 +00:00
|
|
|
def tldexpnd(targetdom,nssrv)
|
|
|
|
target = targetdom.scan(/(\S*)[.]\w*\z/).join
|
|
|
|
target.chomp!
|
2009-10-19 04:58:50 +00:00
|
|
|
if not nssrv.nil?
|
|
|
|
@res.nameserver=(nssrv)
|
|
|
|
end
|
|
|
|
i, a = 0, []
|
|
|
|
tlds = [
|
|
|
|
"com", "org", "net", "edu", "mil", "gov", "uk", "af", "al", "dz",
|
|
|
|
"as", "ad", "ao", "ai", "aq", "ag", "ar", "am", "aw", "ac","au",
|
|
|
|
"at", "az", "bs", "bh", "bd", "bb", "by", "be", "bz", "bj", "bm",
|
|
|
|
"bt", "bo", "ba", "bw", "bv", "br", "io", "bn", "bg", "bf", "bi",
|
|
|
|
"kh", "cm", "ca", "cv", "ky", "cf", "td", "cl", "cn", "cx", "cc",
|
|
|
|
"co", "km", "cd", "cg", "ck", "cr", "ci", "hr", "cu", "cy", "cz",
|
|
|
|
"dk", "dj", "dm", "do", "tp", "ec", "eg", "sv", "gq", "er", "ee",
|
|
|
|
"et", "fk", "fo", "fj", "fi", "fr", "gf", "pf", "tf", "ga", "gm",
|
|
|
|
"ge", "de", "gh", "gi", "gr", "gl", "gd", "gp", "gu", "gt", "gg",
|
|
|
|
"gn", "gw", "gy", "ht", "hm", "va", "hn", "hk", "hu", "is", "in",
|
|
|
|
"id", "ir", "iq", "ie", "im", "il", "it", "jm", "jp", "je", "jo",
|
|
|
|
"kz", "ke", "ki", "kp", "kr", "kw", "kg", "la", "lv", "lb", "ls",
|
|
|
|
"lr", "ly", "li", "lt", "lu", "mo", "mk", "mg", "mw", "my", "mv",
|
|
|
|
"ml", "mt", "mh", "mq", "mr", "mu", "yt", "mx", "fm", "md", "mc",
|
|
|
|
"mn", "ms", "ma", "mz", "mm", "na", "nr", "np", "nl", "an", "nc",
|
|
|
|
"nz", "ni", "ne", "ng", "nu", "nf", "mp", "no", "om", "pk", "pw",
|
|
|
|
"pa", "pg", "py", "pe", "ph", "pn", "pl", "pt", "pr", "qa", "re",
|
|
|
|
"ro", "ru", "rw", "kn", "lc", "vc", "ws", "sm", "st", "sa", "sn",
|
|
|
|
"sc", "sl", "sg", "sk", "si", "sb", "so", "za", "gz", "es", "lk",
|
|
|
|
"sh", "pm", "sd", "sr", "sj", "sz", "se", "ch", "sy", "tw", "tj",
|
|
|
|
"tz", "th", "tg", "tk", "to", "tt", "tn", "tr", "tm", "tc", "tv",
|
|
|
|
"ug", "ua", "ae", "gb", "us", "um", "uy", "uz", "vu", "ve", "vn",
|
|
|
|
"vg", "vi", "wf", "eh", "ye", "yu", "za", "zr", "zm", "zw", "int",
|
|
|
|
"gs", "info", "biz", "su", "name", "coop", "aero" ]
|
2012-03-26 21:08:39 +00:00
|
|
|
print_status("Performing Top Level Domain expansion using #{tlds.size} TLDs")
|
2009-10-19 04:58:50 +00:00
|
|
|
|
2010-09-07 15:44:38 +00:00
|
|
|
tlds.each do |tld|
|
|
|
|
query1 = @res.search("#{target}.#{tld}")
|
|
|
|
if (query1)
|
|
|
|
query1.answer.each do |rr|
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Domain: #{target}.#{tld} Name: #{rr.name} IP address: #{rr.address} Record: A ") if rr.class == Net::DNS::RR::A
|
2010-09-07 15:44:38 +00:00
|
|
|
report_note(:host => rr.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2011-02-22 20:49:44 +00:00
|
|
|
:port => 53,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-09-07 15:44:38 +00:00
|
|
|
:data => "#{rr.address.to_s},#{target}.#{tld},A") if rr.class == Net::DNS::RR::A
|
|
|
|
end
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
|
|
|
end
|
2010-08-30 01:30:57 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2010-03-15 00:37:26 +00:00
|
|
|
def dnsbrute(target, wordlist, nssrv)
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Running bruteforce against domain #{target}")
|
2009-10-19 04:58:50 +00:00
|
|
|
arr = []
|
|
|
|
i, a = 0, []
|
2010-08-30 20:41:22 +00:00
|
|
|
::File.open(wordlist, "rb").each_line do |line|
|
2010-08-30 01:30:57 +00:00
|
|
|
if not nssrv.nil?
|
|
|
|
@res.nameserver=(nssrv)
|
|
|
|
end
|
|
|
|
query1 = @res.search("#{line.chomp}.#{target}")
|
|
|
|
if (query1)
|
|
|
|
query1.answer.each do |rr|
|
|
|
|
if rr.class == Net::DNS::RR::A
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Hostname: #{line.chomp}.#{target} IP address: #{rr.address.to_s}")
|
2010-08-30 01:30:57 +00:00
|
|
|
report_note(:host => rr.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-08-30 01:30:57 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-08-30 01:30:57 +00:00
|
|
|
:data => "#{rr.address.to_s},#{line.chomp}.#{target},A")
|
|
|
|
next unless rr.class == Net::DNS::RR::CNAME
|
|
|
|
end
|
|
|
|
end
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-15 00:37:26 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
def bruteipv6(target, wordlist, nssrv)
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Bruteforcing IPv6 addresses against domain #{target}")
|
2010-03-15 00:37:26 +00:00
|
|
|
arr = []
|
|
|
|
i, a = 0, []
|
|
|
|
arr = IO.readlines(wordlist)
|
|
|
|
if not nssrv.nil?
|
|
|
|
@res.nameserver=(nssrv)
|
|
|
|
end
|
|
|
|
arr.each do |line|
|
2010-08-30 01:30:57 +00:00
|
|
|
query1 = @res.search("#{line.chomp}.#{target}", "AAAA")
|
|
|
|
if (query1)
|
|
|
|
query1.answer.each do |rr|
|
|
|
|
if rr.class == Net::DNS::RR::AAAA
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Hostname: #{line.chomp}.#{target} IPv6 Address: #{rr.address.to_s}")
|
2010-08-30 01:30:57 +00:00
|
|
|
report_note(:host => rr.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-08-30 01:30:57 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-08-30 01:30:57 +00:00
|
|
|
:data => "#{rr.address.to_s},#{line.chomp}.#{target},AAAA")
|
|
|
|
next unless rr.class == Net::DNS::RR::CNAME
|
|
|
|
end
|
|
|
|
end
|
2010-03-15 00:37:26 +00:00
|
|
|
end
|
2010-08-30 01:30:57 +00:00
|
|
|
|
2010-03-15 00:37:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
def reverselkp(iprange,nssrv)
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Running reverse lookup against IP range #{iprange}")
|
2009-10-19 04:58:50 +00:00
|
|
|
if not nssrv.nil?
|
|
|
|
@res.nameserver = (nssrv)
|
|
|
|
end
|
|
|
|
ar = Rex::Socket::RangeWalker.new(iprange)
|
|
|
|
tl = []
|
|
|
|
while (true)
|
|
|
|
# Spawn threads for each host
|
|
|
|
while (tl.length < @threadnum)
|
|
|
|
ip = ar.next_ip
|
|
|
|
break if not ip
|
2010-11-12 06:19:49 +00:00
|
|
|
tl << framework.threads.spawn("Module(#{self.refname})-#{ip}", false, ip.dup) do |tip|
|
2009-10-19 04:58:50 +00:00
|
|
|
begin
|
|
|
|
query = @res.query(tip)
|
|
|
|
query.each_ptr do |addresstp|
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Hostname: #{addresstp} IP address: #{tip.to_s}")
|
2009-11-08 00:16:00 +00:00
|
|
|
report_note(:host => tip,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2009-10-19 04:58:50 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2009-10-19 04:58:50 +00:00
|
|
|
:data => "#{addresstp},#{tip},A")
|
|
|
|
end
|
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
|
|
|
rescue ::Rex::ConnectionError
|
|
|
|
rescue ::Exception => e
|
2010-07-25 21:37:54 +00:00
|
|
|
print_error("Error: #{tip}: #{e.message}")
|
2009-10-19 04:58:50 +00:00
|
|
|
elog("Error running against host #{tip}: #{e.message}\n#{e.backtrace.join("\n")}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# Exit once we run out of hosts
|
|
|
|
if(tl.length == 0)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
tl.first.join
|
|
|
|
tl.delete_if { |t| not t.alive? }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
#SRV Record Enumeration
|
|
|
|
def srvqry(dom,nssrv)
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Enumerating SRV records for #{dom}")
|
2009-12-11 20:24:55 +00:00
|
|
|
i, a = 0, []
|
2009-10-19 04:58:50 +00:00
|
|
|
#Most common SRV Records
|
|
|
|
srvrcd = [
|
|
|
|
"_gc._tcp.","_kerberos._tcp.", "_kerberos._udp.","_ldap._tcp","_test._tcp.",
|
|
|
|
"_sips._tcp.","_sip._udp.","_sip._tcp.","_aix._tcp.","_aix._tcp.","_finger._tcp.",
|
|
|
|
"_ftp._tcp.","_http._tcp.","_nntp._tcp.","_telnet._tcp.","_whois._tcp.","_h323cs._tcp.",
|
2009-11-10 03:08:16 +00:00
|
|
|
"_h323cs._udp.","_h323be._tcp.","_h323be._udp.","_h323ls._tcp.","_h323ls._udp.",
|
2009-12-11 20:24:55 +00:00
|
|
|
"_sipinternal._tcp.","_sipinternaltls._tcp.","_sip._tls.","_sipfederationtls._tcp.",
|
2011-06-23 00:25:32 +00:00
|
|
|
"_jabber._tcp.","_xmpp-server._tcp.","_xmpp-client._tcp.","_imap._tcp.","_certificates._tcp.",
|
2009-12-11 20:24:55 +00:00
|
|
|
"_crls._tcp.","_pgpkeys._tcp.","_pgprevokations._tcp.","_cmp._tcp.","_svcp._tcp.","_crl._tcp.",
|
|
|
|
"_ocsp._tcp.","_PKIXREP._tcp.","_smtp._tcp.","_hkp._tcp.","_hkps._tcp.","_jabber._udp.",
|
2010-08-30 01:30:57 +00:00
|
|
|
"_xmpp-server._udp.","_xmpp-client._udp.","_jabber-client._tcp.","_jabber-client._udp."]
|
2009-12-11 20:24:55 +00:00
|
|
|
srvrcd.each do |srvt|
|
2010-08-30 01:30:57 +00:00
|
|
|
trg = "#{srvt}#{dom}"
|
|
|
|
query = @res.query(trg , Net::DNS::SRV)
|
|
|
|
if query
|
|
|
|
query.answer.each do |srv|
|
|
|
|
print_status("SRV Record: #{trg} Host: #{srv.host} Port: #{srv.port} Priority: #{srv.priority}") if srv.type != "CNAME"
|
|
|
|
end
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
#For Performing Zone Transfers
|
|
|
|
def axfr(target, nssrv)
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Performing zone transfer against all nameservers in #{target}")
|
2009-10-19 04:58:50 +00:00
|
|
|
if not nssrv.nil?
|
|
|
|
@res.nameserver=(nssrv)
|
|
|
|
end
|
2009-11-11 14:14:55 +00:00
|
|
|
@res.tcp_timeout=15
|
2009-10-19 04:58:50 +00:00
|
|
|
query = @res.query(target, "NS")
|
|
|
|
if (query.answer.length != 0)
|
|
|
|
(query.answer.select { |i| i.class == Net::DNS::RR::NS}).each do |nsrcd|
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Testing nameserver: #{nsrcd.nsdname}")
|
2009-11-10 04:14:25 +00:00
|
|
|
nssrvquery = @res.query(nsrcd.nsdname, "A")
|
2009-11-11 14:14:55 +00:00
|
|
|
begin
|
2010-07-25 21:37:54 +00:00
|
|
|
nssrvip = nssrvquery.answer[0].address.to_s
|
|
|
|
@res.nameserver=(nssrvip)
|
|
|
|
zone = []
|
|
|
|
zone = @res.query(target,Net::DNS::AXFR)
|
|
|
|
if zone.answer.length != 0
|
|
|
|
namesrvips = @res.query(nsrcd.nsdname,"A")
|
|
|
|
nsip = namesrvips.answer[0]
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Zone transfer successful")
|
2010-07-25 21:37:54 +00:00
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2012-03-26 21:14:04 +00:00
|
|
|
:data => "Zone transfer successful")
|
2010-07-25 21:37:54 +00:00
|
|
|
#Prints each record according to its type
|
|
|
|
zone.answer.each do |rr|
|
|
|
|
case rr.type
|
|
|
|
when "A"
|
2012-03-26 21:14:04 +00:00
|
|
|
print_status("Name: #{rr.name} IP address: #{rr.address} Record: A ")
|
2010-07-25 21:37:54 +00:00
|
|
|
report_note(:host => rr.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "#{rr.address.to_s},#{rr.name},A")
|
|
|
|
when "SOA"
|
|
|
|
print_status("Name: #{rr.mname} Record: SOA")
|
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "#{rr.name},SOA")
|
|
|
|
when "MX"
|
|
|
|
print_status("Name: #{rr.exchange} Preference: #{rr.preference} Record: MX")
|
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "#{rr.exchange},MX")
|
|
|
|
when "CNAME"
|
|
|
|
print_status("Name: #{rr.cname} Record: CNAME")
|
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "#{rr.cname},CNAME")
|
|
|
|
when "HINFO"
|
|
|
|
print_status("CPU: #{rr.cpu} OS: #{rr.os} Record: HINFO")
|
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "CPU:#{rr.cpu},OS:#{rr.os},HINFO")
|
|
|
|
when "AAAA"
|
|
|
|
print_status("IPv6 Address: #{rr.address} Record: AAAA")
|
|
|
|
report_note(:host => rr.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "#{rr.address.to_s}, AAAA")
|
|
|
|
when "NS"
|
|
|
|
print_status("Name: #{rr.nsdname} Record: NS")
|
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "#{rr.nsdname},NS")
|
|
|
|
when "TXT"
|
2012-05-04 18:23:27 +00:00
|
|
|
print_status("Text: #{rr.inspect}")
|
2010-07-25 21:37:54 +00:00
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2012-05-04 18:23:27 +00:00
|
|
|
:data => rr.inspect)
|
2010-07-25 21:37:54 +00:00
|
|
|
when "SRV"
|
|
|
|
print_status("Host: #{rr.host} Port: #{rr.port} Priority: #{rr.priority} Record: SRV")
|
|
|
|
report_note(:host => nsip.address.to_s,
|
2011-02-04 01:54:32 +00:00
|
|
|
:proto => 'udp',
|
2012-02-22 05:57:55 +00:00
|
|
|
:sname => 'dns',
|
2010-07-25 21:37:54 +00:00
|
|
|
:port => 53 ,
|
2012-03-26 21:08:39 +00:00
|
|
|
:type => 'dns.enum',
|
2010-07-25 21:37:54 +00:00
|
|
|
:data => "#{rr.host},#{rr.port},#{rr.priority},SRV")
|
|
|
|
end
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
2010-07-25 21:37:54 +00:00
|
|
|
else
|
2012-03-26 21:14:04 +00:00
|
|
|
print_error("Zone transfer failed")
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
2010-07-25 21:37:54 +00:00
|
|
|
rescue
|
2012-03-26 21:14:04 +00:00
|
|
|
print_error("Zone transfer failed")
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
2010-07-25 21:37:54 +00:00
|
|
|
end
|
2009-11-11 14:14:55 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
else
|
|
|
|
print_error("Could not resolve domain #{target}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
|
|
|
@res = Net::DNS::Resolver.new()
|
|
|
|
@res.retry = datastore['RETRY'].to_i
|
|
|
|
@res.retry_interval = datastore['RETRY_INTERVAL'].to_i
|
|
|
|
@threadnum = datastore['THREADS'].to_i
|
2009-12-11 20:24:55 +00:00
|
|
|
wldcrd = wildcard(datastore['DOMAIN'])
|
|
|
|
switchdns(datastore['DOMAIN'])
|
2009-11-08 00:16:00 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
if(datastore['ENUM_STD'])
|
|
|
|
genrcd(datastore['DOMAIN'])
|
|
|
|
end
|
2009-11-08 00:16:00 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
if(datastore['ENUM_TLD'])
|
|
|
|
tldexpnd(datastore['DOMAIN'],datastore['NS'])
|
|
|
|
end
|
2009-11-08 00:16:00 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
if(datastore['ENUM_BRT'])
|
2012-03-26 21:14:04 +00:00
|
|
|
if wldcrd and datastore['STOP_WLDCRD']
|
|
|
|
print_error("Wildcard record found!")
|
2009-12-11 20:24:55 +00:00
|
|
|
else
|
2010-03-15 00:37:26 +00:00
|
|
|
dnsbrute(datastore['DOMAIN'],datastore['WORDLIST'],datastore['NS'])
|
|
|
|
end
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-15 00:37:26 +00:00
|
|
|
if(datastore['ENUM_IP6'])
|
2012-03-26 21:14:04 +00:00
|
|
|
if wldcrd and datastore['STOP_WLDCRD']
|
2011-10-18 00:54:05 +00:00
|
|
|
print_status("Wildcard Record Found!")
|
2010-03-15 00:37:26 +00:00
|
|
|
else
|
|
|
|
bruteipv6(datastore['DOMAIN'],datastore['WORDLIST'],datastore['NS'])
|
2009-11-10 03:08:16 +00:00
|
|
|
end
|
2009-10-19 04:58:50 +00:00
|
|
|
end
|
2009-11-08 00:16:00 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
if(datastore['ENUM_AXFR'])
|
|
|
|
axfr(datastore['DOMAIN'],datastore['NS'])
|
|
|
|
end
|
2009-11-08 00:16:00 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
if(datastore['ENUM_SRV'])
|
|
|
|
srvqry(datastore['DOMAIN'],datastore['NS'])
|
|
|
|
end
|
2009-11-08 00:16:00 +00:00
|
|
|
|
2009-10-19 04:58:50 +00:00
|
|
|
if(datastore['ENUM_RVL'] and datastore['IPRANGE'] and not datastore['IPRANGE'].empty?)
|
|
|
|
reverselkp(datastore['IPRANGE'],datastore['NS'])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|