-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInformationDisclosure.py
More file actions
134 lines (111 loc) · 4.57 KB
/
Copy pathInformationDisclosure.py
File metadata and controls
134 lines (111 loc) · 4.57 KB
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
import subprocess
import time
import os
import json
from colorama import Fore, Style
from split import split_by_extension
f_check = False
f_type = []
def show_intro():
os.system("clear" if os.name != "nt" else "cls")
print(Fore.CYAN + Style.BRIGHT)
print('''
.___ _____ ________ .__
| | ____ _/ ____\____ \______ \ |__| ______ ____
| | / \\ __\/ _ \ | | \ | | / ___/_/ ___\
| || | \| | ( <_> ) | ` \| | \___ \ \ \___
|___||___| /|__| \____/ /_______ /|__|/____ > \___ >
\/ \/ \/ \/ <33
''')
print(Fore.GREEN + Style.BRIGHT + "Version: dev-alpha-2.2\n" + Style.RESET_ALL)
print("Created by: " + Fore.RED, Style.BRIGHT + "X3r0Day" + Style.RESET_ALL)
print(Fore.YELLOW + "\nA tool to query and analyze archived data from the Wayback Machine.\n" + Style.RESET_ALL)
# time.sleep(2)
def execute_command(command):
try:
result = subprocess.run(command, shell=True, capture_output=True, text=True, check=True)
return result.stdout
except subprocess.CalledProcessError as e:
return f"Error: {e.stderr}"
def basic_query(url, limit=5000):
command = f"""
curl -G "https://web.archive.org/cdx/search/cdx" \
--http1.1 \
--data-urlencode "url={url}/*" \
--data-urlencode "collapse=urlkey" \
--data-urlencode "output=text" \
--data-urlencode "fl=original" \
--data-urlencode "limit={limit}"
"""
return execute_command(command)
def load_extensions(filename='file_extensions.json'):
try:
with open(filename, 'r') as f:
data = json.load(f)
return data.get("extensions", [])
except Exception as e:
print(Fore.RED + f"Error reading JSON file: {e}")
return []
def filter_files(query_result, extensions):
filtered_lines = []
for line in query_result.splitlines():
if any(ext in line for ext in extensions):
filtered_lines.append(line)
return "\n".join(filtered_lines)
def save_to_file(content, filename='output.txt'):
with open(filename, 'w') as f:
f.write(content)
print(Fore.GREEN + f"Results saved to {filename}.")
def menu():
show_intro() # Show the intro when the program starts
extensions = []
while True:
os.system('clear') # fuck windows who cares
show_intro()
print(Fore.CYAN + Style.BRIGHT + "===== Menu =====")
print("1. Execute Basic Query")
print("2. Load Filter Extensions from JSON")
print("3. Filter out output.txt")
print("4. Exit")
print(Fore.CYAN + Style.BRIGHT + "===== Menu =====")
choice = input(Fore.YELLOW + "Choose an option: ")
if choice == '1':
url = input(Fore.GREEN + "Enter URL to query: ")
limit = int(input("Enter search result limit (default: 5000): ") or 5000)
if limit >= 10000:
print("Note: This tool may take time to finish (7-10mins [depends]) to complete scan!")
result = basic_query(url, limit)
if extensions:
result = filter_files(result, extensions)
print(Fore.GREEN + f"Filtered Result (extensions: {', '.join(extensions)}):\n")
else:
print(Fore.GREEN + "Result:\n")
print(result)
save_to_file(result) # Save the filtered result to output.txt
sort = input("Do you want to sort the files into respect extension files? y/N: ").lower()
if sort == "y":
split_by_extension("output.txt")
#input(Fore.MAGENTA + "Press ENTER to continue...")
break
else:
break
input(Fore.MAGENTA + "Press ENTER to continue...")
elif choice == '2':
# Load file extensions from JSON file
extensions = load_extensions()
if extensions:
print(Fore.GREEN + f"Loaded extensions: {', '.join(extensions)}")
else:
print(Fore.RED + "Failed to load extensions.")
input(Fore.MAGENTA + "Press ENTER to continue...")
elif choice == '4':
print(Fore.RED + "Exiting...")
time.sleep(1)
break
elif choice == '3':
split_by_extension("output.txt")
input(Fore.MAGENTA + "Press ENTER to continue...")
else:
time.sleep(0.3)
if __name__ == "__main__":
menu()