Python Subdomain Scanner Tool Report
Python Subdomain Scanner Tool Report
On
Submitted
by
Keshav Kumar Ladda
18MCAR0007
Department of MCA
School of Computer Science & IT,
Jain Knowledge Campus, Jayanagar 9th Block, Bangalore
May 2021
--------------------- ----------------------------------
Project Guide Head of the Department (MCA)
-------------------------- -----------------------
Examiner-1 Examiner-2
Department of MCA
School of Computer Science & IT,
Jain Knowledge Campus, Jayanagar 9th Block, Bangalore
is the original work carried out by me. It has not formed the part of
any other project work submitted for award of any degree or diploma,
18MCAR0007
Most entities neglect the recon at its early stage, where the true and precise information of the network and
their functions are lost. The purpose to perform a recon operation is to perform scanning and attacking in
much more precise and stealthy manner.
A hacker can have an opportunity to ingress into the network, through the systems that are unpatched and
outdated. They can stalk an employee physically or a breach might happen when a company has high
security measures by an outdated update policy.
A hacker might target on the following information and prepare a report on his recon work which includes
Subdomains,Whois Information,Dir info,S3 Buckets,Social accounts etc.
The above listing does not conclude the identities of recon, rather they are a few examples.
The proposed topic “PYTHON BASED SUBDOMAIN SCANNER TOOL” is a project. It is a tool made
with the help of PYTHON programming language. With this tool, user can gain knowledge of the target
websites. The Recon tool is a subdomain discovery tool. It allows you to run a scan for a top-level domain
name to discover target organization subdomains configured in its hierarchy. The Subdomain Scanner uses
the target domain’s DNS server (or any other DNS server specified) to scan the DNS records for possible
subdomains. While scanning, the Subdomain Scanner will also automatically identify if the domain being
scanned uses wildcards (*.[Link]).
It uses DNS servers and DNS enumeration based on common subdomain names. It uses brute-force method
to get subdomains and it does use SSL certificates, public search engines, certspotter, Virustotal and
mapping. subdomains of a domain is an essential part of hacking reconnaissance, having unsecured
subdomain can lead to a serious risk to your business, and lately, there were some security incidents where
the hacker used subdomains tricks.
List of Figures I
Acronyms II
Abstract III
Chapter 1 Introduction 1
1.1 Background ………………………………………………… 1
1.2 Problem Definition ………………………………………. 2
1.3 Project Scope and Objectives …………………………….. 3
1.4 Organization of the Report ………………………………. 4
Chapter 2 Literature Survey 5
2.1 Survey of the Existing Work ……………………………… 5
2.2 Survey of Technologies …………………………………….. 6
Chapter 3 Requirements Analysis 9
3.1 Hardware and Software Requirements …………………. 9
3.2 Users and Use-case Descriptions …………………………. 9
3.3 Functional and Non-Functional Requirements …………. 11
Chapter 4 System Design 12
4.1 Context Diagram …………………………………………. 12
4.2 Proposed System Architecture and Data Design………… 12
CHAPTER 1
INTRODUCTION
1.1 Background
⮚ The name of my project is “PHYTHON BASED RECON TOOL ”, the name itself tells us that it
is a tool used for gathering information of the target. Information such as finding vulnerable
subdomains which can led access to the main domain. Information Gathering and becoming more
acquainted to the target is the first process in ethical hacking. Information gathering is a key for
any successful hack. On average about three-fourth of any hack should be spent performing
precise and accurate reconnaissance.
⮚ The main reason for the development of this tool is to help ethical hackers to gather all the
necessary information of the target domains. Different tools are integrated into this project to find
verified subdomains fast. different tools like Bruteforce, Certspotter, Hackertarget, Virustotal,
Threatcrowd and SSL
⮚ Bruteforce:-Tools use brute force and recursive brute forcing techniques in order to generate
subdomain lists, most of the time combined with word-lists.
⮚ Certspotter:- CertSpotter is a Certificate Transparency log monitor from SSLMate that alerts
you when a SSL/TLS certificate is issued for one of your [Link] Spotter is easier than
other open source CT monitors, since it does not require a database. It's also more robust. Every
time you run Cert Spotter, it scans all browser-recognized. Certificate Transparency logs for
certificates matching domains on your watch list. When Cert Spotter detects a matching
certificate, it writes a report to standard out, which the Cron daemon emails to you. Make sure
you are able to receive emails sent by Cron.
⮚ Quering search engines:-Google hacking techniques are often used to find the subdomains of
any domain name.
⮚ Savemap:-The module lets us savemap of the domain like from where it originated how many
servers it has hopped. output can also be saved in a text file
⮚ The tool works only in kali linux and the requirements are simple for the tool to run
⮚ Features of the tool are it scans all the subdomains of the target domain and scans the subdomains
for verification using SSL,Certspotter and Bruteforce
⮚ It is a lightweight, easy to use, fast, extremely small size and handy Python commands .
⮚ This tool requires internet connection in order to transmit the significant Subdomains of the
target.
⮚ The mechanism used in this project could be used in various fields of operations in day to day
life.
⮚ During reconnaissance, an ethical hacker attempts to gather as much information about a target
system as possible such as −
Recon is a python tool designed to enumerate subdomains using modules. It helps penetration testers
and bug hunters collect and gather subdomains for the domain they are [Link] tool works only
in kali linux and the requirements are simple for the tool to run. Features of the tool are it scans all the
subdomains of the target domain and scans the subdomains for verification using SSL,Certspotter and
Bruteforce This tool requires internet connection in order to transmit the significant Subdomains of
the target, various tools have problem in scanning like taking excess time scanning and showing
results The mechanism used in this project could be used in various fields of operations in day to day
life.
The objective and scope of Project “PYTHON BASED SUBDOMAIN SCANNER TOOL” is to
gather subdomains of the target, which is very essential for Recon processes of ethical hacking. As
the first step of ethical hacking is reconassiace which is gathering information on the target then
filtering of the needed information to find vulnerabilities then perform attack. The project finds
subdomains as many organizations have vulnerable subdomains which can lead entry into the main
domain and leaking of previledged information. The main objective for the creation of the project is
as many do not provide fast collection of the subdomain from the target and filtering and verifying
of the [Link] project provides everything This tool code is written in PYTHON
programming language.
There are various modules in this project which help in achieiving the objective for which the tool is
built. The following modules are:-
⮚ Bruteforce:-Tools use brute force and recursive brute forcing techniques in order to generate
subdomain lists, most of the time combined with word-lists.
⮚ Certspotter:- CertSpotter is a Certificate Transparency log monitor from SSLMate that alerts
you when a SSL/TLS certificate is issued for one of your [Link] Spotter is easier than
other open source CT monitors, since it does not require a database. It's also more robust. Every
time you run Cert Spotter, it scans all browser-recognized. Certificate Transparency logs for
certificates matching domains on your watch list. When Cert Spotter detects a matching
certificate, it writes a report to standard out, which the Cron daemon emails to you. Make sure
you are able to receive emails sent by Cron.
⮚ Quering search engines:-Google hacking techniques are often used to find the subdomains of
any domain [Link] WhoIs lookup,visiting target domain etc.
⮚ Savemap:-The module lets us savemap of the domain like from where it originated how many
servers it has hopped.
⮚ Saving of output file:- after gathering of the information the information can be saved in an
output file
⮚ Verifying the subdomains with SSL certificates.
The scope of the project is that it can be used for reconassiance in ethical hackers, pentesters and security
professionals in a organization and find vulnerable subdomains.
CHAPTER 2
LITERATURE SURVEY
JGI Knowledge Campus School of Computer Science & IT 2018-2019
PYTHON BASED SUBDOMAIN SCANNER TOOL Page 5
easier for you to keep the code base readable and application maintainable, Compatible with
Major Platforms and Systems, Simplify Complex Software Development.
Filter and verify the subdomains :- when we collect a large number of subdomains there are
times when we will not be needing all the subdomains and we also need to verify if all the
subdomain are working or not this can be done with various modules like Certspotter
CertSpotter is a Certificate Transparency log monitor from SSLMate that alerts you when a
SSL/TLS certificate is issued for one of your domains. then we can also scan the subdomains
through fetching SSL/TLS certificates. Filtering of the subdomains can be done by using
Bruteforce which scans subdomains through a particular wordlist thus there are no
unneccesary subdomains scanned.
Fast collecting of the subdomains :- This can be the one of the factors whenever a pentester
or ethical hacker uses the tool to scan subdomains. The fast collection is nothing but at what
rate the subdomains are scanned and results are presented. The of the quickly collection of
subdomains can be done with Bruteforce, recursive bruteforce and full bruteforcing if this
does not quickly collect then VirusTotal subdomain database can be used to collect then by
running a query against.
Simple commands :- This is not an important factor, but still to build the user-friendly tool
which does not confuse the end-user having simple command to scan, stop, using different
modules can help and make the tool popular among the community.
To save the output :- most of the tools do not provide the function of saving the output into a
file which do not help the pentesters or security professionals as the output is needed for
further review with keeping mind of this function we have implemented an option to save the
file in a .txt format
To build a powerful recon tool we used all the existing technologies under the domain some of the
technologies are :-
1. AMASS
Written by Jeff Foley, Amass is one of our favorite tools when it comes to subdomain discovery. It’s
one of the most powerful terminal-based commands there is for gathering and accumulating large
amounts of subdomain data.
Amass uses a variety of subdomain mapping techniques including scrapping, recursive brute force,
reverse NDS sweeping, and machine learning to get the full list of subdomains. It also includes full
integration with the SecurityTrails API for faster passive subdomain reconnaissance.
Installing Amass is easy by using the precompiled packages, or by using snap on Kali Linux and
other popular Linux distros, simply by typing:
snap install amass
Once you get it running, you can start playing. Let’s see how you can use it to find subdomains
3. Knock
Knock is another Python subdomain scanner tool helping infosec researchers with the intel-gathering
process. It works by performing a full DNS zone transfer, and if that fails, it can run a query against
the VirusTotal subdomain database. It’s a simple program that does a great job when you need to
find subdomains. Its only dependency is the python-dnspython package that can be found on all
major Linux distributions. Once you have that sorted out, using it becomes a really simple task.
knockpy [Link]
For this test configured our VirusTotal API key within this file:
knockpy/[Link]
knockpy [Link]
The same scan will also provide other useful details such as IP address, response status, domain
name and remote detected server hostname. You can also launch scans using external wordlists with
the -w option:
4. DNSRecon
DNSRecon is one of the most well-known domain reconnaissance scripts. As with almost every
other one on this list, it’s written in Python. It works by checking all NS records for AXFR zone
transfers, and can be very useful in DNS enumeration for almost any type of records, including
MX, SOA, NS, TXT, SPF and SRV. It also supports wildcard resolution checking andbrute force-
based discovery for A and AAAA type-records with wordlists. But its powers don’t end there—it
can also query Google dorks to fetch indexed subdomains by GoogleBot.
After downloading the DNSRecon package, you’ll need to install a few required packages with
pip:
./[Link] -d [Link]
While the simple -d option can help with your dns discovery, you can also find subdomains by
using a dictionary file with the -D option:
5. Sublist3r
Sublist3r is another Python-based tool that can be used as a massive subdomain scanner. It’s
widely used by bug bounty hunters, as well as blue and red teams across the globe for subdomain data
collection.
By querying search engines such as Bing, Yahoo, Google, Baidu and other 3rd party sources like
Netcraft or VirusTotal subdomain database, it can be one of the most effective and fastest tools
around when you want to find subdomains. And if that’s not enough, you may be surprised to learn
that Sublist3r also supports brute-force attacks with wordlists. Sublist3r minimum requirements are
Python2 or Python3 versions. Python 2 recommended version: 2.7.x ,Python 3 recommended version:
3.4.x. To get started, you’ll need to clone the Git repo, then run the installation for some of the
dependencies with pip:
pip install -r [Link]
That’s it. Now you can perform subdomain scanning tasks:
./[Link] -d [Link]
This subdomain scanner also includes a cool feature that only scans subdomains that have certain
ports open. For example:
python [Link] -d [Link] -p 80,443
This request will perform a subdomain enumeration and filter only those hosts with 80 and 443 ports
open.
6. AltDNS
AltDNS is a subdomain discovery tool based on work with alterations and permutations.
By setting your own wordlist (or using the default wordlist at default altdns/[Link]) of possible
sensitive areas (let’s say dev, staging, test, server, etc.), as well as using a list of confirmed
subdomains, you can run the script to generate both altered or mutated results that may be present in
the domain name. It includes a dataset of 200+ subdomains that can be used to churn out valid
subdomains.
After cloning the git project, dependencies can be resolved quickly by using pip:
pip install -r [Link]
Then you are ready to start using AltDNS:
./[Link] -i [Link] -o data_output -w [Link] -r -s results_output.txt
Note: [Link] is the actual subdomain list you know already exists, and [Link] is
AltDNS’s own wordlist.
CHAPTER 3
REQUIREMENT ANALYSIS
HARDWARE REQUIREMENTS:
⮚ 2GB RAM
⮚ 2GB Required Storage Space
SOFTWARE REQUIREMENTS:
Whitehat Hackers / Ethical Hackers :- White hat hackers choose to use their powers for
good rather than evil. Also known as “ethical hackers,” white hat hackers can sometimes
be paid employees or contractors working for companies as security specialists that
attempt to find security holes via [Link] is done through using Recon tools
White hat hackers employ the same methods of hacking as black hats, with one exception-
they do it with permission from the owner of the system first, which makes the process
completely legal. White hat hackers perform penetration testing, test in-place security
systems and perform vulnerability assessments for companies. There are even courses,
training, conferences and certifications for ethical hacking.
Black Hat Hackers:- Like all hackers, black hat hackers usually have extensive
knowledge about breaking into computer networks and bypassing security protocols. They
are also responsible for writing malware, which is a method used to gain access to these
systems. Their primary motivation is usually for personal or financial gain, but they can
also be involved in cyber espionage, protest or perhaps are just addicted to the thrill of
cybercrime. Black hat hackers can range from amateurs getting their feet wet by spreading
malware, to experienced hackers that aim to steal data, specifically financial information,
personal information and login credentials. Not only do black hat hackers seek to steal
data, they also seek to modify or destroy data as well.
script kiddie:- is someone who lacks programming knowledge and uses existing software
to launch an attack. Often a script kiddie will use these programs without even knowing
how they work or what they do. For example, imagine a child gets their first computer.
The child watches a movie about hacking and then downloads a copy of Kali Linux. They
begin playing with the various programs while searching for online tutorials. At first, they
may be perceived as nothing more than an internet troll or noob, due to their lack of
experience and quickness to brag and boast. Sometimes they will even resort to
cyberstalking or bullying. However , this may simply be a cover for other more nefarious
activity.
Open the [Link] file from the project folder in the linux terminal then go to help command which
gives brief description of the commands that can be used in the tool it also help with what commands
can be used to get the results.
There are command for each and every module that should be used to execute the particular module.
Typing of the wrong command can cause error for the particular module. The error can force you to
restart the tool.
Once all module commands are executed they can be saved for further review the ouput of the file is
saved I [Link] format it is saved in the root directory from where it can be accessed and reviewed.
CHAPTER 4
SYSTEM DESIGN
A context diagram, sometimes called a level 0 data-flow diagram, is drawn in order to define and
clarify the boundaries of the software system. It identifies the flows of information between the system
and external entities.
The level 0 data -flow diagram for the project is user gives command to the terminal in return
terminal gets the results from the server and returns it to the terminal.
4.2.1 ER Diagram
YES
User launches Displays Title and Enter command
space to type python3
PYTHON
[Link] –Help
BASED command
SUBDOMAIN
NO
Hacker Traget
API
Results are
shown/Output
Fig 4 ER Diagram
CHAPTER 5
IMPLEMENTATION AND TESTING
# Recon,
# Bug Bounty Recon, search for subdomains and save in to a file
# Coded By Keshav Ladda
# import go here :)
def banner():
print(R + " \n"
" _____ \n"
" / __ \___ _________ ____ \n"
" / /_/ / _ \/ ___/ __ \/ __ \ \n"
" / _, _/ __/ /__/ /_/ / / / / \n"
" /_/ |_|\___/\___/\____/_/ /_/ V: 0.1 \n"
" \n"
"\n"
" # Coded By keshav #\n"
" " + W)
print(Y + "Recon, a recon tool to find subdomains\n" + W)
##############################################################################
##
# parser error
def parser_error(errmsg):
print("Usage: python3 " + [Link][0] + " [Options] use -h for help")
print("Error: " + errmsg)
[Link](1)
##############################################################################
##
##############################################################################
##
[Link](1)
return host
##############################################################################
##
def queries(target):
print(G + "Enumerating subdomains for " + target + " \n" + W)
[Link](0.1)
print(R + "Searching in SSL Certificates in " + target + " " + W)
[Link](0.1)
print(R + "Searching in CertsPotter in " + target + " " + W)
[Link](0.1)
print(R + "Searching in Virustotal in " + target + " " + W)
[Link](0.1)
# print(R + "Searching in Entrust Datacard in " + target + " " + W)
# [Link](0.1)
print(R + "Searching in ThreatCrowd in " + target + " \n" + W)
[Link](1)
##############################################################################
##
try:
# <Module required> Perform enumerations and network mapping
'hackertarget': tuga_hackertarget.Hackertarget,
'virustotal': tuga_virustotal.Virustotal,
'threatcrowd': tuga_threatcrowd.Threatcrowd,
'ssl': tuga_crt.CRT,
# 'entrust': tuga_entrust.Entrust,
'googlesearch': tuga_googlesearch.GoogleSearch
}
chosenEnums = []
# Default modules
if enum is None:
queries(target)
chosenEnums = [tuga_certspotter.Certspotter, tuga_hackertarget.Hackertarget,
tuga_virustotal.Virustotal,
tuga_threatcrowd.Threatcrowd, tuga_crt.CRT]
else:
for engine in enum:
if [Link]() in supported_engines:
[Link](supported_engines[[Link]()])
# Start the enumeration
enums = [indicate(target, output) for indicate in chosenEnums]
def menu():
banner()
args = parse_args() # args = parser.parse_args()
target = parse_url([Link])
output = [Link]
# port = [Link]
savemap = [Link]
enum = [Link]
threads = [Link]
bruteforce = [Link]
bscan_dns_queries(target)
bscan_whois_look(target)
[Link]
# Recon,
# Bug Bounty Recon, search for subdomains and save in to a file
# Coded By Keshav Ladda
# import go here
#####################################################################################
#############
class TugaBruteScan:
[Link] = target
[Link] = options # default threads 200
self.ignore_intranet = options.i # need more options... not complete
# set threads and count system to 0
self.thread_count = self.scan_count = self.found_count = 0
[Link] = [Link]()
# Resize console
self.console_width = getTerminalSize()[0] - 2 # thanks guys
self.msg_queue = [Link]()
self.STOP_SCAN = False
[Link](target=self._print_msg).start()
self._load_dns_servers() # load DNS servers from a list
# set resolver from [Link]
[Link] = [[Link](configure=False) for _ in range([Link])]
for _ in [Link]:
_.lifetime = _.timeout = 6.0
self._load_next_sub()
[Link] = [Link]()
t = [Link](target=self._load_sub_names)
[Link]()
while not [Link]() > 0 and t.is_alive():
[Link](0.1)
# create a target folder and save results in to a file
if [Link]:
outfile = [Link]
if not [Link]("results/" + [Link]):
[Link]("results/" + [Link])
else:
#pass
outfile = 'results/' + [Link] + "/" + target + '_tugascan.txt' if not options.full_scan else 'results/'
+ [Link] + "/" + target + '_tugascan_full.txt'
#outfile = 'results/' + target + '_tugascan.txt' if not options.full_scan else 'results/' + target +
'_tugascan_full.txt'
[Link] = open(outfile, 'w')
# save ip ,dns.
self.ip_dict = {}
self.last_scanned = [Link]()
self.ex_resolver = [Link](configure=False)
self.start_time = None
#####################################################################################
##########
def _load_dns_servers(self):
# dns_servers.txt
print(G + '[+] Initializing, validate DNS servers ...')
self.dns_servers = []
with open('wordlist/dns_servers.txt') as f:
for line in f:
server = [Link]()
if not server:
continue
while True:
if [Link]() < 50:
t = [Link](target=self._test_dns_servers, args=(server,))
[Link]()
break
else:
[Link](0.1)
[Link]('\n')
print('[+] Found %s available DNS Servers' % self.dns_count)
if self.dns_count == 0:
print('[ERROR] Oops! No DNS Servers available.')
self.STOP_SCAN = True
[Link](-1)
#####################################################################################
##########
#####################################################################################
##########
def _load_sub_names(self):
else:
self.msg_queue.put('[ERROR] Oops! Names file not exists: %s' % [Link])
return
# Wildcard --------------------------------------------------
normal_lines = []
wildcard_lines = []
wildcard_list = []
regex_list = []
lines = set()
with open(_file) as f:
for line in f:
sub = [Link]()
if not sub or sub in lines:
continue
[Link](sub)
sub_queue = [Link]()
for line in wildcard_lines:
sub_queue.put(line)
while sub_queue.qsize() > 0:
item = sub_queue.get()
if [Link]('{alphnum}') >= 0:
for _letter in 'abcdefghijklmnopqrstuvwxyz0123456789':
sub_queue.put([Link]('{alphnum}', _letter, 1))
elif [Link]('{alpha}') >= 0:
for _letter in 'abcdefghijklmnopqrstuvwxyz':
sub_queue.put([Link]('{alpha}', _letter, 1))
elif [Link]('{num}') >= 0:
for _letter in '0123456789':
sub_queue.put([Link]('{num}', _letter, 1))
else:
lst_subs.append(item)
if len(lst_subs) >= GROUP_SIZE:
while [Link]() > 10000:
[Link](0.1)
[Link](lst_subs)
lst_subs = []
if lst_subs:
[Link](lst_subs)
#####################################################################################
##########
def _load_next_sub(self):
self.msg_queue.put('[+] Load second list name...')
next_subs = []
# Wildcard
with open(_file) as f:
for line in f:
sub = [Link]()
if sub and sub not in next_subs:
tmp_set = {sub}
while len(tmp_set) > 0:
item = tmp_set.pop()
if [Link]('{alphnum}') >= 0:
for _letter in 'abcdefghijklmnopqrstuvwxyz0123456789':
tmp_set.add([Link]('{alphnum}', _letter, 1))
elif [Link]('{alpha}') >= 0:
for _letter in 'abcdefghijklmnopqrstuvwxyz':
#####################################################################################
##########
def _update_scan_count(self):
self.last_scanned = [Link]()
self.scan_count += 1
#####################################################################################
##########
def _update_found_count(self):
# no need to use a lock
self.found_count += 1
#####################################################################################
##########
def _print_msg(self):
while not self.STOP_SCAN:
try:
_msg = self.msg_queue.get(timeout=0.1)
except:
continue
if _msg == 'status':
msg = 'Found %s subdomains | %s groups left | %s scanned in %.1f seconds| %s threads' % (
self.found_count, [Link](), self.scan_count, [Link]() - self.start_time,
self.thread_count)
[Link]('\r' + ' ' * (self.console_width - len(msg)) + msg)
elif _msg.startswith('[+] Check DNS Server'):
[Link]('\r' + _msg + ' ' * (self.console_width - len(_msg)))
else:
[Link]('\r' + _msg + ' ' * (self.console_width - len(_msg)) + '\n') # print subdomains in
# console
[Link]()
#####################################################################################
##########
def _scan(self):
thread_id = int([Link]().getName())
[Link][thread_id].nameservers = [self.dns_servers[thread_id % self.dns_count]]
_lst_subs = []
[Link]()
self.thread_count += 1
[Link]()
try:
cur_sub_domain = sub + '.' + [Link]
self._update_scan_count()
self.msg_queue.put('status')
try:
answers = [Link][thread_id].query(cur_sub_domain)
except [Link] as e:
answers = self.ex_resolver.query(cur_sub_domain)
is_wildcard_record = False
if answers:
ips = ', '.join(sorted([[Link] for answer in answers]))
if ips in ['[Link]', '[Link]', '[Link]']:
break
if is_wildcard_record:
break
try:
[Link][thread_id].query('lordneostark.' + cur_sub_domain)
except [Link] as e:
_lst = []
if_put_one = ([Link]() < self.dns_count * 5)
for i in self.next_subs:
_lst.append(i + '.' + sub)
if if_put_one:
[Link](_lst)
_lst = []
elif len(_lst) >= 10:
[Link](_lst)
_lst = []
if _lst:
[Link](_lst)
except:
pass
break
except ([Link], [Link]) as e:
break
except ([Link], [Link], [Link]) as e:
_sub_timeout_count += 1
if _sub_timeout_count >= 6: # give up
break
except Exception as e:
with open('[Link]', 'a') as errFile:
[Link]('%s [%s] %s %s\n' % (threading.current_thread, type(e), cur_sub_domain, e))
break
[Link]()
self.thread_count -= 1
[Link]()
self.msg_queue.put('status')
#####################################################################################
##########
def run(self):
self.start_time = [Link]()
for i in range([Link]):
try:
t = [Link](target=self._scan, name=str(i)) # pass to def _scan()
[Link](True)
[Link]()
except:
pass
while self.thread_count > 0:
try:
[Link](0.1) # time sleep 1, try to change to 0.1 or 0
except KeyboardInterrupt as e:
msg = (R + '[WARNING] User aborted, wait all slave threads to exit...' + W)
[Link]('\r' + msg + ' ' * (self.console_width - len(msg)) + '\n\r')
[Link]()
self.STOP_SCAN = True
self.STOP_SCAN = True
#####################################################################################
##########
[Link]
# Recon - funcions, write by Keshav Ladda
# Recon,
# Bug Bounty Recon, search for subdomains and save in to a file
# Coded By keshav ladda
import sys
import [Link]
import webbrowser
import [Link]
import urllib3
import os
from pathlib import Path
# Colors
global G, Y, B, R, W
G = '\033[92m' # green
Y = '\033[93m' # yellow
B = '\033[94m' # blue
R = '\033[91m' # red
W = '\033[0m' # white
'''
# write subdomains to a file
def write_file(subdomains, output_file, target):
# saving subdomains results to output file
if not [Link]("results/" + target):
[Link]("results/" + target)
else:
pass
with open("results/" + target + "/" + output_file, 'a') as fp:
[Link](subdomains + '\n')
[Link]()
#DeleteDuplicate(target, subdomains)
#DeleteDuplicate(target, subdomains)
def mapping_domain(target):
try:
try:
[Link](f"[Link] + ".png",
f"results/{target}/{target}.png")
except [Link] as e:
print("", [Link])
my_file = Path(f"results/{target}/{target}.png")
if my_file.is_file():
[Link](f"results/{target}/{target}.png")
else:
print(Y + "\nOops! The map file was not generated. Try again...\n" + W)
except PermissionError:
print("You dont have permission to save a file, use sudo su")
# Future implementation
def Convert(subdomains):
subdomains_list = list([Link](","))
return subdomains_list
[Link]
import [Link] # dnspython
import whois
# Import internal
from functions import G, W, R, Y
#################################################################################
##############
def bscan_dns_queries(target):
print(G + "\n[+] DNS queries...\n" + W)
print(G + "**************************************************************\n" + W)
try:
for qtype in 'A', 'AAAA', 'MX', 'NS', 'TXT', 'SOA', 'CERT', 'HINFO', 'MINFO', 'TLSA', 'SPF':
answer = [Link](target, qtype, raise_on_no_answer=False, lifetime=10)
if [Link] is not None:
print([Link], '\n')
else:
pass
except Exception as e:
pass
print(G + "**************************************************************\n" + W)
#################################################################################
##############
def bscan_whois_look(target):
#domain = [Link](target)
#print(domain.__dict__, "\n")
#print([Link], "\n")
#print("Domain expiration: ", domain.expiration_date, "\n")
#print(G + "**************************************************************\n" + W)
pass
#################################################################################
##############
def is_intranet(ip):
ret = [Link]('.')
if not len(ret) == 4:
return True
if ret[0] == '10':
return True
if ret[0] == '172' and 16 <= int(ret[1]) <= 32:
return True
if ret[0] == '192' and ret[1] == '168':
return True
return False
#################################################################################
##############
Console [Link]
#### getTerminalSize()
__all__ = ['getTerminalSize']
def getTerminalSize():
import platform
current_os = [Link]()
tuple_xy = None
tuple_xy = _getTerminalSize_linux()
if tuple_xy is None:
print ("default")
return tuple_xy
def _getTerminalSize_linux():
def ioctl_GWINSZ(fd):
try:
except:
return None
return cr
if not cr:
try:
fd = [Link]([Link](), os.O_RDONLY)
cr = ioctl_GWINSZ(fd)
[Link](fd)
except:
pass
if not cr:
try:
cr = (env['LINES'], env['COLUMNS'])
except:
return None
if __name__ == "__main__":
[Link]
# import modules
import time
import requests
class Certspotter:
[Link] = target
[Link] = output
self.module_name = "CertSpotter"
[Link] = "certspotter"
[Link] = self.engine_url()
[Link]([Link], output, target)
if [Link] is not None:
DeleteDuplicate([Link] + '_' + [Link], target)
def engine_url(self):
try:
url = f'[Link]
domain={[Link]}&include_subdomains=true&expand=dns_names'
response = [Link](url, headers=tuga_useragents.useragent())
except [Link]:
pass
return response
try:
if [Link]:
print(f"\nSaving result... {[Link] + '_' + [Link]}")
except:
pass
if not subdomains:
print(f"[x] No data found for {[Link]} using CertSpotter.")
else:
print(G + f"\n[**] TugaRecon is complete. CertSpotter: {subdomainscount} subdomains
have been found in %s seconds" % (
[Link]() - start_time) + W)
[Link]
# import modules
import time
import requests
# Import internal
from modules import tuga_useragents
from functions import write_file
from functions import G, W
from functions import DeleteDuplicate
class Hackertarget:
[Link] = target
[Link] = output
self.module_name = "HackerTarget"
[Link] = "hackertarget"
[Link] = self.engine_url()
[Link]([Link], output, target)
def engine_url(self):
url = f"[Link]
response = [Link](url, headers=tuga_useragents.useragent())
return response
try:
while subdomainscount < 10000:
subdomainscount = subdomainscount + 2
print(f"[*] {subdomains[subdomainscount]}")
# Write to a file
if [Link] is not None:
if [Link]:
print(f"\nSaving result... {[Link] + '_' + [Link]}")
except IndexError:
pass
if not subdomains:
print(f"[x] No data found for {[Link]} using HackerTarget.")
else:
print(
G + f"\n[**] Recon is complete. HackerTarget: {int((subdomainscount / 2) - 1)}
subdomains have been found in %s seconds" % (
[Link]() - start_time) + W)
[Link]
# Recon,
# Bug Bounty Recon, search for subdomains and save in to a file
# Coded By keshav ladda
# import go here
import requests
import sys
import re
import time
class GoogleSearch:
[Link] = target
[Link] = output
self.module_name = "Google Search"
[Link] = "googlesearch"
[Link] = set()
############################################################################
###################
############################################################################
###################
page_number = page_number + 10
if html.status_code == 200:
# parsing the fetched html in the response using lxml parser in beautiful soup
soup = BeautifulSoup([Link], 'lxml')
for i in a:
# extracting the href attribute for the link to the search results
k = [Link]('href')
# exception handling code to prevent running into erros
try:
# search for the pattern of a url to prevent unneccessary attributes in the result
using re module
m = [Link]("(?P<url>https?://[^\s]+)", k)
# fetching only the url part in the array
n = [Link](0)
# splitting the url up to the parameters part to get only the necessary url
rul = [Link]('&')[0]
# print(rul)
# parsing the url to divide it into components using urlparse
result = urlparse(rul)
# print(result)
domain = '{[Link]}://{[Link]}/'.format(uri=result)
# checking if the fetched url not belongs to target if true skip the url
# print("teste============== ", domain)
if not ([Link](f"{[Link]}", domain)):
continue
# else add it to the result list
else:
# print("teste==============> ", domain)
url_a = [Link](r"https?://(www\.)?")
url1 = url_a.sub('', domain).strip().strip('/')
# print("==============> ", url1)
if url1 not in g_clean:
# print("teste: s ", url1)
g_clean.append(url1)
else:
continue
except:
continue
finally:
self.get_url(g_clean, page_number)
if [Link]:
print(f"\nSaving result... {[Link] + '_' + [Link]}")
print(G + "\n[**] TugaRecon is complete." + W)
print(G + "Please wait some time... before doing a new search with this module\n" + W)
[Link]
import time
import requests
class Threatcrowd:
[Link] = target
[Link] = output
self.module_name = "Threat Crowd"
[Link] = "threatcrowd"
[Link] = self.engine_url()
[Link]([Link], output, target)
if [Link] is not None:
DeleteDuplicate([Link] + '_' + [Link], target)
def engine_url(self):
try:
url = f'[Link]
response = [Link](url, headers=tuga_useragents.useragent())
except [Link]:
pass
return response
try:
while subdomainscount < 500:
subdomains = [Link]()["subdomains"][subdomainscount]
subdomainscount = subdomainscount + 1
print(f"[*] {subdomains}")
if [Link]:
print(f"\nSaving result... {[Link] + '_' + [Link]}")
except IndexError:
pass
if not subdomains:
print(f"[x] No data found for {[Link]} using Threat Crowd.")
[Link]
import time
import requests
class Virustotal:
[Link] = target
[Link] = output
self.module_name = "VirusTotal"
[Link] = "Virustotal"
[Link] = self.engine_url()
[Link]([Link], output, target)
if [Link] is not None:
DeleteDuplicate([Link] + '_' + [Link], target)
def engine_url(self):
try:
url = f'[Link]
response = [Link](url, headers=tuga_useragents.useragent())
except [Link]:
pass
return response
try:
while subdomainscount < 40:
subdomains = [Link]()["data"][subdomainscount]["id"]
if not subdomains:
print(f"[x] Oops! No data found for {[Link]} using SSL Certificates.")
else:
pass
subdomainscount = subdomainscount + 1
print(f"[*] {subdomains}")
if [Link]:
print(f"\nSaving result... {[Link] + '_' + [Link]}")
except IndexError:
pass
print(
G + f"\n[**] TugaRecon is complete. VirusTotal: {subdomainscount} subdomains have
been found in %s seconds" % (
[Link]() - start_time) + W)
if not subdomains:
print(f"[x] No data found for {[Link]} using VirusTotal.")
[Link]
# Recon,
# Bug Bounty Recon, search for subdomains and save in to a file
# Coded By keshav ladda
# import go here
import requests
import time
import re
class Entrust:
[Link] = target
[Link] = output
self.module_name = "Entrust Datacard"
[Link] = "entrust"
[Link] = 0
[Link].urllib3.disable_warnings()
[Link] = self.engine_url()
[Link] = [Link]([Link])
#print("[+]: Parsed %s domain(s) from list." % len([Link]))
[Link]([Link], [Link], [Link])
if [Link] is not None and [Link] != 0:
DeleteDuplicate([Link] + '_' + [Link], target)
else:
pass
def engine_url(self):
try:
url = f'[Link]
fields=subjectDN&domain={[Link]}&includeExpired=true&exactMatch=false&limit=5000'
response = [Link](url, headers=tuga_useragents.useragent(), verify = False)
except [Link]:
pass
return response
if match:
for domain in match:
# The following line avoids adding wildcard domains, as they will not resolve.
if ((domain[0] not in domains) and not ([Link]("^\*\.", domain[0]))):
[Link](domain[0])
return domains
if [Link]:
#####################################################################################
####################
[Link]
class modules:
def __init__(self, target, enum):
[Link] = target
[Link] = enum
try:
bscan_dns_queries([Link])
bscan_whois_look([Link])
}
chosenEnums = []
if enum is None:
queries(target)
else:
[Link]
import time
import requests
class CRT:
[Link] = target
[Link] = output
self.module_name = "SSL Certificates"
[Link] = "crt"
[Link] = self.engine_url()
[Link]([Link], output, target)
if [Link] is not None and [Link] != 0:
def engine_url(self):
try:
url = f"[Link]
response = [Link](url, headers=tuga_useragents.useragent())
return response
except [Link]:
pass
try:
while [Link] < 10000:
subdomains = [Link]()[[Link]]["name_value"]
if not subdomains:
print(f"[x] Oops! No data found for {[Link]} using SSL Certificates.")
else:
[Link] = [Link] + 1
if "@" in subdomains: # filter for emails
pass
else:
print(f"[*] {subdomains}")
CHAPTER 6
TESTING
Software testing is more than just error detections. Testing software is operating the software under
controlled conditions.
Verification: it is checking or testing of items including software, for performance and consistency
by evaluating the results against pre-specified requirements.
Error detection: testing should intentionally attempt to make things go wrong to determine when
things happen they shouldn’t or things don’t happen when they should.
Validation: Validation looks at the system corrections, that is the process of checking that what has
been specified is what the user actually wanted.
1. Unit Testing
This type of testing is performed by developers before the setup is handed over to the testing team to
formally execute the test cases. Unit testing is performed by the respective developers on the
individual units of source code assigned areas. The developers use test data that is different from the
test data of the quality assurance team. The goal of unit testing is to isolate each part of the program
and show that individual parts are correct in terms of requirements and functionality.
2. Integration Testing
Integration testing is defined as the testing of combined parts of an application to determine if they
function correctly. Integration testing can be done in two ways: Bottom-up integration testing and
Top-down integration testing.
3. Validation Testing
Software testing is one element of a broader topic that is often referred to as verification and
validation. Verification refers to the set of activities that ensure that software correctly implements a
specific function. Validation refers to a different set of activities that ensure that has been built is
traceable to customer requirements. Verification and Validation encompasses a wide array of SQA
activities that include formal technical reviews, quality and configuration audits, performance
monitoring, stimulation, feasibility study, documentation review and installation testing.
4. Performance Testing
Performance testing is the process of determining the speed or effectiveness of a computer, network,
software program or device. This process can involve quantitative tests done in a lab, such as
measuring the response time or the number of MIPS (millions of instructions per second) at which a
system functions. Qualitative attributes such as reliability, scalability and interoperability may also be
evaluated. Performance testing can verify that a system meets the specifications claimed by its
manufacturer or vendor. The process can compare two or more devices or programs in terms of
parameters such as speed, data transfer rate, bandwidth, throughput, efficiency or reliability.
Test case 1:
Test case 2:
Test case 3:
Test Case 4:
CHAPTER 7
RESULTS AND DISCUSSIONS
7.1 Screenshots
7.1.1 Screenshot 1
7.1.2 Screenshot 2
7.1.3 Screenshot 3
7.1.4 Screenshot 4
7.1.5 Screenshot 5
7.1.6 Screenshot 6
7.1.7 Screenshot 7
7.1.8 Screenshot 8
7.1.9 Screenshot 9
7.1.10 Screenshot 10
7.1.11 Screenshot 11
7.1.12 Screenshot 12
7.1.13 Screenshot 13
7.1.14 Screenshot 14
7.1.15 Screenshot 15
7.1.16 Screenshot 16
7.1.17 Screenshot 17
7.1.18 Screenshot 18
7.1.19 Screenshot 19
7.1.20 Screenshot 20
7.1.21 Screenshot 21
7.1.22 Screenshot 22
7.1.23 Screenshot 23
7.1.24 Screenshot 24
7.1.25 Screenshot 25
7.1.26 Screenshot 26
7.1.27 Screenshot 27
7.1.28 Screenshot 28
7.1.29 Screenshot 29
7.1.30 Screenshot 30
7.1.31 Screenshot 31
First the project folder is opened i.e [Link] and then select the [Link] file right click on the file
and select the option open with terminal the terminal is opened with recon folder.
Next step is executing the command python3 [Link] –help this will give brief information on the
commands that can be used to enumerate the subdomains like –bruteforce, --certspotter, --savemap
and –output. There are example commands which can be used to get the gist of the the tool.
Then next step is to start enumerating any domain, command is python3 [Link] -d [Link]
this will give the result of all the subdomains present in the Domain.
Next step is to check the subdomains with SSL command is python3 [Link] -d [Link] –
enum ssl this gives the result of all the subdomains that have the SSL certificates.
Next step is to get the scanned subdomains checked through the Certspotter and saving the map the
command is python3 [Link] -d [Link] –enum certspotter –savemap this gives the result of
all the subdomains that have passd through the certspotter. Saves the image of the map in the results
folder in the project folder.
Next step is find all subdomains through bruteforceing it is nothing but to find all subdomains
specific to the wordlist the command is python3 [Link] -d [Link] --bruteforce this gives
result of all the subdomains that are matched from the wordlist.
Next step is doing full bruteforce that is to scan the subdomains against two or three wordlist the
command is python3 [Link] -d [Link] -b –full this gives the result of all the subdomains
that are matching the wordlist.
Next step is to save all the results that are collected through the execution of the commands the
command to save the result is python3 [Link] -d [Link] -o –[Link] this gives the result
of all the modules like certspotter, hackerstarget etc into a document i.e [Link].
above are all the obervations and their results that have been observed during the running and using of the
tool
CHAPTER 8
CONCLUSIONS AND FUTURE SCOPE
8.1 conclusion
From this project we can conclude that this program is very useful to ethical hacker, pentesters
as it provides more convenience than the manual work. It provides easy methods to retrieve
information for the users. It is much fast and more efficient as the various modules in the tool help to
provide the results. The program can be used per the requirement of the user as it is very easy to
understand.
To conclude, this project “PYTHON BASED SUBDOMAIN SCANNER TOOL” is developed using
PYTHON programming. This project helps users to gather information of the target Domain. It can
implement its functions easily and fast. It is a lightweight tool. Thus, this project entitled above
includes all the above-mentioned features and is confirmed that it is up to the specifications entitled
for the project.
8.2 Limitations
As no project is perfect there are certains limitations of the project the following are the
limitations of the project:-
The main disadvantage of the project is it is non GUI the project is command line which
sometimes can create problem for the users
There will be needing of more modules to scan the subdomains like dns zone transfers etc
Lack of features,Adding more features like ARP poisoning, Sinffing of the network etc that can
be useful for the project
References
[1]. [Link]
[2].[Link]
omain_Enumeration_and_Analysis
[3]. [Link]
[4].[Link]
[5]. [Link]
CertSpotter focuses on verifying SSL certificates, ensuring domain legitimacy, while Hackertarget specializes in enumerating subdomains through different methods. Their integration in the Python Based Recon Tool allows for comprehensive domain analysis by combining verification and discovery in a single streamlined process .
By integrating multiple techniques, such as brute force, CertSpotter, and search engine querying, the Python Based Recon Tool allows ethical hackers to comprehensively assess a domain's security. This combinatory approach uncovers more potential vulnerabilities by leveraging diverse methodologies, enhancing the scope and accuracy of security assessments .
The Python Based Recon Tool integrates various techniques, such as brute force with improved wordlists, and querying search engines to speed up subdomain enumeration. It consolidates methods into a single tool, avoiding the need to switch between multiple tools, thus optimizing performance and reducing scan times .
Savemap is critical for understanding the path a domain has taken, showing how many servers it has hopped through to reach its destination. This information is crucial for ethical hacking as it helps in identifying weak links in the network and understanding potential points of exploitation .
CertSpotter is considered more robust compared to other open source Certificate Transparency monitors due to its lack of database requirement, making it easier to use. It efficiently scans all browser-recognized Certificate Transparency logs and outputs a report without the need for complex setups .
The mechanisms for scanning and verifying domain information can be applied in fields like data collection and analysis, network administration, and information systems monitoring. These applications can benefit from the tool’s capacity for efficient data gathering and verification, facilitating better management and security of complex systems .
Verifying subdomains with SSL certificates is essential as it helps ensure that the subdomains are legitimate and not compromised or fraudulent. This verification process adds an additional layer of security, reducing the risk of attacks or data breaches through unverified subdomains .
A lightweight and simple infrastructure ensures that the Python Based Recon Tool operates efficiently on Kali Linux by minimizing resource consumption and preventing performance bottlenecks. This aspect is crucial for maintaining optimal speed and responsiveness during extensive reconnaissance operations .
The Python Based Recon Tool distinguishes itself by consolidating techniques such as brute force, CertSpotter, and search engine querying into a single tool, unlike Amass and dnsrecon, which focus on individual techniques. This consolidation improves efficiency and reduces the complexity of the reconnaissance process .
Python is suited for developing a subdomain scanner due to its simple syntax, readability, and maintainability. These characteristics facilitate error-free coding and implementation, making it ideal for creating tools that need to be robust and adaptable in cybersecurity applications .









