Git Product home page Git Product logo

dnscan's Introduction

dnscan

dnscan is a python wordlist-based DNS subdomain scanner.

The script will first try to perform a zone transfer using each of the target domain's nameservers.

If this fails, it will lookup TXT and MX records for the domain, and then perform a recursive subdomain scan using the supplied wordlist.

Usage

dnscan.py (-d <domain> | -l <list>) [OPTIONS]

Mandatory Arguments

-d  --domain                              Target domain; OR
-l  --list                                Newline separated file of domains to scan

Optional Arguments

-w --wordlist <wordlist>                  Wordlist of subdomains to use
-t --threads <threadcount>                Threads (1 - 32), default 8
-6 --ipv6                                 Scan for IPv6 records (AAAA)
-z --zonetransfer                         Perform zone transfer and exit
-r --recursive                            Recursively scan subdomains
   --recurse-wildcards                    Recursively scan wildcards (slow)

-m --maxdepth                             Maximum levels to scan recursively
-a --alterations                          Scan for alterations of subdomains (slow)
-R --resolver <resolver>                  Use the specified resolver instead of the system default
-L --resolver-list <file>                 Read list of resolvers from a file
-T --tld                                  Scan for the domain in all TLDs
-o --output <filename>                    Output to a text file
-i --output-ips <filename>                Output discovered IP addresses to a text file
-n --nocheck                              Don't check nameservers before scanning. Useful in airgapped networks
-q --quick                                Only perform the zone transfer and subdomain scans. Suppresses most file output with -o
-N --no-ip                                Don't print IP addresses in the output
-v --verbose                              Verbose output
-h --help                                 Display help text

Custom insertion points can be specified by adding %% in the domain name, such as:

$ dnscan.py -d dev-%%.example.org

Wordlists

A number of wordlists are supplied with dnscan.

The first four (subdomains-100.txt, subdomains-500.txt, subdomains-1000.txt and subdomains-10000.txt) were created by analysing the most commonly occuring subomdains in approximately 86,000 zone files that were transferred as part of a separate research project. These wordlists are sorted by the popularity of the subdomains (more strictly by the percentage of zones that contained them in the dataset).

The subdomain-uk-500.txt and subdomain-uk-1000.txt lists are created using the same methodology, but from a set of approximately 180,000 zone transfers from ".uk" domains.

The final (and default) wordlist (subdomains.txt) is based on the top 500 subdomains by popularity and the top 500 UK subdomains, but has had a number of manual additions made based on domains identified during testing.

This list is sorted alphabetically and currently contains approximately 770 entries.

TLD Scanning

The -T (--tld) option can be used to scan for all of the TLDs a specific domain name exists in. By default it will use the tlds.txt list, which contains all of the TLDs listed by IANA (including new TLDs). You can also specify a custom wordlist with -w. The suffixes.txt file included is a cut-down version of the public suffix list, so will include most of the second level domains (such as co.uk).

Note that when you use this option, you should only specify the base of the domain name ("github", not "github.com").

Alterations

The -a/--alterations switch adds various prefixes and suffixes (such as dev, test, 01, etc) to the domains, with and without hyphens. This generates a lot of extra permutations (approximately 60 permutations per domain), so is much slower, especially with larger wordlists.

Setup

dnscan requires Python 3, and the netaddr (version 0.7.19 or greater) and dnspython (version 2.0.0 or greater) libraries.

Run the following command to install dependencies:

$ pip install -r requirements.txt

dnscan's People

Contributors

0xflotus avatar asadath1395 avatar cry avatar jamesbercegay avatar mantissts avatar moeinfatehi avatar poliwrath avatar rbsec avatar shaggyz avatar shelld3v avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnscan's Issues

Plaintext output

Hi @rbsec!

I really enjoy using dnscan and it is really helpful during the recon process.

However, when using the output with other tools the format becomes a major challenge. Any chance of including an option to get plaintext output.

Thanks in advance.

Best,
sumgr0

Don't add `noise` to the output file

The tool adds noise in the output file even verbose flag is not set. It's ok to print verbose output to console, but not in file.

I run dnscan with the following args:

dnscan -d example.com -D -o sds.txt

The content of sds.txt:

[*] Processing domain example.com
[*] Using system resolvers ['127.0.0.53']
[+] Getting nameservers
199.43.133.53 - b.iana-servers.net
199.43.135.53 - a.iana-servers.net
[-] Zone transfer failed

[+] IPv6 (AAAA) records found. Try running dnscan with the -6 option.
2606:2800:220:1:248:1893:25c8:1946
[+] TXT records found
"v=spf1 -all"
"8j5nfqld20zpcyr8xjw0ydcfq9rk8hgm"
[-] Invalid DNSKEY record length

[+] MX records found, added to target list
0 .
[*] Scanning example.com for A records
example.com - 93.184.216.34
www.example.com - 93.184.216.34

If you agree with this change, I'll be happy to create a PR.

Scan result difference and text output

Hello,

Thank you for your work.

I am testing dnscan to find some valid domains with all existing tlds.
But for domains that I checked by hand for which I found several hundred matches dnsscan found me only 16 with the command.

./dnscan.py -d example -R 1.1.1.1 -T --output example_domains.txt

then

with my DNS server (DNSSEC active)

 python3 dnscan.py -d google -R 127.0.0.1 -T --output google_domains.txt

 python3 dnscan.py -d google -R 1.1.1.1 -T --output google_domains.txt

I have 286 domains on the screen but the google_domains.txt file contains:

[] Processing domain google
[
] Using specified resolvers: 1.1.1.1
[+] TLD Scan

With the command

 python3 dnscan.py -d google -R 1.1.1.1 -T > google_domains.txt

My file is well populated but with several line breaks like this
...
google.ac - ns1.google.com

google.af - ns1.google.com

google.aero - ns1.101domain.com

google.ad - ns1.google.com
...

NS outputs are not useful to me and will generate a workload.

What are the tips to understand to help me?
Thank you for your help.
__

Bug: TypeError: argument of type 'NoneType' is not iterable

hi,
when i try to use dnscan with option -l to bruteforce multiple domains, this bug appear

Traceback (most recent call last): File "/usr/bin/dnscan", line 386, in <module> if not '%%' in args.domain: TypeError: argument of type 'NoneType' is not iterable

Feature Request

Can we have stdout silent feature to show only output like :

$python3 dnscan.py -d example.com -R 8.8.8.8 -silent

13.126.128.222 - example.com
13.126.119.83 - api.example.com
13.235.126.49 - api.example.com
13.35.191.126 - assets.example.com

Input filtering for domain

If the input is given as www.example.com dnscan still tries to enumerate domains,with the prefix www.

Can we have step in dnscan.py to clean/filter the input.

Wildcard scan

Hello, there is a bug inside dnscan.py at line 114: add_target(domain) # Recursively scan subdomains

This function must be run only when wildcard = get_wildcard(domain) is empty, so it is needed to add a condition if not wildcard:, or wildcard domain will be added to recursive subdomain scan.

Adding support for Module import

It is possible to add support for module like import to be used in conjunction with other Modules
for example

import dnscan
or
from dnscan import finder

So that it can be used like

results = finder.subdomainfinder("example.com") # return dict

The reason am asking for this is because I have intergrated this module here at
https://www.nmmapper.com/sys/tools/subdomainfinder/
But I just use the hard way not module like import.
Thank you.

AttributeError: 'DNSKEY' object has no attribute 'signer'

Hello,
I got this error when trying to bruteforce subdomains:
Traceback (most recent call last):
File "dnscan.py", line 499, in
get_dnssec(target, nsip)
File "dnscan.py", line 263, in get_dnssec
dns.dnssec.validate(answer[0],answer[1],{name:answer[0]})
File "/usr/local/lib/python3.8/dist-packages/dns/dnssec.py", line 490, in _validate
_validate_rrsig(rrset, rrsig, keys, origin, now)
File "/usr/local/lib/python3.8/dist-packages/dns/dnssec.py", line 287, in _validate_rrsig
candidate_keys = _find_candidate_keys(keys, rrsig)
File "/usr/local/lib/python3.8/dist-packages/dns/dnssec.py", line 170, in _find_candidate_keys
value = keys.get(rrsig.signer)
AttributeError: 'DNSKEY' object has no attribute 'signer'

Regards

randomly missing some domains from provided list

i was providing list of subdomains from which a subdomain was missing to list down though it was available .
like was scanning abc.com and from list there was keyword analytic but tool bypass this subdomain
but actually analytics.abc.com is available . when I retried it, the tool identified that particular sub domain . so is there any extensive setting which i should implement to scan all list thoroughly. other wise how can we rely on tool .

dnscan.py: error: one of the arguments

Hi,
i have error, looking for help
Thanks.

C:\Users\nng\Desktop\dnscan-master>dnscan.py -d dev-%%.example.org
usage: dnscan.py [-h] (-d DOMAIN | -l DOMAIN_LIST) [-w WORDLIST] [-t THREADS] [-6] [-z] [-r] [-m MAXDEPTH] [-a]
[-R RESOLVERS] [-L RESOLVER_LIST] [-T] [-o OUTPUT_FILENAME] [-i OUTPUT_IPS] [-D] [-N] [-v] [-n] [-q]
dnscan.py: error: one of the arguments -d/--domain -l/--list is required

Resolver module issue

Hi,

I'm no longer able to run dnscan due to the following error:

:~/dnscan$ python3 dnscan.py -d test.com
Traceback (most recent call last):
  File "dnscan.py", line 349, in <module>
    resolver.resolve('.', 'NS')
AttributeError: 'Resolver' object has no attribute 'resolve'

I tried to update dnspython and install dsnpython3, but I still have the same error, with python2 and python3.

I googled a lot to find a potential fix, without success.

found a bug

i enumerate valid subdomains by dnscan,but it was wrong,How should I solve it?
image

Improved wildcard functionality

I have noticed that when using dnscan with a DNS provider that redirects bad requests to a search page, the current approach doesn't always work to detect wildcard. For example, my ISP (CableOne) will fail and not redirect for a domain like 12345.twitter.com. But if I add an 'a' to the beginning (a12345.twitter.com) it works as expected and redirects, thus detecting the wildcard behavior. Otherwise, all non existent domains are redirected to the "failed DNS query search page" thus giving a ton of false positives.

# Use current unix time as a test subdomain
epochtime = 'a' + str(int(time.time())) 

Changing the above code in the get_wildcard() method to include a prefixed alpha character worked for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.