{"id":59293,"date":"2024-08-31T22:30:28","date_gmt":"2024-08-31T19:30:28","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180624\/enum_dns.rb.txt"},"modified":"2024-08-31T22:30:28","modified_gmt":"2024-08-31T19:30:28","slug":"dns-record-scanner-and-enumerator","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/dns-record-scanner-and-enumerator\/","title":{"rendered":"DNS Record Scanner and Enumerator"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::DNS::Enumeration<\/p>\n<p>def initialize(info = {})<br \/>super(update_info(info,<br \/>&#8216;Name&#8217; =&gt; &#8216;DNS Record Scanner and Enumerator&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q(<br \/>This module can be used to gather information about a domain from a<br \/>given DNS server by performing various DNS queries such as zone<br \/>transfers, reverse lookups, SRV record brute forcing, and other techniques.<br \/>),<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;Carlos Perez &lt;carlos_perez[at]darkoperator.com&gt;&#8217;,<br \/>&#8216;Nixawk&#8217;<br \/>],<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;References&#8217; =&gt; [<br \/>[&#8216;CVE&#8217;, &#8216;1999-0532&#8217;],<br \/>[&#8216;OSVDB&#8217;, &#8216;492&#8217;]]))<\/p>\n<p>register_options(<br \/>[<br \/>OptString.new(&#8216;DOMAIN&#8217;, [true, &#8216;The target domain&#8217;]),<br \/>OptBool.new(&#8216;ENUM_AXFR&#8217;, [true, &#8216;Initiate a zone transfer against each NS record&#8217;, true]),<br \/>OptBool.new(&#8216;ENUM_BRT&#8217;, [true, &#8216;Brute force subdomains and hostnames via the supplied wordlist&#8217;, false]),<br \/>OptBool.new(&#8216;ENUM_A&#8217;, [true, &#8216;Enumerate DNS A record&#8217;, true]),<br \/>OptBool.new(&#8216;ENUM_CNAME&#8217;, [true, &#8216;Enumerate DNS CNAME record&#8217;, true]),<br \/>OptBool.new(&#8216;ENUM_MX&#8217;, [true, &#8216;Enumerate DNS MX record&#8217;, true]),<br \/>OptBool.new(&#8216;ENUM_NS&#8217;, [true, &#8216;Enumerate DNS NS record&#8217;, true]),<br \/>OptBool.new(&#8216;ENUM_SOA&#8217;, [true, &#8216;Enumerate DNS SOA record&#8217;, true]),<br \/>OptBool.new(&#8216;ENUM_TXT&#8217;, [true, &#8216;Enumerate DNS TXT record&#8217;, true]),<br \/>OptBool.new(&#8216;ENUM_RVL&#8217;, [ true, &#8216;Reverse lookup a range of IP addresses&#8217;, false]),<br \/>OptBool.new(&#8216;ENUM_TLD&#8217;, [true, &#8216;Perform a TLD expansion by replacing the TLD with the IANA TLD list&#8217;, false]),<br \/>OptBool.new(&#8216;ENUM_SRV&#8217;, [true, &#8216;Enumerate the most common SRV records&#8217;, true]),<br \/>OptBool.new(&#8216;STOP_WLDCRD&#8217;, [true, &#8216;Stops bruteforce enumeration if wildcard resolution is detected&#8217;, false]),<br \/>OptAddressRange.new(&#8216;IPRANGE&#8217;, [false, &#8220;The target address range or CIDR identifier&#8221;]),<br \/>OptInt.new(&#8216;THREADS&#8217;, [false, &#8216;Threads for ENUM_BRT&#8217;, 1]),<br \/>OptPath.new(&#8216;WORDLIST&#8217;, [false, &#8216;Wordlist of subdomains&#8217;, ::File.join(Msf::Config.data_directory, &#8216;wordlists&#8217;, &#8216;namelist.txt&#8217;)])<br \/>])<\/p>\n<p>register_advanced_options(<br \/>[<br \/>OptInt.new(&#8216;TIMEOUT&#8217;, [false, &#8216;DNS TIMEOUT&#8217;, 8]),<br \/>OptInt.new(&#8216;RETRY&#8217;, [false, &#8216;Number of times to try to resolve a record if no response is received&#8217;, 2]),<br \/>OptInt.new(&#8216;RETRY_INTERVAL&#8217;, [false, &#8216;Number of seconds to wait before doing a retry&#8217;, 2]),<br \/>OptBool.new(&#8216;TCP_DNS&#8217;, [false, &#8216;Run queries over TCP&#8217;, false])<br \/>])<br \/>deregister_options(&#8216;DnsClientUdpTimeout&#8217;, &#8216;DnsClientRetry&#8217;, &#8216;DnsClientRetryInterval&#8217;, &#8216;DnsClientTcpDns&#8217;)<br \/>end<\/p>\n<p>def run<br \/>datastore[&#8216;DnsClientUdpTimeout&#8217;] = datastore[&#8216;TIMEOUT&#8217;]datastore[&#8216;DnsClientRetry&#8217;] = datastore[&#8216;RETRY&#8217;]datastore[&#8216;DnsClientRetryInterval&#8217;] = datastore[&#8216;RETRY_INTERVAL&#8217;]datastore[&#8216;DnsClientTcpDns&#8217;] = datastore[&#8216;TCP_DNS&#8217;]\n<p>begin<br \/>setup_resolver<br \/>rescue RuntimeError =&gt; e<br \/>fail_with(Failure::BadConfig, &#8220;Resolver setup failed &#8211; exception: #{e}&#8221;)<br \/>end<\/p>\n<p>domain = datastore[&#8216;DOMAIN&#8217;]is_wildcard = dns_wildcard_enabled?(domain)<\/p>\n<p># All exceptions should be being handled by the library<br \/># but catching here as well, just in case.<br \/>begin<br \/>dns_axfr(domain) if datastore[&#8216;ENUM_AXFR&#8217;]rescue =&gt; e<br \/>print_error(&#8220;AXFR failed: #{e}&#8221;)<br \/>end<br \/>dns_get_a(domain) if datastore[&#8216;ENUM_A&#8217;]dns_get_cname(domain) if datastore[&#8216;ENUM_CNAME&#8217;]dns_get_ns(domain) if datastore[&#8216;ENUM_NS&#8217;]dns_get_mx(domain) if datastore[&#8216;ENUM_MX&#8217;]dns_get_soa(domain) if datastore[&#8216;ENUM_SOA&#8217;]dns_get_txt(domain) if datastore[&#8216;ENUM_TXT&#8217;]dns_get_tld(domain) if datastore[&#8216;ENUM_TLD&#8217;]dns_get_srv(domain) if datastore[&#8216;ENUM_SRV&#8217;]threads = datastore[&#8216;THREADS&#8217;]dns_reverse(datastore[&#8216;IPRANGE&#8217;], threads) if datastore[&#8216;ENUM_RVL&#8217;]\n<p>return unless datastore[&#8216;ENUM_BRT&#8217;]if is_wildcard<br \/>dns_bruteforce(domain, datastore[&#8216;WORDLIST&#8217;], threads) unless datastore[&#8216;STOP_WLDCRD&#8217;]else<br \/>dns_bruteforce(domain, datastore[&#8216;WORDLIST&#8217;], threads)<br \/>end<br \/>end<\/p>\n<p>def save_note(target, type, records)<br \/>data = { &#8216;target&#8217; =&gt; target, &#8216;records&#8217; =&gt; records }<br \/>report_note(host: target, sname: &#8216;dns&#8217;, type: type, data: data, update: :unique_data)<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::DNS::Enumeration def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;DNS Record Scanner and Enumerator&#8217;,&#8216;Description&#8217; =&gt; %q(This module can be used to gather information about a domain from agiven DNS server by performing various DNS queries such as zonetransfers, reverse lookups, SRV record brute forcing, and &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59293","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59293"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59293\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}