-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubdomainRoutes.py
83 lines (63 loc) · 1.89 KB
/
SubdomainRoutes.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
# importing library
import requests
import os
import subprocess
# function for scanning subdomains
def domain_scanner(domain_name,sub_domnames):
print('-----------Subdomain Scanner Started-----------\n')
try:
# loop for getting URLs
for subdomain in sub_domnames:
# making url by putting subdomain one by one
url = f"https://{subdomain}.{domain_name}"
# using try catch block to avoid crash of
# the program
try:
# sending get request to the url
requests.get(url, timeout=2)
# if after putting subdomain one by one url
# is valid then printing the url
print(f'[+] {url}')
f = open("./Subdomain.txt", "a")
f.write(f'[+] {url}')
f.write("\n")
f.close()
# if url is invalid then pass it
except requests.ConnectionError:
pass
path_current="./Subdomain.txt"
movepath = "./Temp/Subdomain_OP.txt"
os.replace(path_current, movepath)
print('\n')
except:
print("No Subdomains Found !!!")
f = open("./Subdomain.txt", "a")
f.write("No Subdomains Found !!!")
f.close()
path_current="./Subdomain.txt"
movepath = "./Temp/Subdomain_OP.txt"
os.replace(path_current, movepath)
print('\n')
#Remove Temp File Save Output File
print('----Scanning Finished----')
# main function
if __name__ == '__main__':
# inputting the domain name
with open('./Temp/Result_current.txt') as f:
dom_name = f.readline().strip()
print('\n')
# opening the subdomain text file
with open('./Lists/Subdomain_names.txt','r') as file:
# reading the file
name = file.read()
# using splitlines() function storing the
# list of splitted strings
sub_dom = name.splitlines()
# calling the function for scanning the subdomains
# and getting the url
domain_scanner(dom_name,sub_dom)
#Run Next Script
rawpath = os.getcwd() + "\\AdminPageScan.py"
path = rawpath.replace('\\', '/')
subprocess.call(['python', path])
exit()