Skip to content

Commit

Permalink
Sort output IPs and rename option -i/--output-ips for consistency. rb…
Browse files Browse the repository at this point in the history
  • Loading branch information
rbsec committed Jan 10, 2018
1 parent c773380 commit 665fca6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ dnscan.py (-d \<domain\> | -l \<list\>) [OPTIONS]
-z --zonetransfer Perform zone transfer and exit
-r --recursive Recursively scan subdomains
-T --tld Scan for the domain in all TLDs
-o --output Output to a text file
-o --output <filename> Output to a text file
-i --output-ips <filename> Output discovered IP addresses to a text file
-v --verbose Verbose output
-h --help Display help text

Expand Down
13 changes: 9 additions & 4 deletions dnscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
except ImportError:
import queue as Queue

try: # Python2 and Python3 have different IP address libraries
from ipaddress import ip_address as ipaddr
except ImportError:
from netaddr import IPaddress as ipaddr

try:
import argparse
except:
Expand Down Expand Up @@ -67,7 +72,7 @@ def get_name(self, domain):
print(domain + " - " + address, file=outfile)
else:
print(address + " - " + domain, file=outfile)
addresses.add(address)
addresses.add(ipaddr(unicode(address)))
if domain != target and args.recurse: # Don't scan root domain twice
add_target(domain) # Recursively scan subdomains
except:
Expand Down Expand Up @@ -241,7 +246,7 @@ def get_args():
parser.add_argument('-r', '--recursive', action="store_true", default=False, help="Recursively scan subdomains", dest='recurse', required=False)
parser.add_argument('-T', '--tld', action="store_true", default=False, help="Scan for TLDs", dest='tld', required=False)
parser.add_argument('-o', '--output', help="Write output to a file", dest='output_filename', required=False)
parser.add_argument( '--output_ips', help="Write found IP addresses to a file", dest='output_ips', required=False)
parser.add_argument('-i', '--output-ips', help="Write discovered IP addresses to a file", dest='output_ips', required=False)
parser.add_argument('-D', '--domain-first', action="store_true", default=False, help='Output domain first, rather than IP address', dest='domain_first', required=False)
parser.add_argument('-v', '--verbose', action="store_true", default=False, help='Verbose mode', dest='verbose', required=False)
args = parser.parse_args()
Expand Down Expand Up @@ -349,7 +354,7 @@ def setup():
get_mx(target)
wildcard = get_wildcard(target)
if wildcard:
addresses.add(wildcard)
addresses.add(ipaddr(unicode(wildcard)))
out.status("Scanning " + target + " for " + recordtype + " records")
add_target(target)

Expand All @@ -367,7 +372,7 @@ def setup():
sys.exit(1)
print("\n")
if outfile_ips:
for address in addresses:
for address in sorted(addresses):
print(address, file=outfile_ips)
if outfile:
outfile.close()
Expand Down

0 comments on commit 665fca6

Please sign in to comment.