-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdns_enum_automation.py
More file actions
144 lines (114 loc) · 5.18 KB
/
Copy pathdns_enum_automation.py
File metadata and controls
144 lines (114 loc) · 5.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python3
import os
import argparse
from concurrent.futures import ThreadPoolExecutor, as_completed
"""
STEVE SPLASH CODES (@whiteshepherdsec | @whiteshepherdse)
THIS SCRIPT IS CREATED FOR GOOD USE ONLY!
REMEMBER TO BE ETHICAL AS PERFORMING ATTACKS IN AN UNAUTHORIZE ENVIRONMENT CAN PUT IN JAIL! USE AT YOUR OWN RISK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
exit(;)
2024-17-10 05:33 GMT/UTC +1:00
"""
"""
DNS Enumeration Script
This script automates the process of running various DNS enumeration tools on a list of target domains.
It uses multithreading to improve performance and organizes the output into separate directories for each tool.
Usage:
python script.py -i <input_file> -o <output_directory> [-t | --threads <num_threads>]
Arguments:
-i, --input File containing a list of target domains (one per line). This is a required argument.
-o, --output Directory where the results will be stored. This is a required argument.
--threads Number of concurrent threads to use for processing (default: 100).
Output Structure:
The output will be organized into the specified output directory, with subdirectories for each DNS tool:
- dnsrecon/
- dnsenum/
- dnsmap/
- dig/
- whois/
- nslookup/
Each subdirectory will contain the results for the corresponding tool, named in the format:
<target>_<tool>.extension
Dependencies:
- dnsrecon
- dnsenum
- dnsmap
- dig
- whois
- nslookup
Example:
python script.py -i targets.txt -o dns_results --threads 50
Note:
Ensure that the required DNS tools are installed and accessible in your system's PATH.
"""
def read_targets(target_file):
with open(target_file, 'r', encoding='utf-8') as file:
return [target.strip() for target in file.readlines()]
def run_dnsrecon(target, output_folder):
output_file = os.path.join(output_folder, 'dnsrecon', f'{target}_dnsrecon.json')
command = f'dnsrecon -d {target} -a -j {output_file}'
print(f'[INFO] Running dnsrecon on {target}')
os.system(command)
def run_dnsenum(target, output_folder):
output_file = os.path.join(output_folder, 'dnsenum', f'{target}_dnsenum.txt')
command = f'dnsenum --dnsserver 8.8.8.8 --output {output_file} {target}'
print(f'[INFO] Running dnsenum on {target}')
os.system(command)
def run_dnsmap(target, output_folder):
output_file = os.path.join(output_folder, 'dnsmap', f'{target}_dnsmap.txt')
command = f'dnsmap {target} -w subdomains.txt -r {output_file}'
print(f'[INFO] Running dnsmap on {target}')
os.system(command)
def create_output_folder(output_folder):
if not os.path.exists(output_folder):
os.makedirs(output_folder)
print(f'[INFO] Created output directory: {output_folder}')
# Create subdirectories for each DNS tool
tools = ['dnsrecon', 'dnsenum', 'dnsmap', 'dig', 'whois', 'nslookup']
for tool in tools:
tool_folder = os.path.join(output_folder, tool)
if not os.path.exists(tool_folder):
os.makedirs(tool_folder)
print(f'[INFO] Created output directory: {tool_folder}')
def run_other_dns_tools(target, output_folder):
# Create output file names in their respective folders
dig_output = os.path.join(output_folder, 'dig', f'{target}_dig.txt')
whois_output = os.path.join(output_folder, 'whois', f'{target}_whois.txt')
nslookup_output = os.path.join(output_folder, 'nslookup', f'{target}_nslookup.txt')
# Run dig
print(f'[INFO] Running dig on {target}')
os.system(f'dig {target} > {dig_output}')
# Run whois
print(f'[INFO] Running whois on {target}')
os.system(f'whois {target} > {whois_output}')
# Run nslookup
print(f'[INFO] Running nslookup on {target}')
os.system(f'nslookup {target} > {nslookup_output}')
def worker(target, output_folder):
run_other_dns_tools(target, output_folder)
run_dnsrecon(target, output_folder)
run_dnsenum(target, output_folder)
run_dnsmap(target, output_folder)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run DNS enumeration tools on specified targets.')
parser.add_argument('-i', '--input', type=str, required=True, help='File containing list of target domains')
parser.add_argument('-o', '--output', type=str, required=True, help='Output folder for results')
parser.add_argument('-t', '--threads', type=int, default=100, help='Number of concurrent threads (default: 100)')
args = parser.parse_args()
target_file = args.input
output_folder = args.output
num_threads = args.threads
create_output_folder(output_folder)
targets = read_targets(target_file)
with ThreadPoolExecutor(max_workers=num_threads) as executor:
futures = {executor.submit(worker, target, output_folder): target for target in targets}
for future in as_completed(futures):
target = futures[future]
try:
future.result() # Wait for the worker to finish
print(f'[INFO] Completed tasks for {target}')
except Exception as e:
print(f'[ERROR] An error occurred for {target}: {e}')
print('[INFO] All DNS tasks completed.')
# how to run
# python script.py -i targets.txt -o dns_results --threads 50