The script will use a list of potential subdomains and prepends them to the domain name provided via a command-line argument.
The script then tries to connect to the subdomains and assumes the ones that accept the connection exist.
import requests import sys sub_list =open("subdomains.txt").read()subdoms = sub_list.splitlines()for sub in subdoms: sub_domains =f"http://{sub}.{sys.argv[1]}"try: requests.get(sub_domains)except requests.ConnectionError:passelse:print("Valid domain: ",sub_domains)
the script will search for a file named "subdomains.txt". The simplest way is to use a wordlist located in the same directory as the Python script, but any wordlist can be used. The wordlist should have possible subdomains listed one per line
Directory Enumeration
The script will use a list of potential subdomains and prepends them to the domain name provided via a command-line argument.
The script then tries to connect to the subdomains and assumes the ones that accept the connection exist.
import requests import sys sub_list =open("subdomains.txt").read()subdoms = sub_list.splitlines()for sub in subdoms: sub_domains =f"http://{sub}.{sys.argv[1]}"try: requests.get(sub_domains)except requests.ConnectionError:passelse:print("Valid domain: ",sub_domains)
Directory Enumeration
The following code will build a simple directory enumeration tool.
This script takes an approach based on a for loop and passes all "404" responses.
Network Scanner
Python can be used to build a simple ICMP (Internet Control Message Protocol) scanner to identify potential targets on the network. However, ICMP packets can be monitored or blocked as the target organization would not expect a regular user to “ping a server”. On the other hand, systems can be configured to not respond to ICMP requests. These are the main reasons why using the ARP (Address Resolution Protocol) to identify targets on the local network is more effective.