Find all Hidden Subdomains of Domains with Python
A subdomain is a part of your domain or any other origination. What if you want to find someone's subdomains? Find all Hidden Subdomains of Domains with Python A subdomain is a part of your domain or any other origination. What if you
A subdomain is a part of your domain or any other origination. What if you want to find someone's subdomains?
Find all Hidden Subdomains of Domains with Python
A subdomain is a part of your domain or any other origination. What if you want to find someone's subdomains?
There are a lot of tools that can help you to find some of them. DnsMapper is a famous tool that also helps Penetration testers find sub-domains using Python and Bash DNS Resolver Library.
Kali has a lot of tools for this. But the problem with DnsMapper is that sometimes it does not work properly.
The script I wrote is working well but do remember its has still one issue — sometimes it Blacklists your IP (Internet Protocol address). You can get past this if you use a VPN (Virtual Private Network). A VPN would help you protect your real IP address.
There are 2 types of scripts that can help save you some time
Disclaimer: This script looks small but it can Alarm Firewall or WAF (Web Application Firewalls ).
Disclaimer 2 :The information provided here is for general informational purposes only and should not be construed as professional advice. Users are responsible for independently verifying the accuracy and applicability of the information provided.
How will it work?
This script will use the { dictionary Attack method } that will use a bunch of name lists from a txt file that I will test.
Requirements: Python, Linux, Windows, or MacOS
In Linux, you should give root access for this file:
chmod -R 777 folder_nameJust replace it with your script in the folder.
If it’s just a simple file in Python use:
chmod -R +rwx filename Scripts 1
import dns.resolver
def get_possible_subdomains(domain):
subdomains = []
with open("subdomains.txt") as f:
subdomains = [line.strip() + "." + domain for line in f]
print(f"[+] Possible subdomains for {domain}:")
for subdomain in subdomains:
try:
answers = dns.resolver.resolve(subdomain, 'A')
print(f" {subdomain}")
except dns.resolver.NoAnswer:
pass
except dns.resolver.NXDOMAIN:
pass
if __name__ == '__main__':
domain = input("Enter a domain name: ")
get_possible_subdomains(domain)This script will provide you only subdomains of the domain. I have used this script on Kali Linux. If you don't have Kali installed on your system, you can use any Linux Distro. I have used this on the sub-Operating System.
import dns.resolver
def get_possible_subdomains(domain):
subdomains = []
with open("subdomains.txt") as f:
subdomains = [line.strip() + "." + domain for line in f]
print(f"[+] Resolved subdomains for {domain}:")
for subdomain in subdomains:
try:
answers = dns.resolver.resolve(subdomain, 'A')
print(f" {subdomain} resolved to {answers[0]}")
except dns.resolver.NoAnswer:
pass
except dns.resolver.NXDOMAIN:
pass
if __name__ == '__main__':
domain = input("Enter a domain name: ")
get_possible_subdomains(domain)If you found this helpful, please share it with friends who want to learn.
In Plain English 🚀
Thank you for being a part of the In Plain English community! Before you go:
- Be sure to clap and follow the writer ️👏️️
- Follow us: X | LinkedIn | YouTube | Discord | Newsletter
- Visit our other platforms: CoFeed | Differ
- More content at PlainEnglish.io