-
Notifications
You must be signed in to change notification settings - Fork 36
/
thetimemachine.py
490 lines (416 loc) · 18.9 KB
/
thetimemachine.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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
import sys
import requests
import re
import numpy as np
from colorama import init
from termcolor import colored
import os
import datetime
import time
def load_animation():
load_str = "preparing the time machine portal for voyager...."
ls_len = len(load_str)
animation = "|/-\\"
anicount = 0
counttime = 0
i = 0
while (counttime != 100):
time.sleep(0.075)
load_str_list = list(load_str)
x = ord(load_str_list[i])
y = 0
if x != 32 and x != 46:
if x>90:
y = x-32
else:
y = x + 32
load_str_list[i]= chr(y)
res =''
for j in range(ls_len):
res = res + load_str_list[j]
sys.stdout.write("\r"+res + animation[anicount])
sys.stdout.flush()
load_str = res
anicount = (anicount + 1)% 4
i =(i + 1)% ls_len
counttime = counttime + 1
if os.name =="nt":
os.system("cls")
else:
os.system("clear")
if __name__ == '__main__':
load_animation()
s ="!"
sys.stdout.write("Ready to Travel"+str(s)+"\n")
init()
print("""
████████╗██╗░░██╗███████╗ ████████╗██╗███╗░░░███╗███████╗
╚══██╔══╝██║░░██║██╔════╝ ╚══██╔══╝██║████╗░████║██╔════╝
░░░██║░░░███████║█████╗░░ ░░░██║░░░██║██╔████╔██║█████╗░░
░░░██║░░░██╔══██║██╔══╝░░ ░░░██║░░░██║██║╚██╔╝██║██╔══╝░░
░░░██║░░░██║░░██║███████╗ ░░░██║░░░██║██║░╚═╝░██║███████╗
░░░╚═╝░░░╚═╝░░╚═╝╚══════╝ ░░░╚═╝░░░╚═╝╚═╝░░░░░╚═╝╚══════╝
███╗░░░███╗░█████╗░░█████╗░██╗░░██╗██╗███╗░░██╗███████╗
████╗░████║██╔══██╗██╔══██╗██║░░██║██║████╗░██║██╔════╝
██╔████╔██║███████║██║░░╚═╝███████║██║██╔██╗██║█████╗░░
██║╚██╔╝██║██╔══██║██║░░██╗██╔══██║██║██║╚████║██╔══╝░░
██║░╚═╝░██║██║░░██║╚█████╔╝██║░░██║██║██║░╚███║███████╗
╚═╝░░░░░╚═╝╚═╝░░╚═╝░╚════╝░╚═╝░░╚═╝╚═╝╚═╝░░╚══╝╚══════╝""")
print(colored(' Coded with Love by Anmol K Sachan @Fr13ND0x7f\n','green'))
if __name__ == "__main__":
for i, arg in enumerate(sys.argv):
i = (f"{arg}")
# exit the program if no target is given
if "thetimemachine" in i:
print("No target is given.")
exit()
print("Usage : thetimemachine.py target.com\n")
print("Checking Your Internet Connection...")
thetimemachine = 'https://web.archive.org/'
try:
response = requests.get(thetimemachine)
print(f"\nThe Time Machine got WayBackMachine's Status Code as: {response.status_code}")
print(colored('\nOK!, The Time Machine Will Work\nInternet Connection is Active.', 'green'))
response.close()
except:
print(colored('Boo! The Time Machine got invalid status code tool might not work properly in offline mode, check your internet connection. ', 'red'))
print(f"\nUnable to load: {colored(i, 'red')}")
print(colored('\nExiting!!!', 'red'))
exit()
url = f'https://web.archive.org/cdx/search/cdx?url=*.{i}/*&output=txt&fl=original&collapse=urlkey&page=/'
print("\nTarget Loaded:", (colored(i, 'green')))
print('\nFetching URLs from The Time Machine :P \nHave Patience this may take some time depending on the size of asset\n[Dont press Enter or anykey while TheTimeMachine is Fetching URLs]')
response = requests.get(url)
url_list = response.text
# "content/"+target+"_URLs.txt"
ct = datetime.datetime.now()
print("Current time :", ct)
if not os.path.exists("content/" + i):
os.makedirs("content/" + i)
print(colored("Data will be stored in content/" + i, 'red'))
targetFile = "content/" + i + "/" + i + "_URLs.txt"
print("Storing links in :", (colored(targetFile, 'green')))
xssFile = "content/" + i + "/" + i + "_xss.txt"
openRedirect = "content/" + i + "/" + i + "_OpenRedirect.txt"
lfi = "content/" + i + "/" + i + "_lfi.txt"
sqli = "content/" + i + "/" + i + "_sqli.txt"
jira = "content/" + i + "/" + i + "_jira.txt"
subdomainFile = "content/" + i + "/" + i + "_subdomain.txt"
wp = "content/" + i + "/" + i + "_wp.txt"
customFuzz = "content/" + i + "/" + i + "_customFuzz.txt"
file = open(targetFile, 'w')
file.write(url_list)
file.close()
print('Completed\n')
file = open(targetFile, "r")
Counter = 0
Content = file.read()
CoList = Content.split("\n")
for i in CoList:
if i:
Counter += 1
print("Found", (colored(Counter, 'green')), "instances in The Time Machine, Stored in ", targetFile)
# Find Subdomains
txt = open(targetFile, 'r')
lines = txt.readlines()
lines = [line.strip()+"/" for line in lines]
txt.close()
regex = "://(.*?)\.(.*?)/"
uniques = []
for i in lines:
matches = re.search(regex, i)
output = matches.group()
data = 'http' + output + '\n'
if data not in uniques:
uniques.append(data)
uniques.append('https' + output + '\n')
out = open(subdomainFile, 'w')
out.writelines(uniques)
out.flush()
out.close()
# Find Subdomains
file = open(subdomainFile, "r")
sub = 0
Content = file.read()
CoList = Content.split("\n")
for i in CoList:
if i:
sub += 1
print("\nFound", (colored(sub,'green')), "subdomains instances in The Time Machine (all instances http and https are included)")
print("Stored in", (colored(subdomainFile, 'green')))
def paramFinder():
print(colored("\n...Fetch All Parameters From Custom File...", 'white', 'on_green'))
findme = input("Enter location of file Eg. (target.com_URLs.txt) :")
parameter = findme + "_param.txt"
pattern = re.compile("([\d\w]*?)=([\d\w+-_%()]*)")
file = open(parameter, "w")
for i, line in enumerate(open(findme)):
for match in re.finditer(pattern, line):
print(colored("URL : ", 'red'), line, colored("\nFound on Line:", 'red'), i + 1, colored("\nParameter:", 'red'), match.group())
file.write(match.group())
file.write('\n')
file.close()
print("\nAll Found parameters are Stored in", (colored(parameter, 'green')))
def exit_or_explore():
print(colored("\n---- [Select from below options] ----", 'white', 'on_green'))
print("1: Fetch /api/ endpoint")
print("2: Fetch JSON in URL")
print("3: Fetch conf(Config Possibility) in URL")
print("4: All Possible Sensitive instances in URL from TheTimeMachine (Searches from Fuzz List) or Add Custom List")
print("5: Show Fetched Links from:", targetFile, "having", Counter, "instances")
print("6: Show subdomains from TheTimeMachine, Found", sub, "instances")
print("7: Enter Custom Keyword of your choice")
print("8:", colored("Attack Mode [Possible Vulnerable Endpoint : JIRA, XSS, Open Redirect, LFI, SQLi] ", 'red'))
print("9: Fetch Only Parameters From File")
print("10: Exit")
while True:
try:
inp = int(input("\nEnter a number: "))
except ValueError:
print(colored("Enter a valid option", 'red'))
else:
break
if inp == 1:
pattern = "/api/"
patterns = " "
print('\nFetching selected', pattern , 'input Given', inp , '\n')
with open(targetFile) as file:
for line in file:
urls = re.findall('(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})', line)
if re.search(pattern, line):
print(urls)
exit_or_explore()
elif inp == 2:
pattern = "JSON"
patterns = " "
print('\nFetching selected', pattern , 'input Given', inp , '\n')
with open(targetFile) as file:
for line in file:
urls = re.findall('(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})', line)
if re.search(pattern, line):
print(urls)
exit_or_explore()
elif inp == 3:
pattern = "conf"
patterns = " "
print('\nFetching selected', pattern , 'input Given', inp , '\n')
with open(targetFile) as file:
for line in file:
urls = re.findall('(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})', line)
if re.search(pattern, line):
print(urls)
exit_or_explore()
elif inp == 7:
pattern = input("\nEnter Custom Keyword to search (Blank output means Not Found): ")
patterns = " "
print('\nFetching custom instance', pattern , 'input Given', inp , '\n')
with open(targetFile) as file:
for line in file:
urls = re.findall('(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})', line)
if re.search(pattern, line):
print(urls)
exit_or_explore()
elif inp == 4:
print(colored("\n---- [Select from below options] ----", 'white', 'on_green'))
print("1: Use Default Fuzz.txt")
print("2: Add your own list")
option = int(input("\nEnter a number: "))
if option == 1:
patterns = "\nFuzzing from default Fuzz.txt\n"
print(patterns)
keyfile = "db/fuzz.txt"
testfile = targetFile
keys = set(key.lower() for key in
re.findall(r'\w+', open(keyfile , "r").readline()))
with open(testfile) as f:
for line in f:
words = set(word.lower() for word in re.findall(r'\w+', line))
if keys & words:
print(line, end = '')
exit_or_explore()
elif option == 2:
patterns = "\nFuzzing from custom list\n"
print(patterns)
keyfile = (input("Enter location of file: "))
testfile = targetFile
keys = set(key.lower() for key in
re.findall(r'\w+', open(keyfile , "r").readline()))
with open(testfile) as f:
for line in f:
words = set(word.lower() for word in re.findall(r'\w+', line))
if keys & words:
print(line, end = '')
exit_or_explore()
else:
print("Wrong Option")
exit_or_explore()
elif inp == 5:
file = open(targetFile, "r")
Content = file.read()
print(Content)
exit_or_explore()
elif inp == 6:
print("Stored in :", subdomainFile," found ", sub, " instances from TheTimeMachine")
file = open(subdomainFile, "r")
Content = file.read()
print(Content)
exit_or_explore()
elif inp == 9:
paramFinder()
exit_or_explore()
elif inp == 8:
print(colored("\nAttack Mode Loaded", 'white', 'on_green'))
print("1: Fetch Possible XSS Vulnerable Endpoint")
print("2: Fetch Possible Open Redirection Vulnerable Endpoint")
print("3: Fetch Possible LFI Vulnerable Endpoint")
print("4: Fetch Possible SQLi Vulnerable Endpoint")
print("5: Fetch Possible JIRA Vulnerable Endpoint")
print("6: Fetch Possible WordPress Vulnerable Endpoint")
print("7: Fetch Custom Vulnerable Endpoint Ref Files available here : https://github.com/danielmiessler/SecLists/tree/master/Discovery ")
print("8: Back")
while True:
try:
option = int(input("\nEnter a number: "))
except ValueError:
print(colored("Enter a valid option", 'red'))
else:
break
if option == 1:
patterns = "\nFinding Possible XSS Vulnerable links\n"
print(patterns)
print(f"Storing links in : {colored(xssFile, 'green')}")
keyfile = "db/xss.txt"
testfile = targetFile
k = open(keyfile,"r")
t = open(testfile,"r")
file = open(xssFile, 'w')
lines = t.readlines()
patterns = [i.strip() for i in k.readlines()]
for l in lines:
for p in patterns:
if p in l:
print(l)
file.write(str(l))
file.close()
print('Completed\n')
print(f"Stored in {colored(xssFile, 'green')}")
exit_or_explore()
elif option == 2:
patterns = "\nFuzzing for Possible Open Redirect Vulnerable links\n"
print(patterns)
keyfile = "db/openredirect.txt"
testfile = targetFile
k = open(keyfile, "r")
t = open(testfile, "r")
file = open(openRedirect, 'w')
lines = t.readlines()
patterns = [i.strip() for i in k.readlines()]
for l in lines:
for p in patterns:
if p in l:
print(l)
file.write(str(l))
file.close()
print('Completed\n')
print(f"Stored in {colored(openRedirect, 'green')}")
exit_or_explore()
if option == 3:
patterns = "\nFinding Possible LFI Vulnerable links\n"
print(patterns)
keyfile = "db/lfi.txt"
testfile = targetFile
k = open(keyfile, "r")
t = open(testfile, "r")
file = open(lfi, 'w')
lines = t.readlines()
patterns = [i.strip() for i in k.readlines()]
for l in lines:
for p in patterns:
if p in l:
print(l)
file.write(str(l))
file.close()
print('Completed\n')
print(f"Stored in {colored(lfi, 'green')}")
exit_or_explore()
if option == 4:
patterns = "\nFinding Possible SQLi Vulnerable links\n"
print(patterns)
keyfile = "db/sqli.txt"
testfile = targetFile
k = open(keyfile, "r")
t = open(testfile, "r")
file = open(sqli, 'w')
lines = t.readlines()
patterns = [i.strip() for i in k.readlines()]
for l in lines:
for p in patterns:
if p in l:
print(l)
file.write(str(l))
file.close()
print('Completed\n')
print(f"Stored in {colored(sqli, 'green')}")
exit_or_explore()
if option == 5:
patterns = "\nFinding Possible JIRA Vulnerable links\nHow to Exploit: https://gist.github.com/0x240x23elu/891371d46a1e270c7bdded0469d8e09c\n"
print(patterns)
keyfile = "db/jira.txt"
testfile = targetFile
k = open(keyfile, "r")
t = open(testfile, "r")
file = open(jira, 'w')
lines = t.readlines()
patterns = [i.strip() for i in k.readlines()]
for l in lines:
for p in patterns:
if p in l:
print(l)
file.write(str(l))
file.close()
print('Completed\n')
print(f"Stored in {colored(jira, 'green')}")
exit_or_explore()
if option == 6:
patterns = "\nFinding Possible WordPress Vulnerable links\n"
print(patterns)
keyfile = "db/wp-fuzz.txt"
testfile = targetFile
k = open(keyfile, "r")
t = open(testfile, "r")
file = open(wp, 'w')
lines = t.readlines()
patterns = [i.strip() for i in k.readlines()]
for l in lines:
for p in patterns:
if p in l:
print(l)
file.write(str(l))
file.close()
print('Completed\n')
print(f"Stored in {colored(wp, 'green')}")
exit_or_explore()
if option == 7:
print("Custom Fuzz xD")
keyfile = (input("Enter location of file: "))
testfile = targetFile
k = open(keyfile, "r")
t = open(testfile, "r")
file = open(customFuzz, 'w')
lines = t.readlines()
patterns = [i.strip() for i in k.readlines()]
for l in lines:
for p in patterns:
if p in l:
print(l)
file.write(str(l))
file.close()
print('Completed\n')
print(f"Stored in {colored(customFuzz, 'green')}")
exit_or_explore()
else:
print(colored("Switching to main Menu", 'red'))
exit_or_explore()
else:
sys.exit("Quitting! Have a nice day ahead.")
exit_or_explore()