Repository navigation
Expand file tree
/
Copy pathglassfuzz.py
More file actions
947 lines (831 loc) · 30.5 KB
/
Copy pathglassfuzz.py
File metadata and controls
947 lines (831 loc) · 30.5 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
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
#!/usr/bin/env python3
r"""
________ ______
/ ____/ /___ ___________/ ____/_ __________
/ / __/ / __ `/ ___/ ___/ /_ / / / /_ /_ /
/ /_/ / / /_/ (__ |__ ) __/ / /_/ / / /_/ /_
\____/_/\__,_/____/____/_/ \__,_/ /___/___/
Stealth Web Fuzzer - WAF/IDS Evasion Tool
"""
import argparse
import base64
import gzip
import http.client
import json
import os
import queue
import random
import re
import signal
import ssl
import sys
import threading
import time
import urllib.parse
from datetime import datetime
VERSION = "1.0.0"
DEFAULT_THREADS = 10
DEFAULT_TIMEOUT = 10
DEFAULT_JITTER_MIN = 100
DEFAULT_JITTER_MAX = 500
MAX_RATE_LIMIT_BACKOFF = 30000
RATE_LIMIT_COOLDOWN = 60
CHROMIUM_VERSIONS = (
"128.0.6613.138",
"129.0.6668.101",
"130.0.6723.116",
"131.0.6778.265",
"132.0.6834.160",
"133.0.6943.142",
"134.0.6998.166",
"135.0.7049.114",
"136.0.7103.113",
"137.0.7151.120",
)
FIREFOX_VERSIONS = ("128.0", "130.0", "132.0", "134.0", "135.0", "136.0", "137.0")
SAFARI_VERSIONS = ("17.5", "17.6", "18.0", "18.1", "18.3", "18.5")
WINDOWS_PLATFORMS = (
"Windows NT 10.0; Win64; x64",
"Windows NT 10.0; WOW64",
)
MAC_PLATFORMS = (
"Macintosh; Intel Mac OS X 10_15_7",
"Macintosh; Intel Mac OS X 13_6_6",
"Macintosh; Intel Mac OS X 14_5",
"Macintosh; Intel Mac OS X 14_7_5",
"Macintosh; Intel Mac OS X 15_3_2",
)
LINUX_PLATFORMS = (
"X11; Linux x86_64",
"X11; Ubuntu; Linux x86_64",
"X11; Fedora; Linux x86_64",
)
ANDROID_DEVICES = (
("13", "Pixel 7", True),
("14", "Pixel 8 Pro", True),
("15", "Pixel 9", True),
("13", "SM-G991B", True),
("14", "SM-S918B", True),
("14", "SM-A546B", True),
("14", "SM-X710", False),
("15", "Pixel Tablet", False),
)
IOS_DEVICES = (
("iPhone", "17_6"),
("iPhone", "18_1"),
("iPhone", "18_3"),
("iPhone", "18_5"),
("iPad", "17_6"),
("iPad", "18_3"),
)
COLORS = {
"green": "\033[92m",
"yellow": "\033[93m",
"red": "\033[91m",
"blue": "\033[94m",
"cyan": "\033[96m",
"magenta": "\033[95m",
"dim": "\033[2m",
"bold": "\033[1m",
"reset": "\033[0m",
}
class UserAgentManager:
def __init__(self, custom_agents=None):
self.agents = list(custom_agents) if custom_agents else None
def random(self):
if self.agents:
return random.choice(self.agents)
family = random.choices(
("chromium", "firefox", "safari", "android", "ios"),
weights=(42, 20, 14, 15, 9),
k=1,
)[0]
return getattr(self, f"_build_{family}")()
@staticmethod
def _build_chromium():
all_platforms = WINDOWS_PLATFORMS + MAC_PLATFORMS + LINUX_PLATFORMS
weights = (
[30] * len(WINDOWS_PLATFORMS)
+ [9] * len(MAC_PLATFORMS)
+ [7] * len(LINUX_PLATFORMS)
)
platform = random.choices(all_platforms, weights=weights, k=1)[0]
version = random.choice(CHROMIUM_VERSIONS)
browser = random.choices(("chrome", "edge"), weights=(82, 18), k=1)[0]
suffix = f" Edg/{version}" if browser == "edge" else ""
return (
f"Mozilla/5.0 ({platform}) AppleWebKit/537.36 "
f"(KHTML, like Gecko) Chrome/{version} Safari/537.36{suffix}"
)
@staticmethod
def _build_firefox():
platform = random.choice(
WINDOWS_PLATFORMS + MAC_PLATFORMS + LINUX_PLATFORMS
)
version = random.choice(FIREFOX_VERSIONS)
return (
f"Mozilla/5.0 ({platform}; rv:{version}) "
f"Gecko/20100101 Firefox/{version}"
)
@staticmethod
def _build_safari():
platform = random.choice(MAC_PLATFORMS)
version = random.choice(SAFARI_VERSIONS)
return (
f"Mozilla/5.0 ({platform}) AppleWebKit/605.1.15 "
f"(KHTML, like Gecko) Version/{version} Safari/605.1.15"
)
@staticmethod
def _build_android():
android, device, is_mobile = random.choice(ANDROID_DEVICES)
version = random.choice(CHROMIUM_VERSIONS)
mobile = " Mobile" if is_mobile else ""
browser = random.choices(("chrome", "samsung"), weights=(78, 22), k=1)[0]
if browser == "samsung":
product = (
f"SamsungBrowser/{random.choice((24, 25, 26, 27))}.0 "
f"Chrome/{version}"
)
else:
product = f"Chrome/{version}"
return (
f"Mozilla/5.0 (Linux; Android {android}; {device}) "
f"AppleWebKit/537.36 (KHTML, like Gecko) {product}"
f"{mobile} Safari/537.36"
)
@staticmethod
def _build_ios():
device, os_version = random.choice(IOS_DEVICES)
cpu = (
f"CPU iPhone OS {os_version} like Mac OS X"
if device == "iPhone"
else f"CPU OS {os_version} like Mac OS X"
)
browser = random.choices(("safari", "chrome", "firefox"), weights=(70, 20, 10), k=1)[0]
version = os_version.replace("_", ".")
if browser == "chrome":
product = f"CriOS/{random.choice(CHROMIUM_VERSIONS)}"
elif browser == "firefox":
product = f"FxiOS/{random.choice(FIREFOX_VERSIONS)}"
else:
product = f"Version/{version}"
return (
f"Mozilla/5.0 ({device}; {cpu}) AppleWebKit/605.1.15 "
f"(KHTML, like Gecko) {product} Mobile/15E148 Safari/604.1"
)
def load_from_file(self, filepath):
with open(filepath, "r") as f:
self.agents = [line.strip() for line in f if line.strip()] or None
return self
class PayloadEncoder:
@staticmethod
def encode(path, method):
if method == "none":
return path
elif method == "double-url":
encoded_once = urllib.parse.quote(path, safe="")
return urllib.parse.quote(encoded_once, safe="")
elif method == "base64":
return base64.b64encode(path.encode("utf-8")).decode("utf-8")
else:
return path
class AdaptiveDelayManager:
def __init__(self, jitter_min, jitter_max):
self.jitter_min = jitter_min
self.jitter_max = jitter_max
self.original_min = jitter_min
self.original_max = jitter_max
self.consecutive_blocked = 0
self.consecutive_ok = 0
self.multiplier = 1.0
self.lock = threading.Lock()
def report_response(self, status):
with self.lock:
if status in (403, 429):
self.consecutive_blocked += 1
self.consecutive_ok = 0
if self.consecutive_blocked >= 3:
self.multiplier = min(self.multiplier * 1.5, 10.0)
self.jitter_min = int(self.original_min * self.multiplier)
self.jitter_max = int(self.original_max * self.multiplier)
if self.multiplier >= 10.0:
return "cooldown"
elif status < 400:
self.consecutive_ok += 1
if self.consecutive_ok >= 15 and self.multiplier > 1.0:
self.multiplier = max(1.0, self.multiplier * 0.8)
self.jitter_min = int(self.original_min * self.multiplier)
self.jitter_max = int(self.original_max * self.multiplier)
self.consecutive_ok = 0
elif status in (503, 500):
self.consecutive_blocked += 1
self.consecutive_ok = 0
return None
def get_delay(self):
with self.lock:
return random.randint(self.jitter_min, self.jitter_max) / 1000.0
def get_multiplier(self):
with self.lock:
return self.multiplier
def needs_cooldown(self):
with self.lock:
return self.multiplier >= 10.0
class StealthHTTPClient:
def __init__(self, timeout, verify_ssl, follow_redirects, encoder_method, ua_manager):
self.timeout = timeout
self.verify_ssl = verify_ssl
self.follow_redirects = follow_redirects
self.encoder_method = encoder_method
self.ua_manager = ua_manager
self._tls_context = None if verify_ssl else ssl._create_unverified_context()
def request(self, host, port, path, scheme="http", method="GET"):
encoded_path = PayloadEncoder.encode(path, self.encoder_method)
if not encoded_path.startswith("/"):
encoded_path = "/" + encoded_path
headers = {
"User-Agent": self.ua_manager.random(),
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Language": random.choice(
["en-US,en;q=0.9", "en-GB,en;q=0.9", "tr-TR,tr;q=0.9,en;q=0.7"]
),
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Cache-Control": "no-cache",
}
if port and port not in (80, 443):
headers["Host"] = f"{host}:{port}"
else:
headers["Host"] = host
try:
if scheme == "https":
conn = http.client.HTTPSConnection(
host, port=port or 443, timeout=self.timeout, context=self._tls_context
)
else:
conn = http.client.HTTPConnection(
host, port=port or 80, timeout=self.timeout
)
conn.request(method, encoded_path, headers=headers)
response = conn.getresponse()
status = response.status
headers_out = dict(response.getheaders())
body = b""
try:
body = response.read(1048576)
except http.client.IncompleteRead as e:
body = e.partial
conn.close()
content_encoding = (
headers_out.get("Content-Encoding")
or headers_out.get("content-encoding")
or ""
)
if "gzip" in content_encoding.lower():
try:
body = gzip.decompress(body)
except Exception:
pass
redirect = None
if self.follow_redirects and status in (301, 302, 303, 307, 308):
location = headers_out.get("Location") or headers_out.get("location")
if location:
redirect = location
title = self._extract_title(body)
return status, headers_out, body, title, redirect
except (http.client.HTTPException, ConnectionRefusedError,
ConnectionResetError, TimeoutError, OSError, ssl.SSLError) as e:
return None, None, None, None, None
def _extract_title(self, body):
try:
text = body.decode("utf-8", errors="ignore")
match = re.search(r"<title[^>]*>(.*?)</title>", text, re.IGNORECASE | re.DOTALL)
if match:
return match.group(1).strip()
except Exception:
pass
return ""
class ScanResult:
def __init__(self, path, status, length, title, redirect=None):
self.path = path
self.status = status
self.length = length
self.title = title
self.redirect = redirect
def to_dict(self):
return {
"path": self.path,
"status": self.status,
"length": self.length,
"title": self.title,
"redirect": self.redirect,
}
class OutputManager:
def __init__(self, use_color=True):
self.use_color = use_color
self.results = []
self.lock = threading.Lock()
self._printed_header = False
def add_result(self, result):
with self.lock:
self.results.append(result)
def print_live(self, result):
color = self._status_color(result.status)
reset = COLORS["reset"] if self.use_color else ""
title_str = f' "{result.title}"' if result.title else ""
redirect_str = f" -> {result.redirect}" if result.redirect else ""
line = (
f"{color}[{result.status}]{reset} "
f"{' ' * (3 - len(str(result.status)))}"
f"Length: {result.length:<8} "
f"{result.path}{title_str}{redirect_str}"
)
print(line)
sys.stdout.flush()
def print_progress(self, completed, total, found):
pct = (completed / total * 100) if total > 0 else 0
bar_len = 30
filled = int(bar_len * completed / total) if total > 0 else 0
bar = "█" * filled + "░" * (bar_len - filled)
color = COLORS["cyan"] if self.use_color else ""
reset = COLORS["reset"] if self.use_color else ""
print(
f"\r{color}[{bar}]{reset} {completed}/{total} ({pct:.1f}%) | Found: {found}",
end="",
)
sys.stdout.flush()
def print_summary(self):
print()
if not self.results:
print("No results found.")
return
self.results.sort(key=lambda r: r.status)
widths = self._calc_widths()
self._print_separator(widths)
self._print_row(["Status", "Length", "Title", "Path"], widths, bold=True)
self._print_separator(widths)
for r in self.results:
color = self._status_color(r.status)
reset = COLORS["reset"] if self.use_color else ""
status_str = f"{color}{r.status}{reset}"
title_str = r.title[:40] + ".." if len(r.title) > 40 else r.title
self._print_row(
[status_str, str(r.length), title_str, r.path], widths
)
self._print_separator(widths)
print(f"\nTotal: {len(self.results)} results found.")
def _calc_widths(self):
max_path = max((len(r.path) for r in self.results), default=10)
max_title = max((len(r.title) for r in self.results), default=10)
return [8, 10, min(max_title, 42), min(max_path, 60)]
def _print_separator(self, widths):
parts = ["+" + "-" * (w + 1) for w in widths]
print("".join(parts) + "+")
def _print_row(self, cols, widths, bold=False):
row = "|"
for i, col in enumerate(cols):
w = widths[i]
col_str = str(col)[:w]
if bold and self.use_color:
row += f" {COLORS['bold']}{col_str:<{w}}{COLORS['reset']}|"
else:
row += f" {col_str:<{w}}|"
print(row)
def _status_color(self, status):
if not self.use_color:
return ""
if 200 <= status < 300:
return COLORS["green"]
elif 300 <= status < 400:
return COLORS["yellow"]
elif status == 403:
return COLORS["red"]
elif status == 401:
return COLORS["magenta"]
elif status >= 500:
return COLORS["red"]
elif status >= 400:
return COLORS["dim"]
return ""
def save_txt(self, filepath):
with open(filepath, "w") as f:
f.write(f"GlassFuzz Scan Results\n")
f.write(f"{'=' * 60}\n")
f.write(f"Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n")
for r in sorted(self.results, key=lambda x: x.status):
f.write(f"[{r.status}] {r.path} (Length: {r.length})")
if r.title:
f.write(f" - {r.title}")
if r.redirect:
f.write(f" -> {r.redirect}")
f.write("\n")
def save_json(self, filepath):
data = {
"scan_date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"total_results": len(self.results),
"results": [r.to_dict() for r in self.results],
}
with open(filepath, "w") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
def save_state(self, filepath, target_url, completed_paths, total_paths):
state = {
"target_url": target_url,
"completed_paths": list(completed_paths),
"total_paths": total_paths,
"saved_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
}
with open(filepath, "w") as f:
json.dump(state, f, indent=2)
@staticmethod
def load_state(filepath):
with open(filepath, "r") as f:
return json.load(f)
class Scanner:
def __init__(
self,
target_url,
wordlists,
threads=DEFAULT_THREADS,
jitter_min=DEFAULT_JITTER_MIN,
jitter_max=DEFAULT_JITTER_MAX,
timeout=DEFAULT_TIMEOUT,
encoder_method="none",
follow_redirects=False,
verify_ssl=False,
match_codes=None,
filter_codes=None,
output_prefix=None,
resume_file=None,
no_color=False,
):
parsed = urllib.parse.urlparse(target_url)
if not parsed.scheme:
parsed = urllib.parse.urlparse("http://" + target_url)
self.scheme = parsed.scheme or "http"
self.host = parsed.hostname
self.port = parsed.port
self.base_path = parsed.path.rstrip("/") if parsed.path else ""
self.threads = threads
self.timeout = timeout
self.encoder_method = encoder_method
self.follow_redirects = follow_redirects
self.verify_ssl = verify_ssl
self.match_codes = match_codes
self.filter_codes = filter_codes or []
self.output_prefix = output_prefix
self.resume_file = resume_file
self.no_color = no_color
self.ua_manager = UserAgentManager()
self.delay_manager = AdaptiveDelayManager(jitter_min, jitter_max)
self.http = StealthHTTPClient(
timeout, verify_ssl, follow_redirects, encoder_method, self.ua_manager
)
self.output = OutputManager(use_color=not no_color)
self.paths = self._load_wordlists(wordlists)
self.completed_paths = set()
self.scanned_count = 0
self.total_paths = len(self.paths)
self.found_count = 0
self.running = True
self.count_lock = threading.Lock()
self.path_queue = queue.Queue()
def _load_wordlists(self, wordlist_paths):
paths = []
seen = set()
for wl_path in wordlist_paths:
if not os.path.isfile(wl_path):
print(f"Warning: Wordlist not found: {wl_path}", file=sys.stderr)
continue
with open(wl_path, "r") as f:
for line in f:
path = line.strip()
if not path or path.startswith("#"):
continue
if path not in seen:
paths.append(path)
seen.add(path)
return paths
def scan(self):
if not self.host:
print("Error: Invalid target URL.", file=sys.stderr)
sys.exit(1)
if not self.paths:
print("Error: No paths loaded from wordlists.", file=sys.stderr)
sys.exit(1)
loaded_from_state = set()
if self.resume_file:
loaded_from_state = self._load_resume_state()
for path in self.paths:
if path not in loaded_from_state:
self.path_queue.put(path)
self.total_paths = len(self.paths)
self.queue_size = self.path_queue.qsize()
self.completed_paths = loaded_from_state
self.scanned_count = len(loaded_from_state)
target_display = f"{self.scheme}://{self.host}"
if self.port and self.port not in (80, 443):
target_display += f":{self.port}"
target_display += self.base_path
print(f"GlassFuzz v{VERSION} - Stealth Web Fuzzer")
print(f"Target: {target_display}")
print(f"Threads: {self.threads}")
print(f"Jitter: {self.delay_manager.original_min}-{self.delay_manager.original_max}ms")
print(f"Encoder: {self.encoder_method}")
print(f"Total paths: {self.total_paths}")
if loaded_from_state:
print(f"Resuming: {len(loaded_from_state)} paths already scanned")
if self.found_count:
print(f"Previously found: {self.found_count}")
print(f"Remaining: {self.queue_size}")
print(f"{'=' * 60}")
threads_list = []
for i in range(self.threads):
t = threading.Thread(target=self._worker, args=(i,), daemon=True)
t.start()
threads_list.append(t)
try:
while any(t.is_alive() for t in threads_list):
self._auto_save_state()
time.sleep(2)
except KeyboardInterrupt:
print("\nInterrupted. Saving progress...")
self.running = False
self._auto_save_state(force=True)
for t in threads_list:
t.join(timeout=5)
self.output.print_summary()
self._save_results()
def _worker(self, worker_id):
while self.running and not self.path_queue.empty():
try:
path = self.path_queue.get(timeout=0.5)
except queue.Empty:
break
if not path:
self.path_queue.task_done()
continue
full_path = self._build_path(path)
result = self._request_path(full_path, path)
with self.count_lock:
self.scanned_count += 1
if result:
if self._should_include(result.status):
self.output.add_result(result)
self.output.print_live(result)
with self.count_lock:
self.found_count += 1
with self.count_lock:
self.completed_paths.add(path)
self.output.print_progress(
self.scanned_count, self.total_paths, self.found_count
)
delay = self.delay_manager.get_delay()
time.sleep(delay)
self.path_queue.task_done()
def _request_path(self, full_path, original_path):
status, headers, body, title, redirect = self.http.request(
self.host, self.port, full_path, scheme=self.scheme
)
cooldown_action = None
if status:
cooldown_action = self.delay_manager.report_response(status)
else:
cooldown_action = self.delay_manager.report_response(500)
if cooldown_action == "cooldown" or (
self.delay_manager.needs_cooldown() and status in (403, 429)
):
multiplier = self.delay_manager.get_multiplier()
print(
f"\n{COLORS['yellow']}[!] Rate limiting detected (multiplier: {multiplier:.1f}x). "
f"Cooling down for {RATE_LIMIT_COOLDOWN}s...{COLORS['reset']}"
)
time.sleep(RATE_LIMIT_COOLDOWN)
self.delay_manager.multiplier = max(1.0, self.delay_manager.multiplier * 0.5)
self.delay_manager.jitter_min = int(self.delay_manager.original_min * self.delay_manager.multiplier)
self.delay_manager.jitter_max = int(self.delay_manager.original_max * self.delay_manager.multiplier)
if status is None:
return None
result = ScanResult(
path=original_path,
status=status,
length=len(body) if body else 0,
title=title,
redirect=redirect,
)
if redirect and self.follow_redirects:
self._follow_redirect_chain(redirect, original_path)
return result
def _follow_redirect_chain(self, redirect_url, original_path, depth=0):
if depth >= 5:
return
try:
parsed = urllib.parse.urlparse(redirect_url)
if parsed.scheme:
scheme = parsed.scheme
host = parsed.hostname
port = parsed.port
else:
scheme = self.scheme
host = self.host
port = self.port
path = parsed.path or "/"
if parsed.query:
path += "?" + parsed.query
status, headers, body, title, next_redirect = self.http.request(
host, port, path, scheme=scheme
)
if status is None:
return
label = f"{original_path} →[{depth + 1}] {path}"
result = ScanResult(
path=label,
status=status,
length=len(body) if body else 0,
title=title or "",
redirect=next_redirect,
)
if self._should_include(status):
self.output.add_result(result)
self.output.print_live(result)
with self.count_lock:
self.found_count += 1
if next_redirect:
self._follow_redirect_chain(next_redirect, original_path, depth + 1)
except Exception:
pass
def _build_path(self, path):
path = path.lstrip("/")
if self.base_path:
return f"{self.base_path}/{path}"
return f"/{path}"
def _should_include(self, status):
if self.match_codes and status not in self.match_codes:
return False
if status in self.filter_codes:
return False
return True
def _load_resume_state(self):
if not os.path.isfile(self.resume_file):
return set()
try:
state = OutputManager.load_state(self.resume_file)
paths = set(state.get("completed_paths", []))
self.found_count = state.get("found_count", 0)
return paths
except Exception:
return set()
def _auto_save_state(self, force=False):
if not self.output_prefix:
return
if not force and self.scanned_count % 50 != 0:
return
state_file = f"{self.output_prefix}.resume.json"
state = {
"target_url": f"{self.scheme}://{self.host}",
"base_path": self.base_path,
"completed_paths": list(self.completed_paths),
"total_paths": self.total_paths,
"found_count": self.found_count,
"saved_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
}
with open(state_file, "w") as f:
json.dump(state, f, indent=2)
def _save_results(self):
if not self.output_prefix:
self.output_prefix = f"glassfuzz_{self.host.replace('.', '_')}"
txt_path = f"{self.output_prefix}.txt"
json_path = f"{self.output_prefix}.json"
self.output.save_txt(txt_path)
self.output.save_json(json_path)
print(f"\nResults saved: {txt_path}, {json_path}")
def build_parser():
parser = argparse.ArgumentParser(
prog="glassfuzz",
description="GlassFuzz - Stealth Web Fuzzer for WAF/IDS Evasion",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
glassfuzz -u https://example.com -w wordlists/common.txt
glassfuzz -u https://example.com -w wordlists/*.txt -t 20 --jitter-min 200 --jitter-max 1000
glassfuzz -u https://example.com -w wordlists/api.txt --encoder double-url
glassfuzz -u https://example.com -w wordlists/common.txt -o scan_results --resume scan_results.resume.json
""",
)
parser.add_argument(
"-u", "--url",
required=True,
help="Target URL to scan (e.g. https://example.com)",
)
parser.add_argument(
"-w", "--wordlist",
required=True,
nargs="+",
help="One or more wordlist files",
)
parser.add_argument(
"-t", "--threads",
type=int,
default=DEFAULT_THREADS,
help=f"Number of concurrent threads (default: {DEFAULT_THREADS})",
)
parser.add_argument(
"--jitter-min",
type=int,
default=DEFAULT_JITTER_MIN,
help=f"Minimum jitter between requests in ms (default: {DEFAULT_JITTER_MIN})",
)
parser.add_argument(
"--jitter-max",
type=int,
default=DEFAULT_JITTER_MAX,
help=f"Maximum jitter between requests in ms (default: {DEFAULT_JITTER_MAX})",
)
parser.add_argument(
"--timeout",
type=int,
default=DEFAULT_TIMEOUT,
help=f"Request timeout in seconds (default: {DEFAULT_TIMEOUT})",
)
parser.add_argument(
"--encoder",
choices=["none", "double-url", "base64"],
default="none",
help="Payload encoding method to evade filters (default: none)",
)
parser.add_argument(
"--follow-redirects",
action="store_true",
help="Follow HTTP redirects",
)
parser.add_argument(
"--match-codes",
type=str,
help="Only show these status codes (comma-separated, e.g. 200,301,403)",
)
parser.add_argument(
"--filter-codes",
type=str,
help="Hide these status codes (comma-separated, e.g. 404,500)",
)
parser.add_argument(
"-o", "--output",
type=str,
help="Output file prefix for saving results",
)
parser.add_argument(
"--resume",
type=str,
help="Resume from a previous scan state file (e.g. scan.resume.json)",
)
parser.add_argument(
"--verify-ssl",
action="store_true",
help="Verify SSL certificates (disabled by default)",
)
parser.add_argument(
"--no-color",
action="store_true",
help="Disable colored output",
)
parser.add_argument(
"-v", "--verbose",
action="store_true",
help="Show all requests including 404s",
)
parser.add_argument(
"--version",
action="version",
version=f"%(prog)s v{VERSION}",
)
return parser
def main():
parser = build_parser()
args = parser.parse_args()
match_codes = None
if args.match_codes:
match_codes = set(int(c.strip()) for c in args.match_codes.split(","))
filter_codes = [404]
if args.verbose:
filter_codes = []
if args.filter_codes:
explicit = [int(c.strip()) for c in args.filter_codes.split(",")]
# Merge with whatever is currently in filter_codes (respects --verbose clearing 404)
filter_codes = list(set(filter_codes) | set(explicit))
scanner = Scanner(
target_url=args.url,
wordlists=args.wordlist,
threads=args.threads,
jitter_min=args.jitter_min,
jitter_max=args.jitter_max,
timeout=args.timeout,
encoder_method=args.encoder,
follow_redirects=args.follow_redirects,
verify_ssl=args.verify_ssl,
match_codes=match_codes,
filter_codes=filter_codes,
output_prefix=args.output,
resume_file=args.resume,
no_color=args.no_color,
)
scanner.scan()
if __name__ == "__main__":
main()