-
Notifications
You must be signed in to change notification settings - Fork 0
/
submix.py
424 lines (396 loc) · 14.2 KB
/
submix.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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# pylint: disable=invalid-name
# pylint: disable=line-too-long
# pylint: disable=missing-docstring
# pylint: disable=trailing-whitespace
# pylint: disable=bad-indentation
# pylint: disable=redefined-outer-name
# pylint: disable=no-self-argument
import argparse
import json
import os
import random
import sys
import colorama
import pyfiglet
import requests
from bs4 import BeautifulSoup as bs
from colorama import Fore
# color method
colorama.init(autoreset=True)
red = Fore.RED
blue = Fore.BLUE
cyan = Fore.CYAN
green = Fore.GREEN
yellow = Fore.YELLOW
# argument system
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", help="url of targeted website", required=True)
parser.add_argument(
"-f",
"--force",
help="forced to look for sub domains without verifying the targeted domain",
required=False,
)
parser.add_argument(
"-r", "--remove", help="remove existing valid.txt file", required=False
)
parser.add_argument("-o", "--option", help="set option 1 / 2", required=False)
parser.add_argument("-m", "--method", help="set method http / https", required=True)
parser.add_argument("-fm", "--fast", help="fast print yes / no", required=True)
parser.add_argument(
"-c", "--check", help="sub domain validation check (ex. -c yes / no)", required=True
)
args = parser.parse_args()
# main system
rapiddns = "https://rapiddns.io/subdomain/{}?full=1#valid"
crt_url = "https://crt.sh/?q={}&output=json"
all_subdomain = list()
subdomains = list()
subdomain = list()
valid_subdomain_list = list()
error_subdomain_list = list()
class main_system:
def method_check():
if args.method == "http":
method = "http"
elif args.method == "https":
method = "https"
return method
def url_check():
c_method = main_system.method_check()
url = str(args.url)
if args.force:
print(yellow + "[-] Forced to look for sub domains")
else:
try:
good_url = f"{c_method}://{url}"
response = requests.get(good_url, timeout=20)
print(green + "[*] Target is valid")
except:
print(red + "[*] Target is invalid")
exit()
def get_data_by_rapiddns(data):
web = str(args.url)
req = requests.get(rapiddns.format(web), timeout=20)
soup = bs(req.text, "html.parser")
if data == "subdomain_num":
total_subdomain = soup.find("div", {"class": "d-flex align-items-left"})
for total_subdomain_div in total_subdomain.find_all("div"):
for total_subdomain_div_span in total_subdomain_div.find_all("span"):
return total_subdomain_div_span
if data == "web_url":
return web
def rapiddns_subdomain_collection_purify():
print(yellow + "[*] Starting to find subdomain in rapid dns")
if args.fast == "yes":
if main_system.get_data_by_rapiddns("subdomain_num").text == "0":
pass
else:
print(
red
+ " [-] "
+ green
+ "Total sub domain find in rapid dns: "
+ str(main_system.get_data_by_rapiddns("subdomain_num").text)
)
web = str(args.url)
req = requests.get(rapiddns.format(web), timeout=20)
soup = bs(req.text, "html.parser")
total_subdomain_num = main_system.get_data_by_rapiddns("subdomain_num")
table_data = soup.find("table", {"id": "table"})
for table_data_tbody in table_data.find_all("tbody"):
i = int(total_subdomain_num.text)
ii = 0
while ii < i:
subdomain_data = table_data_tbody.find_all("tr")[ii]
for subdomain_data_td in subdomain_data.find_all("td")[0]:
ii += 1
all_subdomain.append(subdomain_data_td)
if args.fast == "yes":
print(red + " [ 111 ] " + yellow + subdomain_data_td)
print(green + "[+] done")
def crtsh():
print(yellow + "[*] starting to find subdomain in crtsh")
domain = main_system.get_data_by_rapiddns("web_url")
try:
response = requests.get(crt_url.format(domain), timeout=20)
if response.ok:
content = response.content.decode("UTF-8")
jsondata = json.loads(content)
for i in range(len(jsondata)):
name_value = jsondata[i]["name_value"]
if name_value.find("\n"):
subname_value = name_value.split("\n")
for subname_value in subname_value:
if subname_value.find("*"):
if subname_value not in subdomains:
subdomains.append(subname_value)
all_subdomain.append(subname_value)
if args.fast == "yes":
print(
red + " [ 111 ] " + yellow + subname_value
)
if args.fast == "yes":
print(
red
+ " [-] "
+ green
+ "Total sub domain find in crtsh: "
+ str(len(subdomains))
)
print(green + "[+] done")
except:
print("Something went wrong in crt sub domain finder")
def valid_subdomain():
if args.check == "yes":
print(yellow + "[*] printing valid sub domains")
f = open("result.txt", "r", encoding="UTF-8")
for line in f:
subdomain.append(line.strip())
i = len(subdomain)
ii = 0
while ii < i:
single_subdomain = subdomain[ii]
ii += 1
try:
response = requests.get(f"https://{single_subdomain}", timeout=20)
valid_subdomain_list.append(single_subdomain)
print(green + " [ 200 ] " + yellow + single_subdomain)
except:
error_subdomain_list.append(single_subdomain)
print(
green
+ "[*] Total valid sub domain found: "
+ str(len(valid_subdomain_list))
)
# i = len(valid_subdomain_list)
# ii = 0
# while ii < i:
# single_subdomain = valid_subdomain_list[ii]
# ii += 1
# print(green + " [ 200 ] " + yellow + single_subdomain)
print(green + "[+] done")
elif args.fast == "no":
print(red + "[-] sub domains are unverified")
all_subdomain_s = list(set(all_subdomain))
i = len(all_subdomain_s)
print(green + "[*] Total sub domain found: " + str(i))
ii = 0
while ii < i:
unverified_single_subdomain = all_subdomain_s[ii]
ii += 1
print(red + " [ 000 ] " + yellow + unverified_single_subdomain)
print(green + "[+] done")
def file_check():
if args.remove:
if os.path.exists("./result.txt"):
os.remove("./result.txt")
f_r = open("./result.txt", "w", encoding="utf-8")
return f_r
else:
f_r = open("./result.txt", "w", encoding="utf-8")
return f_r
def file_check_1():
if args.remove:
if os.path.exists("./valid.txt"):
os.remove("./valid.txt")
f = open("./valid.txt", "w", encoding="utf-8")
return f
else:
f = open("./valid.txt", "w", encoding="utf-8")
return f
def file_check_2():
if args.remove:
if os.path.exists("./invalid.txt"):
os.remove("./invalid.txt")
f_in = open("./invalid.txt", "w", encoding="utf-8")
return f_in
else:
f_in = open("./invalid.txt", "w", encoding="utf-8")
return f_in
def write_file_1():
file_name = main_system.file_check()
all_subdomain_s = list(set(all_subdomain))
i = int(len(all_subdomain_s))
ii = int(0)
while ii < i:
single_data = str(all_subdomain_s[ii])
file_name.write(f"{single_data}\n")
ii += 1
def write_file_2():
file_name_2 = main_system.file_check_2()
error_subdomain_list_s = list(set(error_subdomain_list))
i = int(len(error_subdomain_list_s))
ii = int(0)
while ii < i:
invalid_single_data = str(error_subdomain_list_s[ii])
file_name_2.write(f"{invalid_single_data}\n")
ii += 1
def write_file_3():
file_name_3 = main_system.file_check_1()
valid_subdomain_list_s = list(set(valid_subdomain_list))
i = int(len(valid_subdomain_list_s))
ii = int(0)
while ii < i:
valid_single_data = str(valid_subdomain_list_s[ii])
file_name_3.write(f"{valid_single_data}\n")
ii += 1
def banner():
# banner system
banner_style = [
"3-d",
"3x5",
"5lineoblique",
"acrobatic",
"alligator",
"alligator2",
"alphabet",
"avatar",
"banner",
"banner3-D",
"banner3",
"banner4",
"barbwire",
"basic",
"bell",
"big",
"bigchief",
"block",
"broadway",
"bubble",
"bulbhead",
"calgphy2",
"caligraphy",
"catwalk",
"chunky",
"coinstak",
"colossal",
"computer",
"contessa",
"contrast",
"cosmic",
"cosmike",
"crawford",
"cricket",
"cyberlarge",
"cybermedium",
"cybersmall",
"decimal",
"diamond",
"digital",
"doh",
"doom",
"dotmatrix",
"double",
"drpepper",
"dwhistled",
"eftichess",
"eftifont",
"eftipiti",
"eftirobot",
"eftitalic",
"eftiwall",
"eftiwater",
"epic",
"fender",
"fourtops",
"fraktur",
"fuzzy",
"goofy",
"gothic",
"graceful",
"gradient",
"graffiti",
"hex",
"hollywood",
"invita",
"isometric1",
"isometric2",
"isometric3",
"isometric4",
"italic",
"ivrit",
"jazmine",
"katakana",
"kban",
"l4me",
"larry3d",
"lcd",
"lean",
"letters",
"linux",
"lockergnome",
"madrid",
"marquee",
"maxfour",
"mike",
"mini",
"mirror",
"mnemonic",
"nancyj-fancy",
"nancyj-underlined",
"nancyj",
"nipples",
"nvscript",
"o8",
"octal",
"ogre",
"script",
"shadow",
"slant",
"small",
"smscript",
"smshadow",
"smslant",
"standard",
"term",
]
random_banner_style = random.choice(banner_style)
banner = pyfiglet.figlet_format("submix", font=random_banner_style)
print(cyan + banner)
print(yellow + "[*************] " + "created by Solaiman" + " [*************]")
print(green + "[*] Target: " + main_system.get_data_by_rapiddns("web_url"))
def main_text():
main_system.banner()
main_system.url_check()
print(yellow + "[*] looking for sub domains....")
if args.option == str(1) and args.check == "no":
if int(main_system.get_data_by_rapiddns("subdomain_num").text) == 0:
pass
else:
main_system.rapiddns_subdomain_collection_purify()
elif args.option == str(2) and args.check == "no":
main_system.crtsh()
elif args.option == str(1) and args.check == "yes":
if int(main_system.get_data_by_rapiddns("subdomain_num").text) == 0:
pass
else:
main_system.rapiddns_subdomain_collection_purify()
main_system.write_file_1()
main_system.valid_subdomain()
main_system.write_file_2()
main_system.write_file_3()
elif args.option == str(2) and args.check == "yes":
main_system.crtsh()
main_system.write_file_1()
main_system.valid_subdomain()
main_system.write_file_2()
main_system.write_file_3()
else:
if int(main_system.get_data_by_rapiddns("subdomain_num").text) == 0:
pass
else:
main_system.rapiddns_subdomain_collection_purify()
main_system.crtsh()
main_system.write_file_1()
main_system.valid_subdomain()
main_system.write_file_2()
main_system.write_file_3()
try:
main_system.main_text()
except KeyboardInterrupt:
print(red + "Quitting now")
print(green + "Thanks for using me....")
# except:
# print(red + "[-] Something went wrong")
# print(yellow + "[?] Please try again with a new terminal window")