Arishti

Blog by Community Members
Enumerating Subdomains with simple Python Script

Hello Reader, Hope you are doing good. So, In this tutorial we are going to make a simple python script which enumerates subdomain. In this script we will use requests module of python so if it’s not installed in your system install it by typing command apt-get install requests on your terminal.

We will be using a wordlist which you can find here

import requests 
import sys 

sub_list = open("subdomains-1000.txt").read() 
subs = sub_list.splitlines()

for sub in subs:
    url_to_check = f"http://{sub}.{sys.argv[1]}" 

    try:
        requests.get(url_to_check)
    
    except requests.ConnectionError: 
        pass
    
    else:
        print("Valid domain: ",url_to_check)

Now save this file as subenum.py and wordlist in same folder and open your terminal in that folder.

Now type python3 subenum.py example.com to execute your script.

Leave comment

Your email address will not be published. Required fields are marked with *.