forked from AnonKryptiQuz/TimeVault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeVault.py
184 lines (150 loc) · 6.49 KB
/
TimeVault.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
import os
import sys
import time
import subprocess
import importlib.util
import signal
import requests
import re
import urllib.parse
from urllib.parse import urlparse
from concurrent.futures import ThreadPoolExecutor, as_completed
from colorama import Fore, Style, init
import validators
init(autoreset=True)
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
def is_package_installed(package):
return importlib.util.find_spec(package) is not None
def install_package(package):
try:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
print(f"{Fore.GREEN}[+] {package} installed successfully.")
except subprocess.CalledProcessError:
print(f"{Fore.RED}[!] Failed to install {package}.")
def check_and_install_packages(packages):
for package in packages:
if is_package_installed(package):
print(f"{Fore.GREEN}[+] {package} is already installed.")
else:
print(f"{Fore.YELLOW}[!] {package} is missing. Installing...")
install_package(package)
def load_config():
return ["colorama", "requests", "validators"]
def handle_interrupt(signal, frame):
print(f"\n{Fore.RED}[!] Program interrupted. Exiting...")
sys.exit(0)
def get_domain(url):
parsed_url = urlparse(url)
domain = parsed_url.netloc
if domain.startswith("www."):
domain = domain[4:]
return domain
def fetch_status_code(url):
try:
head_response = requests.head(url, timeout=5)
return url, head_response.status_code
except requests.exceptions.Timeout:
return url, "Error: Timeout"
except requests.exceptions.RequestException as e:
return url, "UNKNOWN"
def fetch_and_filter_wayback_info(domain):
found_urls = 0
urls_to_save = []
start_time = time.time()
print(f"{Fore.MAGENTA}Starting the Scan on: {Fore.WHITE}{domain}")
time.sleep(2)
print(f"{Fore.YELLOW}\n[i] Loading, please wait...\n")
base_url = "https://web.archive.org/cdx/search/cdx"
params = {
'url': f"*.{domain}/*",
'collapse': 'urlkey',
'output': 'text',
'fl': 'original'
}
file_extensions_regex = r'\.xls|\.xml|\.xlsx|\.json|\.pdf|\.sli|\.doc|\.docx|\.pptx|\.txt|\.zip|\.tar|\.gz|\.tgz|\.bak|\.7z|\.rar|\.log|\.cache|\.secret|\.db|\.backup|\.yml|\.gz|\.config|\.csv|\.yaml|\.md|\.md5|\.exe|\.dll|\.bin|\.ini|\.bat|\.sh|\.deb|\.rpm|\.iso|\.img|\.apk|\.msi|\.dmg|\.tmp|\.crt|\.pem|\.key|\.pub|\.asc'
try:
response = requests.get(base_url, params=params)
if response.status_code == 200:
urls = response.text.splitlines()
filtered_urls = [url.strip() for url in urls if re.search(file_extensions_regex, url)]
if filtered_urls:
with ThreadPoolExecutor() as executor:
futures = {executor.submit(fetch_status_code, url): url for url in filtered_urls}
for idx, future in enumerate(as_completed(futures), start=1):
url, status_code = future.result()
encoded_url = urllib.parse.quote(url, safe=':/')
index_str = f"({idx:02})"
if "Error" in str(status_code):
print(f"{Fore.MAGENTA}{index_str}{Fore.GREEN} Found: {Fore.WHITE}{url} {Fore.BLUE} - Status code: {status_code}")
else:
print(f"{Fore.MAGENTA}{index_str}{Fore.GREEN} Found: {Fore.WHITE}{url} {Fore.BLUE} - Status code: {status_code}")
print(f"{Fore.MAGENTA} → {Fore.CYAN}URL: {Fore.WHITE}https://web.archive.org/web/*/{encoded_url}")
print()
found_urls += 1
urls_to_save.append(url)
else:
print(f"{Fore.RED}[!] No matching URLs found.\n")
else:
print(f"{Fore.RED}[!] Failed to fetch data Status code. Please try again...\n")
except Exception as e:
print(f"{Fore.RED}[!] Error: {e}")
end_time = time.time()
time_taken = end_time - start_time
print(f"{Fore.YELLOW}[*] Scanning Finished.")
time.sleep(1)
print(f"{Fore.YELLOW}[*] Total Found: {found_urls}")
print(f"{Fore.YELLOW}[*] Time Taken: {time_taken:.2f} seconds")
if found_urls > 0:
save_urls = input(f"{Fore.WHITE}\n[?] Do you want to save the URLs to output.txt? (y/n) [default: n]: ").strip().lower()
if save_urls == 'y':
with open("output.txt", "w") as f:
for url in urls_to_save:
f.write(url + "\n")
print(f"{Fore.GREEN}[+] URLs saved to output.txt")
else:
print(f"{Fore.RED}[-] URLs not saved")
def validate_url(url):
if validators.url(url):
return True
else:
print(f"{Fore.RED}[!] Invalid URL. Please enter a valid URL.")
return False
def Banner():
print(rf"{Fore.GREEN} _____ _ _ _ ")
print(rf"{Fore.GREEN} /__ (_)_ __ ___ ___/\ /\__ _ _ _| | |_ ")
print(rf"{Fore.GREEN} / /\/ | '_ ` _ \ / _ \ \ / / _` | | | | | __| ")
print(rf"{Fore.GREEN} / / | | | | | | | __/\ V / (_| | |_| | | |_ ")
print(rf"{Fore.GREEN} \/ |_|_| |_| |_|\___| \_/ \__,_|\__,_|_|\__| ")
print("")
created_by_text = "Program created by: AnonKryptiQuz"
ascii_width = 49
padding = (ascii_width - len(created_by_text)) // 2
print(" " * padding + f"{Fore.RED}{created_by_text}")
print("")
def main():
signal.signal(signal.SIGINT, handle_interrupt)
clear_screen()
print(f"{Fore.YELLOW}[i] Checking for required packages...\n")
required_packages = load_config()
check_and_install_packages(required_packages)
time.sleep(3)
clear_screen()
Banner()
while True:
url = input("[?] Enter the website URL (e.g., https://google.com): ")
if validate_url(url):
break
input(f"{Fore.YELLOW}[i] Press Enter to try again...")
clear_screen()
Banner()
print(f"{Fore.YELLOW}\n[i] Loading, please wait...")
time.sleep(3)
clear_screen()
domain = get_domain(url)
fetch_and_filter_wayback_info(domain)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print(f"{Fore.RED}\n[!] Operation interrupted. Exiting...")