Skip to content

Commit ccdc302

Browse files
committed
add dns enumeration tutorial
1 parent 05a28eb commit ccdc302

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ This is a repository of all the tutorials of [The Python Code](https://www.thepy
3838
- [How to Make a MAC Address Changer in Python](https://www.thepythoncode.com/article/make-a-mac-address-changer-in-python). ([code](ethical-hacking/mac-address-changer))
3939
- [How to Make a Password Generator in Python](https://www.thepythoncode.com/article/make-a-password-generator-in-python). ([code](ethical-hacking/password-generator))
4040
- [How to Make a Ransomware in Python](https://www.thepythoncode.com/article/make-a-ransomware-in-python). ([code](ethical-hacking/ransomware))
41+
- [How to Perform DNS Enumeration in Python](https://www.thepythoncode.com/article/dns-enumeration-with-python). ([code](ethical-hacking/dns-enumeration))
4142

4243
- ### [Machine Learning](https://www.thepythoncode.com/topic/machine-learning)
4344
- ### [Natural Language Processing](https://www.thepythoncode.com/topic/nlp)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [How to Perform DNS Enumeration in Python](https://www.thepythoncode.com/article/dns-enumeration-with-python)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import dns.resolver
2+
3+
# Set the target domain and record type
4+
target_domain = "thepythoncode.com"
5+
record_types = ["A", "AAAA", "CNAME", "MX", "NS", "SOA", "TXT"]
6+
# Create a DNS resolver
7+
resolver = dns.resolver.Resolver()
8+
for record_type in record_types:
9+
# Perform DNS lookup for the specified domain and record type
10+
try:
11+
answers = resolver.resolve(target_domain, record_type)
12+
except dns.resolver.NoAnswer:
13+
continue
14+
# Print the answers
15+
print(f"{record_type} records for {target_domain}:")
16+
for rdata in answers:
17+
print(f" {rdata}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dnspython

0 commit comments

Comments
 (0)