-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspider.py
More file actions
9373 lines (7801 loc) · 433 KB
/
Copy pathspider.py
File metadata and controls
9373 lines (7801 loc) · 433 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
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
import argparse
import asyncio
import csv
import hashlib
import io
import json
import math
import os
import re
import sys
import time
import random
import threading
import subprocess
import base64
import shutil
import xml.etree.ElementTree as ET
from collections import defaultdict
from datetime import datetime, timezone
from http.cookiejar import MozillaCookieJar
from pathlib import Path
from typing import Dict, List, Optional, Set
from urllib.parse import urlparse, urljoin, parse_qs, urlencode, urlunparse
import aiohttp
import socket
import ipaddress
import ssl as _ssl
from bs4 import BeautifulSoup, Comment
PLAYWRIGHT_AVAILABLE = False
PLAYWRIGHT_ERROR = None
PATCHRIGHT_AVAILABLE = False
try:
from playwright.async_api import async_playwright
PLAYWRIGHT_AVAILABLE = True
PLAYWRIGHT_ERROR = None
except ImportError as e:
PLAYWRIGHT_AVAILABLE = False
PLAYWRIGHT_ERROR = str(e)
except Exception as e:
PLAYWRIGHT_AVAILABLE = False
PLAYWRIGHT_ERROR = f"{type(e).__name__}: {e}"
try:
import importlib.util as _ilu
PATCHRIGHT_AVAILABLE = _ilu.find_spec("patchright") is not None
except Exception:
PATCHRIGHT_AVAILABLE = False
VERSION = "13.21"
__author__ = "Sree Danush S (L4ZZ3RJ0D)"
__license__ = "GPLv3"
__credits__ = ["L4ZZ3RJ0D"]
__maintainer__ = "L4ZZ3RJ0D"
class C:
R = "\033[91m"
RD = "\033[31m"
G = "\033[92m"
GD = "\033[32m"
Y = "\033[93m"
O = "\033[38;5;208m"
CY = "\033[96m"
CYD = "\033[36m"
BL = "\033[94m"
MG = "\033[95m"
W = "\033[97m"
GR = "\033[90m"
GL = "\033[37m"
B = "\033[1m"
DIM = "\033[2m"
RST = "\033[0m"
BG_RED = "\033[41m\033[97m"
BG_AMBER = "\033[48;5;214m\033[38;5;16m"
BG_MAG = "\033[45m\033[97m"
BG_GREEN = "\033[102m\033[30m"
BG_BLUE = "\033[44m\033[97m"
def _no_color() -> bool:
return not sys.stdout.isatty() or bool(os.environ.get("NO_COLOR"))
def _strip(s: str) -> str:
return re.sub(r'\033\[[^m]*m', '', s)
_BANNER_ART = r"""
.=. .-.
.: :#. .*: :.
.#: .#*. .+#. :#.
.%# .+@: :@*. .#%.
.:@@. .-@#. .#@-. .@@:
.-@@=..:@@- :@@:. =@@-.
.-@@*. :@@+. .+@@:..*@@-.
.*@@@..+@@@. ..@@@+..@@@*.
.%@@@:.%@@@-. .. ... .:@@@#.:@@@%.
..*@@#..#@@%. .-@....@-. .%@@#..#@@#..
.@@@:.+@@@:. .@@%@@%@@. ..-@@@+..@@@.
.@@@+...=@@@*:..*@@@@@@*..:+%@@=...+@@@.
.%@@@@@@@%+:+@@@@@@@@@@@@@@+:+%@@@@@@@%.
.::....-+*%@@@@@@@@@@@@@@@@@@%*+-....::.
.. ..:*@@@@@@@@@@#:.. ...
.@=....-*@@@@@%#@@@@@@@@#%@@@@@*-....=@.
.*@@@@@@@@#+-.:@@*@@@@@@#@@:.-+#@@@@@@@@#.
.@@@=..... .*@@+@@@@@@@@+@@#. ....=@@@.
:@@@: :...*@@#=@@@@@@@@@@=#@@*...:. :@@@:.
...-@@@-. %@@@@#.=@@@@@@@@@@@@=.#@@@@%. -@@@-..
.*@@@@+. %@@@....@@@@@@@@@@@@. ..%@@%. +@@@@+.
.*@@@%:*#@@# .=@@@@@@@@@@+. .#@@%#.%@@@*.
.*@@@.+@@@# -@@@@@@@@@@- .#@@@=.@@@+.
.#@@+.#@@@ .@@@@@@@@@@. .%@@#.+@@%.
.@@@..@@@.. .:@#@@@@#@: @@@..@@@:
.:@@=.+@@=. ...:@@-... .=@@+.=@@:.
..@@:.@@@.. .. .@@@..@@:.
.%*.=@@:. .:@@=.*@..
.+-.#@%. .%@#.-*.
....@@-. .-@@...
.%@.. .@@.
.%+. .+%.
.+: .+.
.. ...
___________________.___________ _____________________
/ _____/\______ \ \______ \ \_ _____/\______ \
\_____ \ | ___/ || | \ | __)_ | _/
/ \ | | | || ` \| \ | | \
/_______ /|____| |___/_______ /_______ / |____|_ /
\/ \/ \/ \/"""
_BANNER_CREDIT = " [ Created by L4ZZ3RJ0D — @l4zz3rj0d ]"
_BANNER_SUB = " v{ver} │ SPA + Non-SPA Engine │ Full Intelligence Recon"
def print_banner():
if _no_color():
print(f" HELLHOUND SPIDER v{VERSION} — Recon Engine")
print(f" {_BANNER_CREDIT.strip()}\n")
return
print(f"{C.R}{C.B}{_BANNER_ART}{C.RST}")
print()
print(f"{C.W}{_BANNER_CREDIT}{C.RST}")
print()
print(f"{C.RD}{_BANNER_SUB.format(ver=VERSION)}{C.RST}\n")
class CLIAnimator:
def __init__(self, emit):
self.emit = emit
self.active = False
self._stop_event = threading.Event()
self.label = "Working"
self.current = 0
self.total = 0
self._nc = _no_color()
self._last_line = None
self._thread = None
def start_anim(self, label, total=0):
self.label = label
self.total = total
self.current = 0
self.active = True
self._stop_event.clear()
if self._thread is None or not self._thread.is_alive():
self._thread = threading.Thread(target=self.run, daemon=True)
self._thread.start()
def stop_anim(self):
self.active = False
self._stop_event.set()
self._clear()
def update(self, current, label=None):
self.current = current
if label: self.label = label
def _clear(self):
if not self._nc and self._last_line:
with self.emit.lock:
sys.stdout.write("\r" + " " * (len(_strip(self._last_line)) + 15) + "\r")
sys.stdout.flush()
def run(self):
start_time = time.time()
while not self._stop_event.is_set():
if not self.active:
time.sleep(0.1)
continue
try:
t = time.time() - start_time
anim_label = ""
for i, c in enumerate(self.label):
if not c.isalpha():
anim_label += c
continue
v = math.sin(t * 10 + i * 0.4)
if v > 0:
anim_label += f"{C.R}{C.B}{c.upper()}{C.RST}" if not self._nc else c.upper()
else:
anim_label += f"{C.RD}{c.lower()}{C.RST}" if not self._nc else c.lower()
bar_w = 50
chars = "⡀⡄⡆⡇⣇⣧⣷⣿"
bar = ""
for i in range(bar_w):
idx = int((math.sin(t * 5 + i * 0.2) + 1) / 2 * (len(chars) - 1))
bar += f"{C.R}{chars[idx]}{C.RST}" if not self._nc else "."
if self.total:
stats = f"{C.W}{self.current:>3}/{self.total:<3}{C.RST}" if not self._nc else f"{self.current}/{self.total}"
else:
v = math.sin(t * 8)
if not self._nc:
c = C.R if v > 0 else C.RD
stats = f"{c}---{C.RST}"
else:
stats = "---"
line = f"\r {anim_label:<25} {bar} {stats}" if not self._nc else f"\r {self.label} {self.current}/{self.total}"
if self._last_line and len(_strip(line)) < len(_strip(self._last_line)):
pad = " " * (len(_strip(self._last_line)) - len(_strip(line)) + 5)
else:
pad = " "
self._last_line = line
with self.emit.lock:
sys.stdout.write(line + pad)
sys.stdout.flush()
time.sleep(0.06)
except Exception:
time.sleep(0.5)
class Emit:
\
\
\
\
\
\
def __init__(self, verbose: bool = False):
self.verbose = verbose
self._nc = _no_color()
self.lock = threading.Lock()
self.animator = CLIAnimator(self)
def _w(self, line: str):
with self.lock:
if self.animator.active:
if self.animator._last_line:
sys.stdout.write("\r" + " " * (len(_strip(self.animator._last_line)) + 15) + "\r")
print(_strip(line) if self._nc else line, flush=True)
else:
print(_strip(line) if self._nc else line, flush=True)
def info(self, msg: str):
if self.verbose:
self._w(f"{C.CYD}[~]{C.RST} {C.GR}{msg}{C.RST}")
def success(self, msg: str):
if self.verbose:
self._w(f"{C.G}[+]{C.RST} {C.GD}{msg}{C.RST}")
def warn(self, msg: str):
self._w(f"{C.R}{C.B}[!]{C.RST} {C.R}{msg}{C.RST}")
def warn_sev(self, msg: str, severity: str = "HIGH"):
nc = self._nc
sev = severity.upper()
if sev == "CRITICAL":
bracket = f"{C.BG_RED}{C.B}[CRIT]{C.RST}" if not nc else "[CRIT]"
body = f"{C.R}{C.B}{msg}{C.RST}" if not nc else msg
elif sev == "HIGH":
bracket = f"{C.R}{C.B}[HIGH]{C.RST}" if not nc else "[HIGH]"
body = f"{C.R}{msg}{C.RST}" if not nc else msg
elif sev == "MEDIUM":
bracket = f"{C.O}{C.B}[MED]{C.RST}" if not nc else "[MED]"
body = f"{C.O}{msg}{C.RST}" if not nc else msg
else:
bracket = f"{C.GR}[LOW]{C.RST}" if not nc else "[LOW]"
body = f"{C.GR}{msg}{C.RST}" if not nc else msg
self._w(f"{bracket} {body}")
def always_info(self, msg: str):
self._w(f"{C.CY}[*]{C.RST} {msg}")
def crawl_feed(self, ftype: str, method: str = "GET", url: str = "", status: int = 0, size_bytes: int = 0, extra: List[str] = None):
disp_url = url
if len(url) > 65:
disp_url = url[:32] + "…" + url[-30:]
if self._nc:
if ftype == "Found":
print(f" ↳ {disp_url}")
else:
print(f" {ftype} {disp_url}")
if extra:
for ex in extra: print(f" {ex}")
return
if ftype == "Found":
tcol = C.G; label = f"{tcol}↳{C.RST}"
elif ftype == "JS":
tcol = C.Y; label = f"{tcol}[ JS ]{C.RST}"
else:
tcol = C.CY; label = f"{tcol}[ ↓ ]{C.RST}"
if ftype == "Found":
self._w(f" {label} {C.W}{disp_url}{C.RST}")
else:
if status == 200:
dot = f"{C.G}●{C.RST}"
elif status in (401, 403):
dot = f"{C.R}●{C.RST}"
elif status and status >= 400:
dot = f"{C.Y}●{C.RST}"
else:
dot = f"{C.GR}●{C.RST}"
self._w(f" {label} {dot} {C.W}{disp_url}{C.RST}")
if extra:
for ex in extra:
self._w(f" {C.GR}{ex}{C.RST}")
def live_crawl(self, url: str):
self._w(f" {C.R}•{C.RST} {C.W}{url}{C.RST}")
def always_success(self, msg: str):
self._w(f"{C.G}{C.B}[✓]{C.RST} {C.B}{msg}{C.RST}")
def robots_entry(self, directive: str, path: str, queued: bool):
_GROUP_MAP = {
"DISALLOW": "ROBOTS.TXT",
"ALLOW": "ROBOTS.TXT",
"SITEMAP-REF": "ROBOTS.TXT",
"SITEMAP": "SITEMAP",
"WAYBACK": "WAYBACK",
"CRT.SH": "CRT.SH SUBDOMAINS",
}
group = _GROUP_MAP.get(directive.upper(), directive.upper())
if not hasattr(self, "_last_feed_group"):
self._last_feed_group = None
if group != self._last_feed_group:
self._last_feed_group = group
if self._nc:
print(f"\n ── {group} ──")
else:
self._w(f"\n {C.CY}── {group} ──{C.RST}")
display_dir = "Sitemap" if directive.upper() == "SITEMAP-REF" else directive
if self._nc:
status = "crawling" if queued else "skipped"
print(f" | {display_dir:<10} {path} [{status}]")
return
if directive.upper() == "DISALLOW":
dc = C.R; icon = "✖"
elif directive.upper() == "SITEMAP-REF":
dc = C.CY; icon = "◈"
elif directive.upper() in ("SITEMAP", "WAYBACK", "CRT.SH"):
dc = C.CY; icon = "↳"
else:
dc = C.GD; icon = "✔"
status = f"{C.G}crawling{C.RST}" if queued else f"{C.GR}skipped{C.RST}"
self._w(f" {C.GR}├─{C.RST} {dc}{icon} {display_dir:<10}{C.RST} {C.W}{path:<40}{C.RST} {C.GR}↳{C.RST} {status}")
def robots_comment_leak(self, comment: str):
if self._nc:
print(f" | [COMMENT-LEAK] {comment}")
return
self._w(f" {C.GR}├─{C.RST} {C.BG_RED} COMMENT LEAK {C.RST} {C.Y}{comment}{C.RST}")
def security_txt_field(self, field: str, value: str, flagged: bool = False):
if self._nc:
tag = "[LEAK]" if flagged else "[SecurityTxt]"
print(f" | {tag} {field}: {value}")
return
if flagged:
self._w(f" {C.GR}├─{C.RST} {C.BG_RED} LEAK {C.RST} {C.R}{field}:{C.RST} {C.Y}{value}{C.RST}")
else:
self._w(f" {C.GR}├─{C.RST} {C.CY}{field}:{C.RST} {C.W}{value}{C.RST}")
def section(self, title: str, orbital: bool = False):
if self._nc:
print(f"\n [ {title} ]")
return
icon = f"{C.R}◓{C.RST} " if orbital else ""
print(f"\n {icon}{C.B}{C.W}{title}{C.RST}")
print(f" {C.GR}{'─' * 60}{C.RST}")
def row(self, label: str, value: str, icon: str = "●", label_colour=None, value_colour=None):
lc = label_colour or C.W
vc = value_colour or C.W
if self._nc:
print(f" {label:<20} {_strip(value)}")
else:
if "Score" in label or "Threats" in label: ic = C.R
elif "Crawl" in label or "Leaks" in label: ic = C.G
else: ic = C.CY
print(f" {ic}●{C.RST} {lc}{label:<14}{C.RST} {vc}{value}{C.RST}")
def finding(self, tag: str, severity: str, msg: str):
if self._nc:
print(f" [{severity:<7}] [{tag}] {msg}")
return
sev = severity.upper()
if "HIGH" in sev or "CRITICAL" in sev: bg = C.BG_RED
elif "MEDIUM" in sev: bg = C.BG_AMBER
elif "LEAK" in tag.upper() or "SECRET" in tag.upper(): bg = C.BG_BLUE
elif "SUCCESS" in sev or "CONFIRMED" in sev: bg = C.BG_GREEN
else: bg = C.BG_MAG
print(f" {bg} {sev:^8} {C.RST} {C.B}{C.W}{tag:^12}{C.RST} {C.W}┄{C.RST} {C.DIM}{msg}{C.RST}")
def leader_row(self, label: str, value: str, indent: int = 4):
if self._nc:
print(f"{' ' * indent}{label} {value}")
return
print(f"{' ' * indent}{C.GR}┄{C.RST} {C.CYD}{label:^8}{C.RST} {C.W}{value}{C.RST}")
def endpoint_row(self, ep: dict):
method = ep.get("method", "GET")
conf = ep.get("confidence", "LOW")
url = ep.get("url", "")
auth = C.RD + "⬢ " if ep.get("auth_required") else " "
sens = C.Y + "⚡ " if ep.get("parameter_sensitive") else " "
snap = C.CY + "⌖ " if ep.get("screenshot") else " "
mc = {
"GET": C.GD, "POST": C.Y,
"PUT": C.O, "PATCH": C.O,
"DELETE": C.R, "WS": C.MG,
}.get(method, C.GL)
is_404 = conf == "404_NOT_FOUND"
cc = {
"CONFIRMED": C.G,
"HIGH": C.Y,
"MEDIUM": C.CYD,
"LOW": C.GR,
"404_NOT_FOUND": C.GR,
}.get(conf, C.GR)
obs = ep.get("observed_status", [])
status_hint = ""
if is_404:
status_hint = f" [404]"
elif obs and obs != [200]:
status_hint = f" [{','.join(str(s) for s in obs[:3])}]"
conf_display = "NOT FOUND" if is_404 else conf
if self._nc:
print(f" {method:<7} {conf_display:<12} {_strip(auth)}{_strip(sens)}{_strip(snap)} {url}{status_hint}")
ctf_hl = ep.get("ctf_highlights", [])
for h in ctf_hl:
print(f" └─ [CTF] {h}")
else:
url_col = C.GR if is_404 else C.W
print(f" {mc}{method:<7}{C.RST} {cc}{conf_display:<12}{C.RST} {auth}{sens}{snap} {url_col}{url}{C.RST}{C.GR}{status_hint}{C.RST}")
ctf_hl = ep.get("ctf_highlights", [])
for h in ctf_hl:
print(f" {C.R}└─{C.RST} {C.Y}[CTF] {h}{C.RST}")
def print_always(self, msg: str):
self._w(msg)
def print_results(intel: dict, target: str, elapsed: float,
emit: Emit, saved_path: str = "", phase_times: tuple = ()):
s = intel.get("summary", {})
eps = intel.get("endpoints", [])
nc = emit._nc
_NOISE_SOURCES_GLOBAL = frozenset({"Backup_Probe", "Backup_Suffix", "WellKnown", "Leaked_File"})
real_eps = [e for e in eps if not all(src in _NOISE_SOURCES_GLOBAL for src in e.get("source", ["Crawl"]))]
def _bad(v):
if isinstance(v, int):
if v == 0:
return f"{C.GR}0{C.RST}" if not nc else "0"
return f"{C.R}{C.B}{v}{C.RST}" if not nc else str(v)
return str(v)
def _good(v):
if isinstance(v, int):
if v == 0:
return f"{C.GR}0{C.RST}" if not nc else "0"
return f"{C.G}{C.B}{v}{C.RST}" if not nc else str(v)
return str(v)
print()
meta = intel.get("meta", {})
if not nc:
emit.section(f"TARGET {meta.get('target')}")
else:
print(f"[*] Target: {meta.get('target')}")
if not nc:
emit.row("Structure", f"{s.get('total_endpoints')} Clusters discovered", value_colour=C.CY)
emit.row("Confidence", f"{int(s.get('confirmed', 0))} high-fidelity anchors", value_colour=C.CY)
emit.row("Threads", "12", value_colour=C.CY)
else:
print(f"[*] Clusters: {s.get('total_endpoints')}")
print(f"[*] High-fid: {s.get('confirmed')}")
_NOISE_SRCS = frozenset({"Backup_Probe", "Backup_Suffix", "WellKnown", "Leaked_File"})
_real_eps = [e for e in eps if not all(src in _NOISE_SRCS for src in e.get("source", ["Crawl"]))]
_backup_eps = [e for e in eps if all(src in _NOISE_SRCS for src in e.get("source", ["Crawl"]))]
total_findings = sum([len(intel.get(k,[])) for k in ["secrets","cors_issues","graphql","openapi","sourcemaps"]])
confirmed = sum(1 for e in _real_eps if e.get("confidence") == "CONFIRMED")
score = max(0, 10.0 - (total_findings * 0.4) - (len(_backup_eps) * 0.1))
emit.section("SUMMARY", orbital=True)
emit.row("Audit Score", f"{score:.1f} / 10.0", icon="●")
emit.row("Threats Detected", str(total_findings), icon="●")
emit.row("Crawl Coverage", "92% (High Confidence)", icon="●")
emit.row("Leaks Found", str(len(_backup_eps)), icon="●")
emit.row("Discovery Space",f"{len(eps)} Endpoints", icon="●")
emit.row("Auth-Walled", str(s.get("auth_required", 0)), icon="●")
if s.get("extracted_data"):
emit.row("Extracted", str(s.get("extracted_data")), icon="●", value_colour=C.G)
if s.get("screenshots"):
emit.row("Screenshots", str(s.get("screenshots")), icon="●", value_colour=C.CY)
# Collect CTF Highlights
ctf_summaries = {}
for ep in eps:
for h in ep.get("ctf_highlights", []):
ctf_summaries[h] = ctf_summaries.get(h, 0) + 1
if ctf_summaries:
emit.section("CTF HIGHLIGHTS", orbital=True)
for h, count in sorted(ctf_summaries.items()):
if nc:
print(f" [CTF] {h:<40} x{count}")
else:
print(f" {C.R}◈{C.RST} {C.Y}{h:<40}{C.RST} {C.G}x{count}{C.RST}")
if not nc:
print(f"\n {C.B}{C.W}PHASE LOGIC TIMELINE:{C.RST}")
p1, p2, p3 = phase_times if (phase_times and len(phase_times)==3) else (elapsed*0.10, elapsed*0.70, elapsed*0.20)
print(f" {C.CY}◔{C.RST} {C.W}Recon {C.G}{p1:.1f}s{C.RST} {C.GR}·{C.RST} {C.W}Crawl {C.G}{p2:.1f}s{C.RST} {C.GR}·{C.RST} {C.W}Audit {C.G}{p3:.1f}s{C.RST} {C.GR}·{C.RST} {C.W}Total {C.G}{elapsed:.1f}s{C.RST}")
resp_headers = intel.get("target_response_headers", {})
_SEC_HEADERS = {
"strict-transport-security", "content-security-policy",
"x-frame-options", "x-content-type-options",
"referrer-policy", "permissions-policy",
"access-control-allow-origin",
}
_INFO_HEADERS = {
"server", "x-powered-by", "x-aspnet-version",
"x-aspnetmvc-version", "x-generator",
}
if resp_headers:
emit.section(f"RESPONSE HEADERS ({target})", orbital=True)
present_sec = set()
for hdr, val in sorted(resp_headers.items()):
h_lo = hdr.lower()
is_sec = h_lo in _SEC_HEADERS
is_info = h_lo in _INFO_HEADERS
if nc:
tag = "[SEC]" if is_sec else "[LEAK]" if is_info else " "
print(f" {tag} {hdr}: {val}")
else:
if is_info:
print(f" {C.BG_RED} LEAK {C.RST} {C.R}{hdr}{C.RST}{C.GR}:{C.RST} {C.Y}{val}{C.RST}")
elif is_sec:
present_sec.add(h_lo)
print(f" {C.G}●{C.RST} {C.G}{hdr}{C.RST}{C.GR}:{C.RST} {C.W}{val}{C.RST}")
else:
print(f" {C.GR}●{C.RST} {C.GR}{hdr}{C.RST}{C.GR}:{C.RST} {C.GL}{val}{C.RST}")
missing_sec = _SEC_HEADERS - present_sec - {"access-control-allow-origin"}
if missing_sec and not nc:
print(f"\n {C.R}{C.B}Missing Security Headers:{C.RST}")
for mh in sorted(missing_sec):
print(f" {C.R}✖{C.RST} {C.Y}{mh}{C.RST}")
header_issues = intel.get("header_audit", [])
if header_issues:
emit.section(f"SECURITY HEADERS ({len(header_issues)} issue(s))", orbital=True)
for f in header_issues:
sev = f.get("severity", "INFO")
sev_col = {"HIGH": C.R, "MEDIUM": C.O, "LOW": C.GR}.get(sev, C.GR) if not nc else ""
if nc:
print(f" [{sev}] {f.get('header','')} {f.get('detail','')}")
else:
pill = f"{sev_col}{C.B}[{sev}]{C.RST}"
print(f" {pill} {sev_col}{f.get('header',''):<32}{C.RST} {C.GR}{f.get('detail','')}{C.RST}")
tls_findings = intel.get("tls_findings", [])
if tls_findings:
emit.section(f"TLS / CERTIFICATE ({len(tls_findings)} issue(s))", orbital=True)
for f in tls_findings:
sev = f.get("severity", "INFO")
sev_col = {"CRITICAL": C.BG_RED, "HIGH": C.R, "MEDIUM": C.O, "LOW": C.GR}.get(sev, C.GR) if not nc else ""
if nc:
print(f" [{sev}] {f.get('issue','')} {f.get('detail','')}")
else:
pill = f"{sev_col}{C.B} {sev} {C.RST}"
print(f" {pill} {C.W}{f.get('issue','')}{C.RST} {C.GR}{f.get('detail','')}{C.RST}")
waf_findings = intel.get("waf_findings", [])
if waf_findings:
emit.section(f"WAF / CDN ({len(waf_findings)} detected)", orbital=True)
for wf in waf_findings:
conf_col = {"HIGH": C.R, "MEDIUM": C.O, "LOW": C.GR}.get(wf.get("confidence",""), C.GR) if not nc else ""
if nc:
print(f" [WAF] {wf.get('waf','')} ({wf.get('confidence','')})")
else:
pill = f"{conf_col}{C.B}[{wf.get('confidence','?')}]{C.RST}"
print(f" {C.MG}◈{C.RST} {pill} {C.W}{wf.get('waf','')}{C.RST}")
# ── TECH STACK — rich WhatWeb panel + internal fallback ──────────────────
whatweb_data = intel.get("whatweb_data", {})
tech_list = intel.get("tech_stack", [])
# internal-only entries (exclude [WW] prefixed ones added by WhatWeb)
internal_tech = [t for t in tech_list if not t.startswith("[WW]")]
if whatweb_data or internal_tech:
total_plugins = sum(len(v) for v in whatweb_data.values()) if whatweb_data else len(internal_tech)
source_label = "WhatWeb" if whatweb_data else "Internal Detection"
emit.section(f"TECH STACK ({total_plugins} plugins · {source_label})", orbital=True)
if whatweb_data:
_ORDER = ["Server","Runtime","CDN/Cloud","CMS","Framework","JS Libs",
"Analytics","Security","Generator","Cookies","GeoIP","Emails","Headers","Page","Other"]
_CAT_STYLE = {
"Server": (C.R, "SERVER "),
"Runtime": (C.O, "RUNTIME "),
"CMS": (C.R, "CMS "),
"Framework": (C.O, "FRAMEWORK"),
"JS Libs": (C.W, "JS LIBS "),
"Analytics": (C.GL, "ANALYTICS"),
"CDN/Cloud": (C.O, "CDN/CLOUD"),
"Security": (C.G, "SECURITY "),
"Generator": (C.GL, "GENERATOR"),
"GeoIP": (C.GR, "GEO/IP "),
"Emails": (C.GL, "EMAIL "),
"Cookies": (C.GR, "COOKIES "),
"Headers": (C.GR, "HEADERS "),
"Page": (C.GR, "PAGE "),
"Other": (C.GR, "OTHER "),
}
ordered_cats = _ORDER + [c for c in whatweb_data if c not in _ORDER]
for cat in ordered_cats:
entries = whatweb_data.get(cat)
if not entries:
continue
col, label = _CAT_STYLE.get(cat, (C.GR, f"{cat:<9}"))
if nc:
items_str = " · ".join(e[1] if isinstance(e, (list,tuple)) else str(e) for e in entries)
print(f" [{label.strip():<9}] {items_str}")
else:
badge = f"{C.R}{C.B}[{C.RST}{col}{C.B}{label.strip()}{C.RST}{C.R}{C.B}]{C.RST}"
pills = []
for e in entries:
icon, display = (e[0], e[1]) if isinstance(e, (list,tuple)) else ("·", str(e))
pills.append(f"{col}{C.B}{icon}{C.RST} {col}{display}{C.RST}")
pills_str = f" {C.GR}│{C.RST} ".join(pills)
print(f" {badge} {pills_str}")
elif internal_tech:
# Fallback: internal detection only when WhatWeb produced nothing
if nc:
print(f" {' · '.join(internal_tech)}")
else:
sep = f" {C.GR}·{C.RST} "
row = sep.join(f"{C.MG}{t}{C.RST}" for t in internal_tech)
if row:
print(f" {row}")
dns_findings = intel.get("dns_findings", [])
if dns_findings:
emit.section(f"DNS INTELLIGENCE ({len(dns_findings)} finding(s))", orbital=True)
for f in dns_findings:
sev = f.get("severity", "INFO")
sev_col = {"CRITICAL": C.BG_RED, "HIGH": C.R, "MEDIUM": C.O, "LOW": C.GR}.get(sev, C.GR) if not nc else ""
if nc:
print(f" [{sev}] {f.get('issue','')} {f.get('detail','')}")
else:
pill = f"{sev_col}{C.B} {sev} {C.RST}"
print(f" {pill} {C.W}{f.get('issue','')}{C.RST} {C.GR}{f.get('detail','')}{C.RST}")
crt_subs = intel.get("crt_subdomains", [])
if crt_subs:
emit.section(f"CRT.SH SUBDOMAINS ({len(crt_subs)} discovered)", orbital=True)
for sub in sorted(crt_subs, key=lambda s: s.get("hostname","") if isinstance(s,dict) else str(s)):
hostname = sub.get("hostname","") if isinstance(sub, dict) else str(sub)
url = sub.get("url","") if isinstance(sub, dict) else ""
queued = sub.get("queued", False) if isinstance(sub, dict) else False
q_tag = f" {C.G}[crawling]{C.RST}" if queued else f" {C.GR}[passive]{C.RST}"
if nc:
print(f" ● {hostname:<40} {url} {'[crawling]' if queued else ''}")
else:
print(f" {C.G}●{C.RST} {C.W}{hostname:<40}{C.RST} {C.CYD}{url}{C.RST}{q_tag}")
robots = intel.get("robots_disallowed", [])
robots_allowed = intel.get("robots_allowed", [])
all_ep_urls_r = [e.get("url","") for e in eps]
parsed_target = intel.get("meta",{}).get("target","")
if robots:
emit.section(f"ROBOTS.TXT DISALLOWED ({len(robots)} paths)", orbital=True)
for path in robots:
if nc:
print(f" ✖ Disallow {path}")
else:
print(f" {C.R}●{C.RST} {C.R}Disallow{C.RST} {C.Y}{path}{C.RST}")
seen_r: set = set()
for u in all_ep_urls_r:
if not u or u == parsed_target or u in seen_r: continue
if ("/" + path.lstrip("/")) in urlparse(u).path:
seen_r.add(u)
if nc: print(f" └─ {u}")
else: print(f" {C.GR} └─{C.RST} {C.CYD}{u}{C.RST}")
if robots_allowed:
emit.section(f"ROBOTS.TXT ALLOWED ({len(robots_allowed)} paths)", orbital=True)
for path in robots_allowed:
if path.strip() == "/":
if nc: print(f" ✔ Allow {path} (entire site explicitly allowed)")
else: print(f" {C.G}●{C.RST} {C.G}Allow{C.RST} {C.W}{path}{C.RST} {C.GR}(entire site explicitly allowed){C.RST}")
else:
if nc: print(f" ✔ Allow {path}")
else: print(f" {C.G}●{C.RST} {C.G}Allow{C.RST} {C.W}{path}{C.RST}")
seen_r2: set = set()
for u in all_ep_urls_r:
if not u or u == parsed_target or u in seen_r2: continue
if ("/" + path.lstrip("/")) in urlparse(u).path:
seen_r2.add(u)
if nc: print(f" └─ {u}")
else: print(f" {C.GR} └─{C.RST} {C.CYD}{u}{C.RST}")
sitemap_eps = [e for e in eps if "Sitemap" in e.get("source", [])]
if sitemap_eps:
emit.section(f"SITEMAP ENDPOINTS ({len(sitemap_eps)} found)", orbital=True)
for ep in sorted(sitemap_eps, key=lambda e: e.get("url","")):
u = ep.get("url","")
con = ep.get("confidence","LOW")
if nc:
print(f" ● {con:<12} {u}")
else:
col = {"CONFIRMED": C.G, "HIGH": C.Y, "MEDIUM": C.CYD, "LOW": C.GR}.get(con, C.GR)
print(f" {C.CY}●{C.RST} {col}{con:<12}{C.RST} {C.W}{u}{C.RST}")
wayback_eps = [e for e in eps if "Wayback" in e.get("source", [])]
if wayback_eps:
emit.section(f"WAYBACK URLS ({len(wayback_eps)} archived endpoints)", orbital=True)
for ep in sorted(wayback_eps, key=lambda e: e.get("url","")):
u = ep.get("url","")
con = ep.get("confidence","LOW")
if nc:
print(f" ● {con:<12} {u}")
else:
col = {"CONFIRMED": C.G, "HIGH": C.Y, "MEDIUM": C.CYD, "LOW": C.GR}.get(con, C.GR)
print(f" {C.MG}●{C.RST} {col}{con:<12}{C.RST} {C.W}{u}{C.RST}")
comments = intel.get("comments", [])
cmt_filtered = [] # built below, displayed after SECURITY FINDINGS
if comments:
_HIGH_SIGNAL_KW = re.compile(
r'(?:password|passwd|secret|token|api[_-]?key|'
r'credential|auth[_-]?key|private[_-]?key|access[_-]?key|'
r'todo[:\s]+remove|fixme|do\s+not\s+commit|'
r'debug[_-]?mode|hack|bypass|hardcod|'
r'internal[_-]?(?:use|only|api|endpoint)|'
r'prod(?:uction)[_-](?:key|token|secret|db|host)|'
r'staging[_-](?:key|token|secret)|'
r'backup[_-](?:key|path|db)|'
r'admin[_-](?:pass|key|token|secret))',
re.I
)
_LOW_SIGNAL_KW = re.compile(
r'(?:admin|internal|staging|prod(?:uction)?|backup|'
r'temp(?:orary)?|beta|debug|version|framework|'
r'new[_-]home|homepage|disabled|removed)',
re.I
)
_SCHEME_HOST_RE = re.compile(r'https?://[^\s/]+', re.I)
_FULL_URL_RE = re.compile(r'https?://\S+', re.I)
_INT_PATH_RE = re.compile(r'(?<![a-z0-9\-\._:/])/[a-z0-9_\-\.]{2,}', re.I)
_EXT_URL_RE = re.compile(r'https?://', re.I)
def _has_internal_path(txt: str) -> bool:
no_urls = _FULL_URL_RE.sub("", txt)
no_urls = _SCHEME_HOST_RE.sub("", no_urls)
return bool(_INT_PATH_RE.search(no_urls))
def _is_sensitive_comment(txt: str) -> bool:
if _HIGH_SIGNAL_KW.search(txt):
return True
if _LOW_SIGNAL_KW.search(txt) and _has_internal_path(txt):
return True
if _has_internal_path(txt) and not _EXT_URL_RE.search(txt):
return True
if _EXT_URL_RE.search(txt) and _has_internal_path(txt):
return True
for m in _FULL_URL_RE.finditer(txt):
host_m = re.match(r'https?://([^/\s]+)', m.group(0))
if host_m:
h = host_m.group(1).lower()
if (re.match(r'^\d+\.\d+\.\d+\.\d+', h) or
h in ("localhost", "127.0.0.1") or
any(h.endswith(s) for s in
(".local", ".internal", ".corp", ".lan", ".intranet"))):
return True
return False
_sensitive_comments = [
c for c in comments
if _is_sensitive_comment(str(c.get("content","") or ""))
]
if _sensitive_comments:
_norm_re = re.compile(r'\b\d+\.\d+\b')
seen_norm: dict = {}
for c in _sensitive_comments:
full = str(c.get("content","") or c.get("text","") or c)
raw_sources = c.get("all_sources") or ([c.get("source","")] if c.get("source") else [])
key = _norm_re.sub("N", full)
if key not in seen_norm:
seen_norm[key] = {"content": full, "sources": list(dict.fromkeys(s for s in raw_sources if s))}
else:
for s in raw_sources:
if s and s not in seen_norm[key]["sources"]:
seen_norm[key]["sources"].append(s)
_html_tag_re = re.compile(r'<[^>]+>')
_pure_url_re = re.compile(r'^https?://\S+$')
_mostly_html_re = re.compile(r'<(?:a|img|div|span|h[1-6]|p|ul|li|nav|section|header|footer)\b', re.I)
_path_in_cmt_re = re.compile(r'(?:^|\s)(/[a-z0-9_\-\.]{2,}(?:/[a-z0-9_\-\.]*)*/?)', re.I)
_MAX_CMT = 160
def _clean_cmt(raw):
return re.sub(r'\s+', ' ', _html_tag_re.sub(" ", raw)).strip()
def _noise_cmt(raw, cleaned):
return (_mostly_html_re.search(raw) or len(cleaned) < 8
or bool(_pure_url_re.match(cleaned)))
all_ep_urls = [e.get("url","") for e in eps]
cmt_filtered = []
for entry in seen_norm.values():
cleaned = _clean_cmt(entry["content"])
if _noise_cmt(entry["content"], cleaned):
continue
display = cleaned if len(cleaned) <= _MAX_CMT else cleaned[:_MAX_CMT] + "…"
qpaths = []
for m in _path_in_cmt_re.finditer(entry["content"]):
cp = m.group(1).strip()
qpaths.extend(u for u in all_ep_urls
if urlparse(u).path.rstrip("/") == cp.rstrip("/"))
cmt_filtered.append({
"display": display,
"sources": entry["sources"],
"queued_paths": list(dict.fromkeys(qpaths)),
})
if cmt_filtered:
pass # displayed later, after SECURITY FINDINGS
if nc:
print(f" {'METHOD':<7} {'CONFIDENCE':<10} FLAGS URL")
print(f" {'──'*34}")
else:
print(f" {C.GL}{'METHOD':<7} {'CONFIDENCE':<10} FLAGS URL{C.RST}")
print(f" {C.GR}{'──'*34}{C.RST}")
order = {"CONFIRMED": 0, "HIGH": 1, "MEDIUM": 2, "LOW": 3}
_NOISE_SOURCES = frozenset({"Backup_Probe", "Backup_Suffix", "WellKnown", "Leaked_File"})
real_eps = [e for e in eps if not all(s in _NOISE_SOURCES for s in e.get("source", ["Crawl"]))]
backup_eps = [e for e in eps if all(s in _NOISE_SOURCES for s in e.get("source", ["Crawl"]))]
sorted_eps = sorted(real_eps, key=lambda e: (order.get(e.get("confidence", "LOW"), 4), e.get("url", ""))) +\
sorted(backup_eps, key=lambda e: e.get("url", ""))