-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRun.py
77 lines (67 loc) · 3.2 KB
/
Run.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
import requests
import json
import re
import sys
import time
def find_subdomains(domain_name, complite, file_name):
headers = {
'Accept-Language': 'id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7',
'X-Requested-With': 'id.chie.subdomainfinder',
'Accept-Encoding': 'gzip, deflate',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'crt.sh',
'Referer': 'https://crt.sh/?q=[]&output=json',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Accept': '*/*',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Linux; Android 14; SM-S9210 Build/UP1A.231005.007; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.74 Mobile Safari/537.36',
}
with requests.Session() as session:
session.headers.update(
headers
)
if bool(complite) != True:
response = session.get('https://crt.sh/?q={}&output=json&exclude=expired'.format(domain_name), verify=True)
else:
response = session.get('https://crt.sh/?q={}&output=json'.format(domain_name), verify=True)
x_data = json.loads(response.text)
subdomains = set()
for entry in x_data:
subdomains.update(entry['name_value'].split('\n'))
number = 0
for subdomain in subdomains:
open(f'{file_name}', 'a+').write(f'{subdomain}\n')
number += 1
print(f"\x1b[1;92m{number}\x1b[1;97m.\x1b[1;97m {subdomain}")
return ("null")
if __name__ == "__main__":
print(r"""{} ____ _ _____ _ _
/ ___| _ _| |__ | ___(_)_ __ __| | ___ _ __
\___ \| | | | '_ \| |_ | | '_ \ / _` |/ _ \ '__|
___) | |_| | |_) | _| | | | | | (_| | __/ |
|____/ \__,_|_.__/|_| |_|_| |_|\__,_|\___|_|
""".format('\x1b[1;93m', '\x1b[1;97m'))
domain_name = input("\x1b[1;97mDomain (Ex:\x1b[1;92m facebook.com\x1b[1;97m):\x1b[1;92m ").lower()
if re.match(r'^(?!https?:\/\/|www\.|.*[^a-zA-Z0-9.-]).+(\.[a-zA-Z]{2,})+$', domain_name):
file_name = input("\x1b[1;97mFiles (\x1b[1;97mEx:\x1b[1;93m Temporary/Save.txt\x1b[1;97m):\x1b[1;92m ")
type_ = input("\x1b[1;97mType (\x1b[1;91mQuick\x1b[1;97m/\x1b[1;92mComplite\x1b[1;97m):\x1b[1;92m ")
with open(f'{file_name}', 'w+') as save:
save.write("")
save.close()
print(f"\x1b[1;97mLooking for {domain_name}", end="", flush=True)
for i in range(3):
for dots in range(1, 4):
print(f"\r\x1b[1;97mLooking for {domain_name}{'.' * dots}", end="", flush=True)
time.sleep(0.5)
print("\r ")
complite = False if type_.capitalize() == 'Quick' else True
find_subdomains(domain_name, complite, file_name)
print("\n\x1b[1;97mSuccessfully Saved Subdomain!")
print(f"\x1b[1;97mDomain Count:\x1b[1;92m {len(open(file_name, 'r').readlines())}")
print(f"\x1b[1;97mSaved in:\x1b[1;91m {file_name}")
sys.exit(1)
else:
print("\n\x1b[1;91mInvalid Domain Name!")
sys.exit(1)