-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiple_URLs.py
More file actions
201 lines (170 loc) · 6.71 KB
/
Copy pathMultiple_URLs.py
File metadata and controls
201 lines (170 loc) · 6.71 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
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
import requests
import time
import random
import string
from urllib.parse import urljoin
from concurrent.futures import ThreadPoolExecutor, as_completed
from threading import Lock
# Credits: RandomUsernames1 / Abelia / Sg /
# ================= COLORS =================
GREEN = "\033[92m"
RED = "\033[91m"
YELLOW = "\033[93m"
MAGENTA = "\033[95m"
CYAN = "\033[96m"
BOLD = "\033[1m"
RESET = "\033[0m"
# ================= CONFIG =================
TIMEOUT = 6
THREADS = 15
HEADERS = {"User-Agent": "AdvancedEndpointScanner/FAST"}
# ================= ENDPOINTS =================
BASE_ENDPOINTS = [
"/index.html","/index.html.en","/.htaccess","/.htpasswd",
"/.htaccess~","/.htaccess.bak","/.htaccess.old","/.htaccess.save",
"/.htpasswd~","/.htpasswd.bak","/.htpasswd.old",
"/httpd.conf","/apache2.conf","/ports.conf","/envvars",
"/mime.types","/magic",
"/conf/","/conf.d/","/apache/","/apache2/",
"/apache2/conf/","/apache2/conf.d/",
"/apache2/sites-available/","/apache2/sites-enabled/",
"/apache2/mods-available/","/apache2/mods-enabled/",
"/etc/apache2/","/etc/httpd/","/etc/httpd/conf/",
"/etc/httpd/conf.d/","/etc/httpd/sites-enabled/",
"/server-status","/server-status/",
"/server-info","/server-info/",
"/logs/","/log/","/access.log","/error.log","/access_log","/error_log",
"/apache.log","/apache2.log",
"/var/log/apache/access.log","/var/log/apache2/access.log",
"/var/log/apache/error.log","/var/log/apache2/error.log",
"/manual/","/manual/index.html",
"/icons/","/icons/README",
"/cgi-bin/","/cgi-bin/test-cgi",
"/cgi/","/scripts/","/bin/","/perl/","/python/",
"/uploads/","/upload/","/files/","/file/",
"/backup/","/backups/","/bak/","/old/",
"/tmp/","/temp/","/test/","/tests/",
"/dev/","/private/","/data/","/docs/",
"/.git/","/.git/config","/.git/HEAD","/.git/index",
"/.svn/","/.hg/","/CVS/",
"/.env","/env",
"/phpinfo.php","/info.php","/test.php","/debug.php",
"/config.php","/settings.php",
"/login","/login.php",
"/admin","/admin/","/admin.php","/admin/login",
"/dashboard","/manager","/manage",
"/.proc/","/.proc/self/","/.proc/version",
"/.bash_history","/.ssh/","/.ssh/authorized_keys",
"/site.zip","/backup.zip","/www.zip","/html.zip",
"/source.zip","/code.zip",
"/database.sql","/db.sql","/dump.sql",
"/vendor/","/node_modules/",
"/composer.json","/composer.lock",
"/package.json","/yarn.lock",
"/web.config","/httpd.ini","/server.xml",
]
COMMON_FILES = ["index.php","config.php","login.php",".htaccess",".env"]
WILDCARD_EXTS = [".bak",".old",".orig",".save",".swp",".swo","~"]
# ================= HELPERS =================
def normalize_url(u):
u = u.strip()
if not u:
return None
if not u.startswith("http"):
u = "http://" + u
return u
def random_404():
return "/" + "".join(random.choices(string.ascii_letters + string.digits, k=30))
def get_404_len(base):
try:
r = requests.get(urljoin(base, random_404()), timeout=TIMEOUT, allow_redirects=False, headers=HEADERS)
return len(r.text)
except:
return None
def build_endpoints():
eps = set(BASE_ENDPOINTS)
for f in COMMON_FILES:
for e in WILDCARD_EXTS:
eps.add("/" + f + e)
return sorted(eps)
def check_endpoint(base, ep, nf_len):
try:
r = requests.get(urljoin(base, ep), timeout=TIMEOUT, allow_redirects=False, headers=HEADERS)
if r.status_code in (301,302,303,307,308):
return "REDIRECT", r.status_code
if r.status_code == 200 and len(r.text) == nf_len:
return "MISS", "Fake 200"
if r.status_code in (200,401,403):
return "FOUND", r.status_code
return "MISS", r.status_code
except requests.exceptions.Timeout:
return "ERROR", "Timeout"
except requests.exceptions.SSLError:
return "ERROR", "SSL"
except requests.exceptions.ConnectionError:
return "ERROR", "Connection"
except Exception as e:
return "ERROR", str(e)
# ================= MAIN =================
def main():
file_path = input("Enter file with URLs: ").strip()
with open(file_path) as f:
urls = [normalize_url(x) for x in f if normalize_url(x)]
endpoints = build_endpoints()
lock = Lock()
final_results = {}
global_stats = {"FOUND":0,"MISS":0,"REDIRECT":0,"ERROR":0}
start_all = time.time()
for url in urls:
print(f"\n{CYAN}{BOLD}Scanning {url}{RESET}")
nf_len = get_404_len(url)
if nf_len is None:
print(f"{MAGENTA}[ERROR]{RESET} Could not detect 404 behavior")
continue
url_stats = {"FOUND":[], "MISS":0, "REDIRECT":0, "ERROR":0}
t0 = time.time()
with ThreadPoolExecutor(max_workers=THREADS) as exe:
futures = {exe.submit(check_endpoint, url, ep, nf_len): ep for ep in endpoints}
for f in as_completed(futures):
ep = futures[f]
status, detail = f.result()
with lock:
global_stats[status] += 1
if status == "FOUND":
url_stats["FOUND"].append((ep, detail))
print(f"{GREEN}[FOUND]{RESET} {ep}")
else:
url_stats[status] += 1
url_stats["time"] = time.time() - t0
final_results[url] = url_stats
# ================= FINAL REPORT =================
total_time = time.time() - start_all
print(f"\n{BOLD}{CYAN}{'='*95}{RESET}")
print(f"{BOLD}{CYAN} FINAL MULTI‑THREADED SCAN REPORT {RESET}")
print(f"{BOLD}{CYAN}{'='*95}{RESET}")
print(f"""
{BOLD}URLs scanned:{RESET} {len(final_results)}
{BOLD}Endpoints checked:{RESET} {len(endpoints)}
{BOLD}Threads used:{RESET} {THREADS}
{BOLD}Total runtime:{RESET} {total_time:.2f}s
{GREEN}FOUND:{RESET} {global_stats['FOUND']}
{RED}NOT FOUND:{RESET} {global_stats['MISS']}
{YELLOW}REDIRECT:{RESET} {global_stats['REDIRECT']}
{MAGENTA}ERROR:{RESET} {global_stats['ERROR']}
""")
for url, data in final_results.items():
print(f"{CYAN}{'-'*85}{RESET}")
print(f"{BOLD}{url}{RESET}")
print(f"Time: {data['time']:.2f}s")
print(f"{GREEN}FOUND:{RESET} {len(data['FOUND'])} | "
f"{RED}MISS:{RESET} {data['MISS']} | "
f"{YELLOW}REDIRECT:{RESET} {data['REDIRECT']} | "
f"{MAGENTA}ERROR:{RESET} {data['ERROR']}")
if data["FOUND"]:
print(f"{GREEN}--- FOUND ENDPOINTS ---{RESET}")
for ep, code in data["FOUND"]:
print(f" {ep} → HTTP {code}")
print(f"{BOLD}{CYAN}{'='*95}{RESET}")
print(f"{BOLD}{GREEN}Scan complete. Fast + clean + low false positives.{RESET}")
if __name__ == "__main__":
main()