-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmsdnsscan.py
383 lines (360 loc) · 23.7 KB
/
msdnsscan.py
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
import dns.resolver
import dns.zone
import sys
from colorama import Fore, Style, init
import requests
import argparse
import textwrap
import os
from datetime import datetime
import urllib.request
from pathlib import Path
import concurrent.futures
def options():
opt_parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, epilog=textwrap.dedent(
'''Example: python3 msdnsscan.py -d example.com -a
Example: python3 msdnsscan.py -d example.com -s
'''))
requiredNamed = opt_parser.add_argument_group('required arguments')
requiredNamed.add_argument(
'-d', '--domain', help='Specifies the domain name to test', required=True)
opt_parser.add_argument(
'-a', '--all', help='Scans for DNS records, zone transfers, and subdomains', action='store_true')
opt_parser.add_argument(
'-dn', '--dns', help='Checks A, AAAA, NS, CNAME, MX, PTR, SOA, SRV, and TXT records', action='store_true')
opt_parser.add_argument(
'-s', '--subdom', help='Includes check for subdomains in scan', action='store_true')
opt_parser.add_argument(
'-z', '--zone', help='Includes check for zone transfers in scan', action='store_true')
opt_parser.add_argument(
'-e', '--email', help='Includes check for email settings in scan', action='store_true')
opt_parser.add_argument(
'-w', '--wordlist', help='Use a wordlist for subdomains')
opt_parser.add_argument(
'-wl', '--weblist', help='Use a raw.githubusercontent.com wordlist for subdomains')
opt_parser.add_argument(
'-tx', '--text', help='Write results of subdomain scan to a file', action='store_true')
opt_parser.add_argument(
'-md', '--markdown', help='Write results of subdomain scan to a markdown file for use with Xmind', action='store_true'
)
opt_parser.add_argument(
'-il', '--input', help='Check subdomain output against a list of IP addresses')
opt_parser.add_argument(
'-c', '--concurrent', help='Number of concurrent requests to run. DEFAULT - 10. Anything greater can be unstable', required=False
)
global args
args = opt_parser.parse_args()
if len(sys.argv) == 1:
opt_parser.print_help()
opt_parser.exit()
def style():
global success, info, fail, servertype
success, info, fail, servertype = Fore.GREEN + Style.BRIGHT, Fore.YELLOW + Style.BRIGHT, Fore.RED + Style.BRIGHT, Fore.WHITE + Style.BRIGHT
record_types = ['A', 'AAAA', 'NS', 'CNAME', 'MX', 'PTR', 'SOA', 'SRV',
'TXT']
subdomain_array = ['a', 'acceptatie', 'access', 'accounting', 'accounts', 'ad', 'adm', 'admin', 'administrator', 'ads', 'adserver', 'affiliate', 'affiliates', 'agenda', 'alpha', 'alumni', 'analytics', 'ann', 'api', 'apollo', 'app', 'apps', 'ar', 'archive', 'art', 'assets', 'atlas', 'auth', 'auto', 'autoconfig', 'autodiscover', 'av', 'ayuda', 'b', 'b2b', 'backup', 'backups', 'banner', 'barracuda', 'bb', 'bbs', 'beta', 'biblioteca', 'billing', 'blackboard', 'blog', 'blogs', 'board', 'book', 'booking', 'bookings', 'broadcast-ip', 'bsd', 'bt', 'bug', 'bugs', 'business', 'c', 'ca', 'cache', 'cacti', 'cal', 'calendar', 'cam', 'careers', 'cart', 'cas', 'catalog', 'catalogo', 'catalogue', 'cc', 'cctv', 'cdn', 'cdn1', 'cdn2', 'chat', 'chimera', 'chronos', 'ci', 'cisco', 'citrix', 'classroom', 'client', 'clientes', 'clients', 'cloud', 'cloudflare-resolve-to', 'club', 'cms', 'cn', 'co', 'community', 'conference', 'config', 'connect', 'contact', 'contacts', 'content', 'control', 'controller', 'controlp', 'controlpanel', 'corp', 'corporate', 'correo', 'correoweb', 'cp', 'cpanel', 'crm', 'cs', 'css', 'customers', 'cvs', 'd', 'da', 'data', 'database', 'db', 'db1', 'db2', 'dbadmin', 'dbs', 'dc', 'de', 'default', 'demo', 'demo2', 'demon', 'demostration', 'descargas', 'design', 'desktop', 'dev', 'dev01', 'dev1', 'dev2', 'devel', 'developers', 'development', 'dialin', 'diana', 'direct', 'directory', 'dl', 'dmz', 'dns', 'dns1', 'dns2', 'dns3', 'dns4', 'doc', 'docs', 'domain', 'domain-controller', 'domainadmin', 'domaincontrol', 'domaincontroller', 'domaincontrolpanel', 'domainmanagement', 'domains', 'download', 'downloads', 'drupal', 'e', 'eaccess', 'echo', 'ecommerce', 'edu', 'ektron', 'elearning', 'email', 'en', 'eng', 'english', 'enterpriseenrollment', 'enterpriseregistration', 'erp', 'es', 'event', 'events', 'ex', 'example', 'examples', 'exchange', 'external', 'extranet', 'f', 'facebook', 'faq', 'fax', 'fb', 'feedback', 'feeds', 'file', 'files', 'fileserver', 'finance', 'firewall', 'folders', 'forms', 'foro', 'foros', 'forum', 'forums', 'foto', 'fr', 'free', 'freebsd', 'fs', 'ftp', 'ftp1', 'ftp2', 'ftpadmin', 'ftpd', 'fw', 'g', 'galeria', 'gallery', 'game', 'games', 'gate', 'gateway', 'gilford', 'gis', 'git', 'gmail', 'go', 'google', 'groups', 'groupwise', 'gu', 'guest', 'guia', 'guide', 'gw', 'health', 'help', 'helpdesk', 'hera', 'heracles', 'hercules', 'hermes', 'home', 'homer', 'host', 'host2', 'hosting', 'hotspot', 'hr', 'hypernova', 'i', 'id', 'idp', 'im', 'image', 'images', 'images1', 'images2', 'images3', 'images4', 'images5', 'images6', 'images7', 'images8', 'imail', 'imap', 'imap3', 'imap3d', 'imapd', 'imaps', 'img', 'img1', 'img2', 'img3', 'imgs', 'imogen', 'in', 'incoming', 'info', 'inmuebles', 'internal', 'interno', 'intra', 'intranet', 'io', 'ip', 'ip6', 'ipfixe', 'iphone', 'ipmi', 'ipsec', 'ipv4', 'ipv6', 'irc', 'ircd', 'is', 'isa', 'it', 'j', 'ja', 'jabber', 'jboss', 'jboss2', 'jira', 'job', 'jobs', 'jp', 'js', 'jupiter', 'k', 'kb', 'kerberos', 'l', 'la', 'lab', 'laboratories', 'laboratorio', 'laboratory', 'labs', 'ldap', 'legacy', 'lib', 'library', 'link', 'links', 'linux', 'lisa', 'list', 'lists', 'live', 'lms', 'local', 'localhost', 'log', 'loghost', 'login', 'logon', 'logs', 'london', 'loopback', 'love', 'lp', 'lync', 'lyncdiscover', 'm', 'm1', 'm2', 'magento', 'mail', 'mail01', 'mail1', 'mail2', 'mail3', 'mail4', 'mail5', 'mailadmin', 'mailbackup', 'mailbox', 'mailer', 'mailgate', 'mailhost', 'mailing', 'mailman', 'mailserver', 'main', 'manage', 'manager', 'mantis', 'map', 'maps', 'market', 'marketing', 'mars', 'master', 'math', 'mb', 'mc', 'mdm', 'media',
'meet', 'member', 'members', 'mercury', 'meta', 'meta01', 'meta02', 'meta03', 'meta1', 'meta2', 'meta3', 'miembros', 'mijn', 'minerva', 'mirror', 'ml', 'mm', 'mob', 'mobil', 'mobile', 'monitor', 'monitoring', 'moodle', 'movil', 'mrtg', 'ms', 'msoid', 'mssql', 'munin', 'music', 'mx', 'mx-a', 'mx-b', 'mx0', 'mx01', 'mx02', 'mx03', 'mx1', 'mx2', 'mx3', 'my', 'mysql', 'mysql2', 'n', 'nagios', 'nas', 'nat', 'nelson', 'neon', 'net', 'netmail', 'netscaler', 'network', 'network-ip', 'networks', 'new', 'newmail', 'news', 'newsgroups', 'newsite', 'newsletter', 'nl', 'noc', 'novell', 'ns', 'ns0', 'ns01', 'ns02', 'ns03', 'ns1', 'ns10', 'ns11', 'ns12', 'ns2', 'ns3', 'ns4', 'ns5', 'ns6', 'ns7', 'ns8', 'nt', 'ntp', 'ntp1', 'o', 'oa', 'office', 'office2', 'old', 'oldmail', 'oldsite', 'oldwww', 'on', 'online', 'op', 'openbsd', 'operation', 'operations', 'ops', 'ora', 'oracle', 'origin', 'orion', 'os', 'osx', 'ou', 'outgoing', 'outlook', 'owa', 'ox', 'p', 'painel', 'panel', 'partner', 'partners', 'pay', 'payment', 'payments', 'pbx', 'pcanywhere', 'pda', 'pegasus', 'pendrell', 'personal', 'pgsql', 'phoenix', 'photo', 'photos', 'php', 'phpmyadmin', 'pm', 'pma', 'poczta', 'pop', 'pop3', 'portal', 'portfolio', 'post', 'postgres', 'postgresql', 'postman', 'postmaster', 'pp', 'ppp', 'pr', 'pre-prod', 'pre-production', 'preprod', 'press', 'preview', 'private', 'pro', 'prod', 'production', 'project', 'projects', 'promo', 'proxy', 'prueba', 'pruebas', 'pt', 'pub', 'public', 'q', 'qa', 'r', 'ra', 'radio', 'radius', 'ras', 'rdp', 'redirect', 'redmine', 'register', 'relay', 'remote', 'remote2', 'repo', 'report', 'reports', 'repos', 'research', 'resources', 'restricted', 'reviews', 'robinhood', 'root', 'router', 'rss', 'rt', 'rtmp', 'ru', 's', 's1', 's2', 's3', 's4', 'sa', 'sales', 'sample', 'samples', 'sandbox', 'sc', 'search', 'secure', 'security', 'seo', 'server', 'server1', 'server2', 'service', 'services', 'sftp', 'share', 'sharepoint', 'shell', 'shop', 'shopping', 'signup', 'sip', 'site', 'siteadmin', 'sitebuilder', 'sites', 'skype', 'sms', 'smtp', 'smtp1', 'smtp2', 'smtp3', 'snmp', 'social', 'software', 'solaris', 'soporte', 'sp', 'spam', 'speedtest', 'sport', 'sports', 'sql', 'sqlserver', 'squirrel', 'squirrelmail', 'ssh', 'ssl', 'sslvpn', 'sso', 'st', 'staff', 'stage', 'staging', 'start', 'stat', 'static', 'static1', 'static2', 'stats', 'status', 'storage', 'store', 'stream', 'streaming', 'student', 'sun', 'support', 'survey', 'sv', 'svn', 't', 'team', 'tech', 'telewerk', 'telework', 'temp', 'test', 'test1', 'test2', 'test3', 'testing', 'testsite', 'testweb', 'tfs', 'tftp', 'thumbs', 'ticket', 'tickets', 'time', 'tools', 'trac', 'track', 'tracker', 'tracking', 'train', 'training', 'travel', 'ts', 'tunnel', 'tutorials', 'tv', 'tw', 'u', 'uat', 'uk', 'unix', 'up', 'update', 'upload', 'uploads', 'us', 'user', 'users', 'v', 'v2', 'vc', 'ventas', 'video', 'videos', 'vip', 'virtual', 'vista', 'vle', 'vm', 'vms', 'vmware', 'vnc', 'vod', 'voip', 'vpn', 'vpn1', 'vpn2', 'vpn3', 'vps', 'vps1', 'vps2', 'w', 'w3', 'wap', 'wc', 'web', 'web0', 'web01', 'web02', 'web03', 'web1', 'web2', 'web3', 'web4', 'web5', 'webadmin', 'webcam', 'webconf', 'webct', 'webdb', 'webdisk', 'weblog', 'webmail', 'webmail2', 'webmaster', 'webmin', 'webservices', 'webstats', 'webstore', 'whm', 'wifi', 'wiki', 'win', 'win32', 'windows', 'wordpress', 'work', 'wp', 'ws', 'wsus', 'ww', 'ww0', 'ww01', 'ww02', 'ww03', 'ww1', 'ww2', 'ww3', 'www', 'www-test', 'www0', 'www01', 'www02', 'www03', 'www1', 'www2', 'www3', 'www4', 'www5', 'www6', 'www7', 'wwwm', 'wwwold', 'wwww', 'x', 'xml', 'zabbix', 'zeus', 'zimbra']
subdom_file = []
def banner():
print(Fore.YELLOW + Style.BRIGHT + "")
print('███╗ ███╗███████╗██████╗ ███╗ ██╗███████╗███████╗ ██████╗ █████╗ ███╗ ██╗')
print('████╗ ████║██╔════╝██╔══██╗████╗ ██║██╔════╝██╔════╝██╔════╝██╔══██╗████╗ ██║')
print('██╔████╔██║███████╗██║ ██║██╔██╗ ██║███████╗███████╗██║ ███████║██╔██╗ ██║')
print('██║╚██╔╝██║╚════██║██║ ██║██║╚██╗██║╚════██║╚════██║██║ ██╔══██║██║╚██╗██║')
print('██║ ╚═╝ ██║███████║██████╔╝██║ ╚████║███████║███████║╚██████╗██║ ██║██║ ╚████║')
print('╚═╝ ╚═╝╚══════╝╚═════╝ ╚═╝ ╚═══╝╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═══╝\n')
print(' DNS and Subdomain Enumeration Tool ')
print(' Version 2.0.0 ')
print(' A project by The Mayor ')
print(' python3 msdnsscan.py -d <domain> -a to start \n')
print(' Recommend the Bitquark 100000 Wordlist in the Wordlist Directory \n' + Style.RESET_ALL)
print("-" * 79)
def main():
try:
domain = args.domain
except IndexError:
print(
fail + f'\n[warn] You did not enter a domain. Syntax is python3 msdnsscan.py <domain>.')
quit()
for records in record_types:
try:
answers = dns.resolver.resolve(domain, records)
print(info + f'\n{records} Records')
print('-' * 50)
for server in answers:
print(success + server.to_text())
except dns.resolver.NXDOMAIN:
print(fail + f'\n[warn] {domain} domain does not exist.\n')
quit()
except dns.resolver.NoAnswer:
print(info + f'\n[info] No {records} records found.')
except dns.rdatatype.UnknownRdatatype:
pass
except dns.resolver.NoNameservers:
pass
except dns.resolver.NoAnswer:
pass
except Exception:
pass
def zone_transfer():
domain = args.domain
address = domain
try:
name_server = dns.resolver.resolve(address, 'NS')
print(
info + f'\nZone Transfer Records - This may take a minute')
print('-' * 50)
for server in name_server:
ip_value = dns.resolver.resolve(server.target, 'A')
for ip_addr in ip_value:
try:
z_transfer = dns.zone.from_xfr(
dns.query.xfr(str(ip_addr), address))
print(
info + f'\nZone transfer records for {server} at {ip_addr}')
print('-' * 60)
for z_host in z_transfer:
print(success + z_host.to_text())
except dns.xfr.TransferError:
print(info + f'\n[info] Zone Transfer refused for {server}')
pass
except TimeoutError:
print(info + f'\n[info] Zone Transfer refused for {server}')
pass
except dns.resolver.NoAnswer:
pass
except Exception:
pass
except dns.resolver.NoAnswer:
pass
def email():
domain = args.domain
address = domain
dmarc_val = 0
spf_val = 0
dkim_val = 0
records = []
print(info + f'\nEmail Records')
print('-' * 50)
try:
dmarc_data = dns.resolver.resolve(f'_dmarc.{address}', 'TXT')
for dmarc_response in dmarc_data:
if 'DMARC1' in str(dmarc_response):
records.append(success + f'[dmarc record] {dmarc_response}')
dmarc_val += 1
except dns.resolver.NXDOMAIN:
pass
except dns.resolver.NoAnswer:
pass
try:
spf_data = dns.resolver.resolve(domain, 'TXT')
for spf_response in spf_data:
if 'spf1' in str(spf_response):
records.append(success + f'[spf record] {spf_response}')
spf_val += 1
except dns.resolver.NXDOMAIN:
pass
except dns.resolver.Timeout:
pass
except dns.resolver.NoAnswer:
pass
selectors = ["2013-03", "a2hosting","20161025", "alfa", "beta", "cm", "default", "delta", "dkim", "google",
"k1", "k2", "k3", "k4", "k5", "m1", "m2", "m3", "m4", "m5", "mail", "mandrill", "my1",
"my2", "my3", "my4", "my5", "pf2014", "pm", "proddkim1024", "rit1608", "s1", "s1024",
"s2", "s2048", "s5", "s512", "s7", "s768", "selector1", "selector1-ebsmd-com0i",
"selector1-wwecorp-com", "selector2", "smtp", "smtpapi", "test", "zendesk", "zendesk1",
"ml", "consulenze"]
for selector in selectors:
try:
dkim_data = dns.resolver.resolve(f'{selector}._domainkey.{domain}', 'TXT')
for dkim_response in dkim_data:
if 'DKIM1' in str(dkim_response):
records.append(success + f'[dkim record] {dkim_response}')
dkim_val += 1
except dns.resolver.NXDOMAIN:
pass
except dns.resolver.NoAnswer:
pass
except dns.resolver.Timeout:
pass
for success_val in records:
print(success_val)
if dmarc_val == 0:
print(info + f'[info] DMARC data not found for {domain}')
if spf_val == 0:
print(info + f'[info] SPF data not found for {domain}')
if dkim_val == 0:
print(info + f'[info] DKIM data not found for {domain}')
def subdom_requestor(ip_addr, subdoms, domain):
possible_headers = ['Server', 'X-Powered-By']
server_headers = []
url_request = requests.get(f'\nhttps://{subdoms}.{domain}')
if url_request.status_code == 200:
status_code = success + f'[{url_request.status_code}]'
markdown_status_code = f'[{url_request.status_code}]'
elif url_request.status_code == 300 or url_request.status_code == 301 or url_request.status_code == 302:
status_code = info + f'[{url_request.status_code}]'
markdown_status_code = f'[{url_request.status_code}]'
else:
status_code = fail + f'[{url_request.status_code}]'
markdown_status_code = f'[{url_request.status_code}]'
for possible_header in possible_headers:
server_header = url_request.headers.get(possible_header)
if server_header == None:
pass
else:
server_headers.append(server_header)
if server_headers == None:
print(success + f'{subdoms}.{domain} - {ip_addr} - {status_code}')
if args.text == True:
if str(ip_addr):
with open(f'{args.domain}_subdomains.txt', 'a') as sub_file:
sub_file.write(
f'{subdoms}.{domain} - {ip_addr}\n')
if args.markdown:
if str(ip_addr):
with open(f'{args.domain}_markdown.md', 'a') as md_file:
md_file.write(
f'## {subdoms}.{domain} - {ip_addr}\n')
md_file.write(f'### {markdown_status_code} - {print_header}\n')
elif len(server_headers) == 1 and server_headers != 'None':
print_header = server_header
print(
success + f'{subdoms}.{domain} - {ip_addr} - {status_code}' + servertype + f' [{server_headers[0]}]')
if args.text == True:
if str(ip_addr):
with open(f'{args.domain}_subdomains.txt', 'a') as sub_file:
sub_file.write(
f'{subdoms}.{domain} - {ip_addr} - [{server_headers[0]}]\n')
if args.markdown:
if str(ip_addr):
with open(f'{args.domain}_markdown.md', 'a') as md_file:
md_file.write(
f'## {subdoms}.{domain} - {ip_addr}\n')
md_file.write(f'### {markdown_status_code} - [{server_headers[0]}]\n')
elif len(server_headers) == 2 and server_headers != 'None':
print(
success + f'{subdoms}.{domain} - {ip_addr} - {status_code}' + servertype + f' [{server_headers[0]}]/[{server_headers[1]}]')
if args.text == True:
if str(ip_addr):
with open(f'{args.domain}_subdomains.txt', 'a') as sub_file:
sub_file.write(
f'{subdoms}.{domain} - {ip_addr} - [{server_headers[0]}]/[{server_headers[1]}]\n')
if args.markdown:
if str(ip_addr):
with open(f'{args.domain}_markdown.md', 'a') as md_file:
md_file.write(
f'## {subdoms}.{domain} - {ip_addr}\n')
md_file.write(f'### {markdown_status_code} - [{server_headers[0]}]/[{server_headers[1]}]\n')
else:
pass
server_headers = []
def try_statement(subdoms, domain, inscope_store):
try:
ip_value = dns.resolver.resolve(f'{subdoms}.{domain}', 'A')
for ip_addr in ip_value:
if args.input is not None:
for ip_check in inscope_store:
if str(ip_addr) != str(ip_check):
pass
else:
subdom_requestor(ip_addr, subdoms, domain)
elif args.input is None:
subdom_requestor(ip_addr, subdoms, domain)
except (requests.ConnectionError, dns.resolver.NXDOMAIN, dns.resolver.NoAnswer,
dns.resolver.NoNameservers, dns.exception.Timeout, UnboundLocalError,
requests.exceptions.TooManyRedirects):
pass
def process_subdomain(subdomains, domain, inscope_store):
if args.concurrent:
concurrent_requests = int(args.concurrent)
else:
concurrent_requests = 10
with concurrent.futures.ThreadPoolExecutor(max_workers=concurrent_requests) as executor:
futures = []
try:
for subdoms in subdomains:
future = executor.submit(try_statement, subdoms, domain, inscope_store)
futures.append(future)
# Handles keyboard interrupts
for future in concurrent.futures.as_completed(futures):
try:
future.result()
except KeyboardInterrupt:
for task in futures:
task.cancel()
break
except KeyboardInterrupt:
for task in futures:
task.cancel()
raise
def subdom_finder():
domain = args.domain
print(info + f'\n[info] Checking for subdomains. This may take some time depending on the wordlist.\n')
inscope_store = []
if args.input is not None:
lines = Path(args.input).read_text().splitlines()
for line in lines:
inscope_store.append(f'{line}')
if args.wordlist is not None:
with open(args.wordlist, 'r+') as subdomain_list:
if args.markdown:
with open(f'{args.domain}_markdown.md', 'a') as md_file:
header_info = f'# {args.domain}\n'
md_file.write(header_info)
md_file.close()
subdomains = [line.strip() for line in subdomain_list]
process_subdomain(subdomains, domain, inscope_store)
elif args.weblist is not None:
url = args.weblist
head, tail = os.path.split(url)
urllib.request.urlretrieve(url, f'{tail}')
print(f'[info] Reading subdomains from {url}.\n')
subdom_file.append(tail)
with open(f'{tail}', 'r+') as subdomain_list:
if args.markdown:
with open(f'{args.domain}_markdown.md', 'a') as md_file:
header_info = f'# {args.domain}\n'
md_file.write(header_info)
md_file.close()
subdomains = [line.strip() for line in subdomain_list]
process_subdomain(subdomains, domain, inscope_store)
os.remove(f'{tail}')
else:
process_subdomain(subdomain_array, domain, inscope_store)
def run():
if args.dns:
main()
elif args.zone:
zone_transfer()
elif args.subdom:
subdom_finder()
elif args.email:
email()
elif args.all:
main(), email(), zone_transfer(), subdom_finder()
else:
print(
fail + f'\n[syntax error] Please include options. Ex - python3 msdnsscan.py -d example.com --dns.\n')
quit()
print(info + f'\n[info] Enumeration for {args.domain} completed.\n')
if __name__ == "__main__":
try:
init()
style()
banner()
options()
t1 = datetime.now()
print('Starting scan at ' + str(t1))
run()
t2 = datetime.now()
total_time = t2 - t1
print('Scan completed in ' + str(total_time))
except KeyboardInterrupt:
print(
info + f'\n[warn] You either fat fingered this, or meant to do it. Either way, goodbye!\n')
for i in subdom_file:
os.remove(i)
quit()
except urllib.error.HTTPError:
print(fail + '[warn] Wordlist invalid. Check URL and try again.')