Repository navigation
Expand file tree
/
Copy pathcybercodex.py
More file actions
1054 lines (916 loc) · 55 KB
/
Copy pathcybercodex.py
File metadata and controls
1054 lines (916 loc) · 55 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
# -*- coding: utf-8 -*-
"""
CyberCodex - 23-Source Zero-Cost OSINT, Image Forensics, Data Breach/Leak & Cyber Warfare Engine
================================================================================================
Author: Çınar (prox0959)
Platform: Windows CMD / PowerShell, Linux, macOS (Zero External Dependencies)
Languages: 11 (TR, EN, ZH, ES, HI, AR, PT, RU, JA, DE, FR)
Commands:
intel <ip_or_domain> -> 23-source parallel OSINT, Breach/Leak, Stealer & Threat Intel scan
image <file_or_url> -> Deep Image OSINT: Binary EXIF, GPS Street Reverse-Geocoding, C2PA AI & Stego EOF Hunter
leak <domain|email|pass> -> Dedicated Data Breach History (Latest/Top Leak, DataClasses, Stealers & K-Anonymity)
cve <CVE-XXXX-XXXX> -> Live CVE, CISA KEV, FIRST EPSS & GitHub Public PoC/Exploit hunter
ioc <hash_or_indicator> -> Malware SHA256/MD5 hash & C2 lookup (ThreatFox / Codex / Feodo)
mitre <Txxxx_or_keyword> -> Official MITRE ATT&CK technique & detection lookup
attack <name_or_id> -> Unbiased technical anatomy of major cyber operations
compare <atk1> <atk2> -> Side-by-side comparison matrix of two cyber attacks
apt <group_name> -> Threat Actor (APT) intelligence profile
ransom -> Live global ransomware victim & group feed
dict <term_or_id> -> Dual-perspective (OSINT/Red + Blue/DFIR) technical lexicon
dork <target> -> Automated OSINT dorks & Wazuh/Sigma/KQL SIEM queries
search <keyword> -> Search across all attacks, APTs, MITRE, and lexicon terms
list -> List all indexed cyber attacks, APTs, MITRE, and lexicon terms
update -> Force live self-update (CISA KEV, Feodo C2, Tor Exit Nodes, Ransomware)
shell -> Launch interactive CyberCodex console (`codex>`)
"""
import argparse
import cmd
import json
import os
import shlex
import sys
from typing import Dict, Any, Optional, List
if hasattr(sys.stdout, "reconfigure"):
try:
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
except Exception:
pass
from i18n_engine import I18nEngine, SUPPORTED_LANGUAGES
from live_updater import LiveThreatUpdater, MITRE_ATTACK_DB
from api_aggregator import ZeroCostAPIAggregator
from incident_codex import IncidentCodexEngine
from cyber_lexicon import CyberLexiconEngine
from query_generator import DorkAndSIEMGenerator
os.system("")
C_RESET = "\033[0m"
C_BOLD = "\033[1m"
C_CYAN = "\033[96m"
C_GREEN = "\033[92m"
C_YELLOW = "\033[93m"
C_RED = "\033[91m"
C_MAGENTA = "\033[95m"
C_DIM = "\033[90m"
class CyberCodexApp:
"""
Core orchestrator uniting the 11-Language Engine, Self-Updating Feeds,
21-Source Zero-Cost Public API Aggregator, Breach/Leak & Stealer Engine,
Incident Codex, MITRE ATT&CK, and Technical Lexicon.
"""
def __init__(self, lang: str = "tr", auto_translate: bool = False):
self.i18n = I18nEngine(lang=lang, auto_translate=auto_translate)
self.updater = LiveThreatUpdater(auto_sync_hours=12.0)
self.aggregator = ZeroCostAPIAggregator(updater=self.updater)
self.codex = IncidentCodexEngine()
self.lexicon = CyberLexiconEngine()
self.dorker = DorkAndSIEMGenerator()
def print_banner(self) -> None:
sub = self.i18n.t("banner_sub")
langs = " | ".join(k.upper() for k in SUPPORTED_LANGUAGES.keys())
print(f"{C_CYAN}{C_BOLD}" + "=" * 90)
print(" ██████╗██╗ ██╗██████╗ ███████╗██████╗ ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗")
print(" ██╔════╝╚██╗ ██╔╝██╔══██╗██╔════╝██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝╚██╗██╔╝")
print(" ██║ ╚████╔╝ ██████╔╝█████╗ ██████╔╝██║ ██║ ██║██║ ██║█████╗ ╚███╔╝ ")
print(" ██║ ╚██╔╝ ██╔══██╗██╔══╝ ██╔══██╗██║ ██║ ██║██║ ██║██╔══╝ ██╔██╗ ")
print(" ╚██████╗ ██║ ██████╔╝███████╗██║ ██║╚██████╗╚██████╔╝██████╔╝███████╗██╔╝ ██╗")
print(" ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝")
print(f" {C_GREEN}{sub}{C_CYAN}")
print(f" {C_YELLOW}[11 Languages: {langs}] [Active: {self.i18n.lang.upper()}]{C_CYAN}")
print("=" * 90 + f"{C_RESET}")
def _format_breach_and_stealer_block(
self,
hibp: Dict[str, Any],
hrock: Dict[str, Any],
section_title: str,
) -> List[str]:
lines: List[str] = []
lines.append(f"\n{C_YELLOW}{C_BOLD}{section_title}{C_RESET}")
if hibp and hibp.get("breach_count", 0) > 0:
cnt = hibp["breach_count"]
tot_pwn = hibp["total_pwn_count"]
latest = hibp.get("most_recent_leak") or {}
largest = hibp.get("top_largest_leak") or {}
all_classes = hibp.get("all_leaked_data_classes", [])
lines.append(
f" • {C_RED}{C_BOLD}Documented Data Breaches (HIBP): {cnt} Incidents | "
f"Total Compromised Accounts: {tot_pwn:,}{C_RESET}"
)
lines.append(
f" • {C_YELLOW}{C_BOLD}[LATEST LEAK / EN SON SIZINTI]{C_RESET} "
f"{C_BOLD}{latest.get('title')} ({latest.get('name')}){C_RESET} -> "
f"Date: {C_RED}{C_BOLD}{latest.get('breach_date')}{C_RESET} | "
f"Leaked Records: {C_YELLOW}{latest.get('pwn_count', 0):,}{C_RESET}"
)
lines.append(
f" - Compromised Data: {', '.join(latest.get('data_classes', []))}"
)
if latest.get("description"):
lines.append(f" - Incident Info: {latest['description'][:280]}...")
lines.append(
f" • {C_RED}{C_BOLD}[TOP / EN BÜYÜK SIZINTI]{C_RESET} "
f"{C_BOLD}{largest.get('title')} ({largest.get('name')}){C_RESET} -> "
f"Date: {C_RED}{C_BOLD}{largest.get('breach_date')}{C_RESET} | "
f"Leaked Records: {C_RED}{C_BOLD}{largest.get('pwn_count', 0):,}{C_RESET}"
)
lines.append(
f" - Compromised Data: {', '.join(largest.get('data_classes', []))}"
)
if largest.get("description") and largest.get("name") != latest.get("name"):
lines.append(f" - Incident Info: {largest['description'][:280]}...")
lines.append(f" • All Leaked Data Types Across History: {C_CYAN}{', '.join(all_classes)}{C_RESET}")
else:
lines.append(f" • HIBP Public Breach DB: {C_GREEN}0 Verified Public Database Breaches on Record{C_RESET}")
if hrock and (hrock.get("total_compromised", 0) > 0 or hrock.get("employees_compromised", 0) > 0):
lines.append(
f" • {C_MAGENTA}{C_BOLD}[HUDSON ROCK INFOSTEALER TELEMETRY (RedLine / Raccoon / Vidar / Lumma)]{C_RESET}"
)
lines.append(
f" - Total Infected Stealer Logs: {C_RED}{C_BOLD}{hrock.get('total_compromised', 0):,}{C_RESET} "
f"(Corporate Employees: {C_RED}{hrock.get('employees_compromised', 0):,}{C_RESET} | "
f"Users/Clients: {C_YELLOW}{hrock.get('users_compromised', 0):,}{C_RESET} | "
f"Third-Parties: {hrock.get('third_parties_compromised', 0):,})"
)
lines.append(
f" - Latest Stealer Compromise: Last Employee Leak: {C_RED}{hrock.get('last_employee_compromised')}{C_RESET} | "
f"Last User Leak: {C_RED}{hrock.get('last_user_compromised')}{C_RESET}"
)
fams = hrock.get("top_stealer_families") or {}
if fams:
fam_str = ", ".join(f"{k}: {v:,}" for k, v in fams.items())
lines.append(f" - Top Infostealer Families: {fam_str}")
pw_aud = hrock.get("employee_password_audit") or {}
if pw_aud.get("total_audited"):
lines.append(
f" - Leaked Employee Passwords: Audited={pw_aud['total_audited']:,} | "
f"Weak={pw_aud.get('weak_pct')}% ({pw_aud.get('weak_qty', 0):,}) | "
f"Too Weak={pw_aud.get('too_weak_pct')}% ({pw_aud.get('too_weak_qty', 0):,}) | "
f"Strong={pw_aud.get('strong_pct')}% ({pw_aud.get('strong_qty', 0):,})"
)
upw_aud = hrock.get("user_password_audit") or {}
if upw_aud.get("total_audited"):
lines.append(
f" - Leaked User Passwords: Audited={upw_aud['total_audited']:,} | "
f"{C_RED}Weak={upw_aud.get('weak_pct')}% ({upw_aud.get('weak_qty', 0):,}){C_RESET} | "
f"{C_RED}Too Weak={upw_aud.get('too_weak_pct')}% ({upw_aud.get('too_weak_qty', 0):,}){C_RESET} | "
f"Strong={upw_aud.get('strong_pct')}% ({upw_aud.get('strong_qty', 0):,})"
)
avs = hrock.get("bypassed_antiviruses") or []
if avs:
av_str = ", ".join(f"{a['name']} ({a['count']})" for a in avs[:6])
lines.append(f" - Victim Antiviruses Bypassed: {av_str}")
c_urls = hrock.get("compromised_client_urls") or []
e_urls = hrock.get("compromised_employee_urls") or []
combined_urls = e_urls[:5] + c_urls[:10]
if combined_urls:
lines.append(
f" - {C_YELLOW}{C_BOLD}Top Compromised Login/Portal URLs (Where Credentials Were Stolen):{C_RESET}"
)
for u in combined_urls[:10]:
lines.append(
f" • [{u.get('type', 'User')}] {C_RED}{C_BOLD}{u.get('occurrence', 0):,} leaked logins{C_RESET} -> {C_CYAN}{u.get('url')}{C_RESET}"
)
return lines
def render_intel(self, target: str, export_path: Optional[str] = None) -> Dict[str, Any]:
self.updater.ensure_fresh(force=False)
data = self.aggregator.investigate_target(target)
t = self.i18n.t
lines: List[str] = []
lines.append(f"\n{C_CYAN}{C_BOLD}[+] {t('intel_header')}{C_RESET}")
lines.append("-" * 90)
lines.append(f" {C_BOLD}{t('target')}:{C_RESET} {data['target']} ({data['target_type']} -> IP: {C_GREEN}{data['resolved_ip']}{C_RESET})")
lines.append(f" {C_BOLD}{t('timestamp')}:{C_RESET} {data['timestamp']}")
lines.append(f" {C_BOLD}{t('cache_status')}:{C_RESET} {'HIT (Local Instant Cache)' if data.get('cache_hit') else 'LIVE (21-Source Parallel Public APIs)'}")
# 1. Network, ASN, RIPE BGP & Tor Exit Node
net = data.get("network_asn", {})
ripe = data.get("ripe_bgp", {})
is_tor = data.get("is_tor_exit_node", False)
lines.append(f"\n{C_YELLOW}{C_BOLD}[1] {t('network_asn')}{C_RESET}")
if net:
lines.append(f" • ASN / Org: {net.get('asn', 'N/A')} | {net.get('org', 'N/A')} ({net.get('isp', 'N/A')})")
lines.append(f" • Location: {net.get('country', 'N/A')} / {net.get('region', '')} / {net.get('city', '')}")
lines.append(f" • Reverse DNS: {net.get('reverse_dns') or 'None'}")
lines.append(f" • Hosting / Proxy: Datacenter={net.get('is_datacenter_hosting')} | Proxy/VPN={net.get('is_proxy_vpn')}")
if ripe:
lines.append(f" • RIPE BGP Prefix: {C_CYAN}{ripe.get('bgp_prefix', 'N/A')}{C_RESET} (Origin ASNs: {ripe.get('origin_asns', [])})")
tor_badge = f"{C_RED}{C_BOLD}ACTIVE TOR EXIT NODE!{C_RESET}" if is_tor else f"{C_GREEN}False (Not a Tor Exit Node){C_RESET}"
lines.append(f" • Tor Exit Status: {tor_badge}")
# 2. Shodan InternetDB
shodan = data.get("shodan_internetdb", {})
ports = shodan.get("ports", [])
vulns = shodan.get("vulns", [])
cpes = shodan.get("cpes", [])
lines.append(f"\n{C_YELLOW}{C_BOLD}[2] {t('open_ports')}{C_RESET}")
lines.append(f" • Open Ports: {C_GREEN}{ports if ports else 'None detected via InternetDB'}{C_RESET}")
lines.append(f" • Hostnames/Tags: {shodan.get('hostnames', [])} | Tags: {shodan.get('tags', [])}")
lines.append(f" • CPE Fingerprints: {cpes[:6] if cpes else 'None'}")
# 3. Live DNS, SPF, DMARC & Email Spoofing Audit
dns_dmarc = data.get("dns_dmarc", {})
if dns_dmarc:
lines.append(f"\n{C_YELLOW}{C_BOLD}[3] {t('dns_dmarc')}{C_RESET}")
lines.append(f" • MX Servers: {dns_dmarc.get('mx_records') or 'None'}")
lines.append(f" • Name Servers: {dns_dmarc.get('ns_records') or 'None'}")
lines.append(f" • SPF Record: {dns_dmarc.get('spf_record')}")
lines.append(f" • DMARC Policy: {dns_dmarc.get('dmarc_record')}")
risk = dns_dmarc.get("email_spoofing_risk", "")
risk_color = C_RED if "HIGH" in risk else (C_YELLOW if "MODERATE" in risk else C_GREEN)
lines.append(f" • Spoofing Verdict: {risk_color}{C_BOLD}{risk}{C_RESET}")
# 4. Live SSL/TLS Certificate & C2 Check
ssl_cert = data.get("live_ssl_cert", {})
if ssl_cert:
lines.append(f"\n{C_YELLOW}{C_BOLD}[4] {t('ssl_live')}{C_RESET}")
lines.append(f" • TLS / Cipher: {ssl_cert.get('tls_version')} | {ssl_cert.get('cipher_suite')}")
lines.append(f" • Subject / Issuer: CN={ssl_cert.get('subject_cn')} | Issuer={ssl_cert.get('issuer_org')}")
lines.append(f" • Serial / Expiry: {ssl_cert.get('serial_number')} | Valid Until: {ssl_cert.get('not_after')}")
lines.append(f" • SHA-256 Cert FP: {C_CYAN}{ssl_cert.get('sha256_fingerprint')}{C_RESET}")
lines.append(f" • C2 Cert Check: {C_GREEN}{ssl_cert.get('c2_cert_heuristic')}{C_RESET}")
# 5. HTTP Security Headers & RFC 9116 security.txt Audit
hdrs = data.get("http_security_headers", {})
if hdrs:
lines.append(f"\n{C_YELLOW}{C_BOLD}[5] {t('http_headers')}{C_RESET}")
lines.append(f" • Server Banner: {hdrs.get('server_banner')} (HTTP {hdrs.get('http_status')})")
lines.append(
f" • Header Controls: HSTS={hdrs.get('hsts')} | CSP={hdrs.get('csp')} | "
f"X-Frame-Options={hdrs.get('x_frame_options')} | X-Content-Type={hdrs.get('x_content_type_options')}"
)
lines.append(
f" • RFC 9116 Policy: /.well-known/security.txt={hdrs.get('security_txt_rfc9116')} | "
f"Posture Score: {C_CYAN}{C_BOLD}{hdrs.get('posture_score')}{C_RESET}"
)
# 6. Data Breach History (Latest Leak, Top Leak, Leaked Data Classes & Hudson Rock Infostealers)
lines.extend(
self._format_breach_and_stealer_block(
hibp=data.get("hibp_breaches") or {},
hrock=data.get("hudsonrock_stealers") or {},
section_title=f"[6] {t('breach_section')}",
)
)
# 7. Vulnerabilities & Threat Feeds
lines.append(f"\n{C_YELLOW}{C_BOLD}[7] {t('vulns_found')} & {t('threat_feeds')}{C_RESET}")
if vulns:
lines.append(f" • CVEs on Host: {C_RED}{', '.join(vulns[:15])}{C_RESET}")
else:
lines.append(f" • CVEs on Host: {C_GREEN}0 Known CVEs exposed on public scan{C_RESET}")
for k in data.get("cisa_kev_alerts", []):
lines.append(f" • {C_RED}{C_BOLD}[CISA KEV ALERT]{C_RESET} {k['cveID']} ({k['vulnerabilityName']}) - Ransomware Use: {k['knownRansomwareCampaignUse']}")
feodo = data.get("feodo_c2_alert")
if feodo:
lines.append(f" • {C_RED}{C_BOLD}[ABUSE.CH FEODO BOTNET C2]{C_RESET} Active {feodo.get('malware')} C2 Server! (Status: {feodo.get('status')})")
else:
lines.append(f" • Feodo C2 Check: {C_GREEN}CLEAN (Not listed in active abuse.ch Botnet C2 feed){C_RESET}")
phish = data.get("phishstats_hits", [])
if phish:
lines.append(f" • {C_RED}[PhishStats Feed]{C_RESET} {len(phish)} recent phishing URLs associated with query:")
for p in phish[:3]:
lines.append(f" - {p.get('date')} | Score: {p.get('score')} | {p.get('url')}")
# 8. Certificate Transparency & Wayback
subs = data.get("crtsh_subdomains", [])
if subs:
lines.append(f"\n{C_YELLOW}{C_BOLD}[8] {t('ssl_subdomains')} (Top {len(subs)}){C_RESET}")
for s in subs[:10]:
lines.append(f" • {s}")
wb = data.get("wayback_endpoints", [])
if wb:
lines.append(f"\n{C_YELLOW}{C_BOLD}[9] {t('wayback_urls')}{C_RESET}")
for u in wb[:8]:
lines.append(f" • {u}")
# Auto-Correlation Bridge
corrs = data.get("codex_correlations", [])
if corrs:
lines.append(f"\n{C_MAGENTA}{C_BOLD}[!] {t('correlation_title')}{C_RESET}")
for c in corrs:
lines.append(f" ⚡ {C_BOLD}{c['attack_name']}{C_RESET}: {c['reason']}")
lines.append(f" 👉 Run: {C_CYAN}python cybercodex.py {c['command_hint']} --lang {self.i18n.lang}{C_RESET}")
output_text = "\n".join(lines)
print(output_text)
if export_path:
self._export_dossier(export_path, data, output_text)
return data
def render_leak(
self,
query: str,
is_password: bool = False,
export_path: Optional[str] = None,
download_leaks: bool = False,
) -> Dict[str, Any]:
data = self.aggregator.investigate_leak(query, is_password=is_password)
t = self.i18n.t
lines: List[str] = []
lines.append(f"\n{C_CYAN}{C_BOLD}[+] {t('leak_header')}{C_RESET}")
lines.append("=" * 90)
lines.append(f" {C_BOLD}{t('target')}:{C_RESET} {C_YELLOW}{data['query']}{C_RESET} (Mode: {data['mode']})")
lines.append(f" {C_BOLD}{t('timestamp')}:{C_RESET} {data['timestamp']}")
if data["mode"] == "PASSWORD_K_ANONYMITY":
pa = data["password_audit"]
cnt = pa["leak_count"]
lines.append(f"\n{C_YELLOW}{C_BOLD}[1] HIBP Pwned Passwords K-Anonymity Check (Only SHA-1 Prefix '{pa['sha1_prefix_sent']}' Sent){C_RESET}")
lines.append(f" • Local Full SHA-1: {pa['sha1_full_local']}")
if cnt > 0:
lines.append(f" • Exposure Verdict: {C_RED}{C_BOLD}COMPROMISED! Seen {cnt:,} times in global password dumps!{C_RESET}")
else:
lines.append(f" • Exposure Verdict: {C_GREEN}{C_BOLD}CLEAN (0 occurrences in 850M+ leaked password corpus){C_RESET}")
else:
if "username_stealer_hits" in data:
uh = data.get("username_stealer_hits") or {}
lines.append(f"\n{C_YELLOW}{C_BOLD}[1] Username Infostealer Infection Logs (Hudson Rock Cavalier){C_RESET}")
if uh.get("stealer_count", 0) > 0:
lines.append(f" • {C_RED}{C_BOLD}ALERT: Username found in {uh['stealer_count']} Infostealer logs!{C_RESET}")
for s in uh.get("stealers", [])[:10]:
lines.append(
f" - Date: {s.get('date_compromised')} | OS: {s.get('operating_system')} | "
f"Host: {s.get('computer_name')} | Malware: {s.get('malware_path')}"
)
else:
lines.append(f" • {C_GREEN}No direct Infostealer infection logs found for this username.{C_RESET}")
if "email_stealer_hits" in data:
eh = data.get("email_stealer_hits") or {}
lines.append(f"\n{C_YELLOW}{C_BOLD}[1] Email Infostealer Infection Logs (Hudson Rock Cavalier){C_RESET}")
if eh.get("stealer_count", 0) > 0:
lines.append(f" • {C_RED}{C_BOLD}ALERT: Email found in {eh['stealer_count']} Infostealer logs!{C_RESET}")
for s in eh.get("stealers", [])[:10]:
lines.append(
f" - Date: {s.get('date_compromised')} | OS: {s.get('operating_system')} | "
f"Host: {s.get('computer_name')} | Malware: {s.get('malware_path')}"
)
else:
lines.append(f" • {C_GREEN}No direct Infostealer infection logs found for this email.{C_RESET}")
hibp = data.get("domain_breaches") or {}
hrock = data.get("domain_stealer_stats") or {}
if hibp or hrock:
lines.extend(
self._format_breach_and_stealer_block(
hibp=hibp,
hrock=hrock,
section_title=f"[•] {t('breach_section')}",
)
)
comb = data.get("comb_leaks") or {}
comb_cnt = comb.get("total_count", 0)
comb_lines = comb.get("leaked_lines") or []
lines.append(f"\n{C_YELLOW}{C_BOLD}[•] ProxyNova COMB (3.2 Billion Breach Corpus) Plaintext Credential Dump:{C_RESET}")
if comb_cnt > 0 or comb_lines:
lines.append(
f" • {C_RED}{C_BOLD}MATCHES FOUND:{C_RESET} {C_RED}{comb_cnt:,}{C_RESET} leaked credential records in COMB corpus "
f"(Showing top {min(15, len(comb_lines))}, full {len(comb_lines)} saved to disk):"
)
for cl in comb_lines[:15]:
lines.append(f" 🔑 {C_YELLOW}{cl}{C_RESET}")
else:
lines.append(f" • {C_GREEN}0 plaintext email:password lines in public COMB sample for this target.{C_RESET}")
timeline = hibp.get("breach_timeline") or []
if len(timeline) > 1:
lines.append(f"\n{C_YELLOW}{C_BOLD}[•] Complete Chronological Leak Timeline ({len(timeline)} Breaches):{C_RESET}")
for idx, item in enumerate(timeline, 1):
lines.append(
f" {idx}. [{C_RED}{item['breach_date']}{C_RESET}] {C_BOLD}{item['title']}{C_RESET} "
f"({item['pwn_count']:,} accounts) -> {', '.join(item['data_classes'][:6])}"
)
output_text = "\n".join(lines)
print(output_text)
if download_leaks and data["mode"] != "PASSWORD_K_ANONYMITY":
bundle = self.aggregator.download_leak_bundle(data, report_text=output_text)
print(f"\n{C_GREEN}{C_BOLD}[📥] LEAK VERİ PAKETİ BİLGİSAYARINA İNDİRİLDİ (DOWNLOADED LEAK BUNDLE):{C_RESET}")
print(f" 📂 Klasör / Directory: {C_CYAN}{C_BOLD}{bundle['bundle_dir']}{C_RESET}")
for fw in bundle["files_written"]:
print(f" ✔ {C_YELLOW}{fw['name']}{C_RESET} ({fw['records']} kayıt) -> {fw['description']}")
if export_path:
self._export_dossier(export_path, data, output_text)
return data
def render_cve(self, cve_id: str, export_path: Optional[str] = None) -> Dict[str, Any]:
self.updater.ensure_fresh(force=False)
data = self.aggregator.investigate_cve(cve_id)
t = self.i18n.t
detail = data.get("detail", {})
epss = data.get("epss", {})
kev = data.get("cisa_kev")
pocs = data.get("github_pocs", [])
lines: List[str] = []
lines.append(f"\n{C_CYAN}{C_BOLD}[+] {t('cve_header')}{C_RESET}")
lines.append("-" * 90)
lines.append(f" {C_BOLD}CVE ID:{C_RESET} {C_RED}{C_BOLD}{data['cve_id']}{C_RESET}")
lines.append(f" {C_BOLD}CVSS / Severity:{C_RESET} {detail.get('cvss_score') or 'N/A'} ({detail.get('severity', 'UNKNOWN')})")
lines.append(f" {C_BOLD}Published / Source:{C_RESET} {detail.get('published') or 'N/A'} | {detail.get('source')}")
if epss.get("epss_score") is not None:
lines.append(
f" {C_BOLD}FIRST EPSS Score:{C_RESET} {C_YELLOW}{epss['epss_score']}% probability of exploitation in next 30 days "
f"(Percentile: {epss['epss_percentile']}%){C_RESET}"
)
if kev:
lines.append(
f" {C_BOLD}CISA KEV Status:{C_RESET} {C_RED}{C_BOLD}ACTIVELY EXPLOITED IN THE WILD{C_RESET} "
f"(Added: {kev.get('dateAdded')} | Ransomware Campaign Use: {kev.get('knownRansomwareCampaignUse')})"
)
lines.append(f" {C_BOLD}Required Action:{C_RESET} {kev.get('requiredAction')}")
else:
lines.append(f" {C_BOLD}CISA KEV Status:{C_RESET} {C_GREEN}Not currently listed in CISA KEV catalog{C_RESET}")
summary = detail.get("summary", "No description available.")
if self.i18n.lang not in ("en",) and self.i18n.auto_translate:
summary = self.i18n.translate_text_zero_cost(summary, self.i18n.lang)
lines.append(f"\n{C_YELLOW}{C_BOLD}[•] {t('definition')}:{C_RESET}\n {summary}")
lines.append(f"\n{C_YELLOW}{C_BOLD}[•] {t('github_pocs')}:{C_RESET}")
if pocs:
for p in pocs:
lines.append(
f" 💥 {C_GREEN}{C_BOLD}{p['full_name']}{C_RESET} (⭐ {p['stars']} | Updated: {p['updated_at']})\n"
f" URL: {C_CYAN}{p['html_url']}{C_RESET}\n"
f" Info: {p['description']}"
)
else:
lines.append(" • No public PoC repositories found on GitHub search.")
corrs = data.get("codex_correlations", [])
if corrs:
lines.append(f"\n{C_MAGENTA}{C_BOLD}[!] {t('correlation_title')}{C_RESET}")
for c in corrs:
lines.append(f" ⚡ {C_BOLD}{c['attack_name']}{C_RESET} ({c['reason']})")
lines.append(f" 👉 Run: {C_CYAN}python cybercodex.py {c['command_hint']} --lang {self.i18n.lang}{C_RESET}")
output_text = "\n".join(lines)
print(output_text)
if export_path:
self._export_dossier(export_path, data, output_text)
return data
def render_ioc(self, indicator: str, export_path: Optional[str] = None) -> Dict[str, Any]:
self.updater.ensure_fresh(force=False)
data = self.aggregator.investigate_ioc(indicator)
t = self.i18n.t
lines: List[str] = []
lines.append(f"\n{C_CYAN}{C_BOLD}[+] {t('ioc_header')}{C_RESET}")
lines.append("-" * 90)
lines.append(f" {C_BOLD}Indicator:{C_RESET} {C_YELLOW}{data['indicator']}{C_RESET} ({data['indicator_type']})")
lines.append(f" {C_BOLD}{t('timestamp')}:{C_RESET} {data['timestamp']}")
seed = data.get("codex_malware_seed")
if seed:
lines.append(f"\n{C_RED}{C_BOLD}[!] CYBERCODEX HISTORICAL MALWARE VAULT MATCH:{C_RESET}")
lines.append(f" • Malware Family: {C_RED}{C_BOLD}{seed['malware_family']}{C_RESET}")
lines.append(f" • Artifact Name: {seed['file_name']} ({seed['file_type']})")
lines.append(f" • Severity: {seed['severity']}")
lines.append(f" 👉 Full Anatomy: {C_CYAN}python cybercodex.py attack {seed['linked_attack']} --lang {self.i18n.lang}{C_RESET}")
tf_hits = data.get("threatfox_hits", [])
lines.append(f"\n{C_YELLOW}{C_BOLD}[•] abuse.ch ThreatFox Live Intelligence:{C_RESET}")
if tf_hits:
for h in tf_hits:
lines.append(
f" 🦠 {C_RED}{C_BOLD}{h['malware']}{C_RESET} | Type: {h['threat_type']} | "
f"Confidence: {h['confidence']}% | First Seen: {h['first_seen']}"
)
else:
lines.append(f" • {C_GREEN}No recent active ThreatFox hits for this indicator.{C_RESET}")
if data.get("feodo_c2_hit"):
f = data["feodo_c2_hit"]
lines.append(f"\n{C_RED}{C_BOLD}[!] ABUSE.CH FEODO TRACKER C2 HIT:{C_RESET} Active {f.get('malware')} C2 on port {f.get('port')}")
if data.get("is_tor_exit"):
lines.append(f"\n{C_RED}{C_BOLD}[!] TOR BULK LIST:{C_RESET} Indicator is an active Tor Exit Node.")
output_text = "\n".join(lines)
print(output_text)
if export_path:
self._export_dossier(export_path, data, output_text)
return data
def render_mitre(self, query: str) -> List[Dict[str, Any]]:
t = self.i18n.t
hits = self.updater.search_mitre(query)
print(f"\n{C_CYAN}{C_BOLD}[+] {t('mitre_header')} -> '{query}'{C_RESET}")
print("=" * 90)
if not hits:
print(f"{C_RED}[!] {t('not_found')}: '{query}'{C_RESET}")
return []
for item in hits:
desc = item["description"]
det = item["detection"]
if self.i18n.lang not in ("en",) and self.i18n.auto_translate:
desc = self.i18n.translate_text_zero_cost(desc, self.i18n.lang)
det = self.i18n.translate_text_zero_cost(det, self.i18n.lang)
print(f"\n {C_GREEN}{C_BOLD}[{item['id']}] {item['name']}{C_RESET}")
print(f" • {C_BOLD}Tactic:{C_RESET} {item['tactic']} | {C_BOLD}Platforms:{C_RESET} {', '.join(item['platforms'])}")
print(f" • {C_YELLOW}Technical Description:{C_RESET}\n {desc}")
print(f" • {C_CYAN}SOC / DFIR Detection:{C_RESET}\n {det}")
return hits
def render_attack(self, query: str, export_path: Optional[str] = None) -> Optional[Dict[str, Any]]:
atk = self.codex.get_attack(query)
t = self.i18n.t
if not atk:
print(f"{C_RED}[!] {t('not_found')}: '{query}'{C_RESET}")
return None
summary = self.i18n.pick_localized_field(atk, "summary")
kill_chain = atk["kill_chain_tr"] if self.i18n.lang == "tr" else atk["kill_chain_en"]
impact = self.i18n.pick_localized_field(atk, "impact")
lines: List[str] = []
lines.append(f"\n{C_CYAN}{C_BOLD}[+] {t('attack_header')}{C_RESET}")
lines.append("=" * 90)
lines.append(f" {C_BOLD}Operation / Incident:{C_RESET} {C_GREEN}{C_BOLD}{atk['name']}{C_RESET}")
lines.append(f" {C_BOLD}Timeline / Year:{C_RESET} {atk['year']}")
lines.append(f" {C_BOLD}Classification:{C_RESET} {atk['category']}")
lines.append(f" {C_BOLD}Technical Attribution:{C_RESET}{atk['attributed_to']}")
lines.append(f" {C_BOLD}Target Sector:{C_RESET} {atk['target_sector']}")
lines.append(f" {C_BOLD}Exploited CVEs:{C_RESET} {', '.join(atk['cves']) if atk['cves'] else 'Zero-Exploit / Identity & Credential Abuse'}")
lines.append(f" {C_BOLD}{t('mitre_ttps')}:{C_RESET} {', '.join(atk['mitre_ttps'])}")
lines.append(f"\n{C_YELLOW}{C_BOLD}[1] {t('definition')}{C_RESET}")
lines.append(f" {summary}")
lines.append(f"\n{C_YELLOW}{C_BOLD}[2] {t('kill_chain')}{C_RESET}")
for step in kill_chain:
lines.append(f" {step}")
lines.append(f"\n{C_YELLOW}{C_BOLD}[3] {t('iocs_detection')}{C_RESET}")
for ioc in atk["iocs_and_detection"]:
lines.append(f" • {ioc}")
lines.append(f"\n{C_YELLOW}{C_BOLD}[4] {t('neutral_impact')}{C_RESET}")
lines.append(f" {impact}")
output_text = "\n".join(lines)
print(output_text)
if export_path:
self._export_dossier(export_path, atk, output_text)
return atk
def render_compare(self, q1: str, q2: str) -> Optional[Dict[str, Any]]:
comp = self.codex.compare_attacks(q1, q2)
t = self.i18n.t
if not comp:
print(f"{C_RED}[!] {t('not_found')}: '{q1}' vs '{q2}'{C_RESET}")
return None
a1, a2 = comp["attack_1"], comp["attack_2"]
print(f"\n{C_CYAN}{C_BOLD}[+] {t('compare_header')}{C_RESET}")
print("=" * 90)
print(f" {C_BOLD}{'DIMENSION':<22} | {a1['id'].upper():<30} | {a2['id'].upper():<30}{C_RESET}")
print("-" * 90)
print(f" {'Full Name':<22} | {a1['name'][:30]:<30} | {a2['name'][:30]:<30}")
print(f" {'Year':<22} | {a1['year'][:30]:<30} | {a2['year'][:30]:<30}")
print(f" {'Category':<22} | {a1['category'][:30]:<30} | {a2['category'][:30]:<30}")
print(f" {'CVE Count':<22} | {str(len(a1['cves'])) + ' CVEs':<30} | {str(len(a2['cves'])) + ' CVEs':<30}")
print(f" {'MITRE TTPs':<22} | {', '.join(a1['mitre_ttps'][:3]):<30} | {', '.join(a2['mitre_ttps'][:3]):<30}")
print("-" * 90)
print(f" {C_YELLOW}Shared MITRE TTPs:{C_RESET} {', '.join(comp['shared_mitre_ttps']) or 'None (Distinct Operational Tradecraft)'}")
print(f" {C_YELLOW}Shared CVEs:{C_RESET} {', '.join(comp['shared_cves']) or 'None'}")
return comp
def render_apt(self, query: str) -> Optional[Dict[str, Any]]:
apt = self.codex.get_apt(query)
t = self.i18n.t
if not apt:
print(f"{C_RED}[!] {t('not_found')}: '{query}'{C_RESET}")
return None
prof = self.i18n.pick_localized_field(apt, "profile")
print(f"\n{C_CYAN}{C_BOLD}[+] {t('apt_header')}{C_RESET}")
print("=" * 90)
print(f" {C_BOLD}Actor Designation:{C_RESET} {C_RED}{C_BOLD}{apt['name']}{C_RESET}")
print(f" {C_BOLD}Origin Attribution:{C_RESET} {apt['origin_attribution']}")
print(f" {C_BOLD}Active Since:{C_RESET} {apt['active_since']}")
print(f" {C_BOLD}Primary Targets:{C_RESET} {apt['primary_targets']}")
print(f" {C_BOLD}Signature Tooling:{C_RESET} {', '.join(apt['signature_tools'])}")
print(f" {C_BOLD}{t('mitre_ttps')}:{C_RESET} {', '.join(apt['mitre_ttps'])}")
print(f"\n{C_YELLOW}{C_BOLD}[•] Operational Assessment:{C_RESET}\n {prof}")
return apt
def render_ransomware_live(self) -> List[Dict[str, str]]:
self.updater.ensure_fresh(force=False)
items = self.updater.get_recent_ransomware(limit=12)
t = self.i18n.t
print(f"\n{C_CYAN}{C_BOLD}[+] {t('ransom_header')} (Last Sync: {self.updater.state.get('last_sync_iso')}){C_RESET}")
print("-" * 90)
print(f" {C_BOLD}{'DISCOVERED DATE':<21} | {'RANSOMWARE GROUP':<18} | {'REPORTED VICTIM / ENTITY'}{C_RESET}")
print("-" * 90)
for row in items:
print(f" {row.get('discovered', '')[:19]:<21} | {C_RED}{row.get('group_name', ''):<18}{C_RESET} | {row.get('post_title', '')}")
return items
def render_dict(self, query: str) -> Optional[Dict[str, Any]]:
entry = self.lexicon.lookup(query)
t = self.i18n.t
if not entry:
print(f"{C_RED}[!] {t('not_found')}: '{query}'{C_RESET}")
return None
defn = self.i18n.pick_localized_field(entry, "definition")
red = self.i18n.pick_localized_field(entry, "osint_red")
blue = self.i18n.pick_localized_field(entry, "blue_dfir")
print(f"\n{C_CYAN}{C_BOLD}[+] {t('dict_header')}{C_RESET}")
print("=" * 90)
print(f" {C_BOLD}Term:{C_RESET} {C_GREEN}{C_BOLD}{entry['term']}{C_RESET}")
print(f" {C_BOLD}Category:{C_RESET} {entry['category']} | {C_BOLD}MITRE:{C_RESET} {entry['mitre_id']}")
print(f"\n{C_YELLOW}{C_BOLD}[1] {t('definition')}{C_RESET}\n {defn}")
print(f"\n{C_RED}{C_BOLD}[2] {t('osint_red')}{C_RESET}\n {red}")
print(f"\n{C_GREEN}{C_BOLD}[3] {t('blue_dfir')}{C_RESET}\n {blue}")
return entry
def render_dorks(self, target: str) -> Dict[str, List[str]]:
t = self.i18n.t
bundles = self.dorker.generate_for_target(target)
print(f"\n{C_CYAN}{C_BOLD}[+] {t('dork_header')} -> {target}{C_RESET}")
print("=" * 90)
for section, queries in bundles.items():
print(f"\n{C_YELLOW}{C_BOLD}[•] {section.upper().replace('_', ' ')}{C_RESET}")
for q in queries:
print(f" {q}")
return bundles
def render_update(self) -> Dict[str, Any]:
t = self.i18n.t
print(f"\n{C_CYAN}{C_BOLD}[*] {t('update_header')}...{C_RESET}")
stats = self.updater.sync_now()
print(f"{C_GREEN}{C_BOLD}[✓] {t('sync_complete')}{C_RESET}")
print(f" • Timestamp: {stats['last_sync_iso']}")
print(f" • CISA KEV Catalog Indexed: {stats['kev_count']} actively exploited CVEs")
print(f" • abuse.ch Feodo C2 Tracked: {stats['feodo_count']} active botnet C2 IPs")
print(f" • Official Tor Exit Nodes: {stats['tor_count']} active Tor exit nodes")
print(f" • Live Ransomware Telemetry: {stats['ransomware_count']} recent global incidents")
print(f" • MITRE ATT&CK Core Matrix: {stats['mitre_count']} indexed enterprise techniques")
return stats
def render_list(self) -> None:
print(f"\n{C_CYAN}{C_BOLD}=== [1] CYBER WARFARE & INCIDENT CODEX (`attack <id>`) ==={C_RESET}")
for a in self.codex.list_all_attacks():
print(f" • {C_GREEN}{a['id']:<18}{C_RESET} -> {a['name']} ({a['year']})")
print(f"\n{C_CYAN}{C_BOLD}=== [2] APT THREAT ACTOR PROFILES (`apt <id>`) ==={C_RESET}")
for ap in self.codex.list_all_apts():
print(f" • {C_RED}{ap['id']:<20}{C_RESET} -> {ap['name']}")
print(f"\n{C_CYAN}{C_BOLD}=== [3] CYBERSECURITY, OSINT & LOLBAS LEXICON (`dict <id>`) ==={C_RESET}")
for lx in self.lexicon.list_all():
print(f" • {C_YELLOW}{lx['id']:<18}{C_RESET} -> {lx['term']} [{lx['category']}]")
print(f"\n{C_CYAN}{C_BOLD}=== [4] MITRE ATT&CK ENTERPRISE TECHNIQUES (`mitre <id>`) ==={C_RESET}")
for m in MITRE_ATTACK_DB.values():
print(f" • {C_MAGENTA}{m['id']:<18}{C_RESET} -> {m['name']} [{m['tactic']}]")
def render_search(self, keyword: str) -> None:
kw = keyword.lower().strip()
print(f"\n{C_CYAN}{C_BOLD}[+] Search Results for '{keyword}':{C_RESET}")
hits = 0
for a in self.codex.list_all_attacks():
if kw in json.dumps(a, ensure_ascii=False).lower():
print(f" [ATTACK] {C_GREEN}{a['id']:<18}{C_RESET} -> {a['name']}")
hits += 1
for ap in self.codex.list_all_apts():
if kw in json.dumps(ap, ensure_ascii=False).lower():
print(f" [APT] {C_RED}{ap['id']:<18}{C_RESET} -> {ap['name']}")
hits += 1
for lx in self.lexicon.search(kw):
print(f" [LEXICON] {C_YELLOW}{lx['id']:<18}{C_RESET} -> {lx['term']}")
hits += 1
for m in self.updater.search_mitre(kw):
print(f" [MITRE] {C_MAGENTA}{m['id']:<18}{C_RESET} -> {m['name']}")
hits += 1
if hits == 0:
print(f" {C_DIM}{self.i18n.t('not_found')}{C_RESET}")
def _export_dossier(self, path: str, structured: Dict[str, Any], formatted_text: str) -> None:
clean_ansi = formatted_text
for code in (C_RESET, C_BOLD, C_CYAN, C_GREEN, C_YELLOW, C_RED, C_MAGENTA, C_DIM):
clean_ansi = clean_ansi.replace(code, "")
if path.lower().endswith(".json"):
with open(path, "w", encoding="utf-8") as f:
json.dump(structured, f, ensure_ascii=False, indent=2)
else:
with open(path, "w", encoding="utf-8") as f:
f.write("# CyberCodex Intelligence Dossier\n\n```text\n" + clean_ansi.strip() + "\n```\n")
print(f"\n{C_GREEN}[✓] {self.i18n.t('exported_to')}: {path}{C_RESET}")
def render_image(self, target: str, export_path: Optional[str] = None) -> None:
from core.image_osint import analyze_image_osint
print(f"\n{C_CYAN}{C_BOLD}[~] PixelTrace Image OSINT & Binary EXIF/GPS/Stego Engine -> {target}{C_RESET}")
try:
rep = analyze_image_osint(target)
except Exception as exc:
print(f"{C_RED}[!] Image OSINT Error: {exc}{C_RESET}")
return
lines: List[str] = []
lines.append(f"\n{C_CYAN}{C_BOLD}╔══════════════════════════════════════════════════════════════════════════════╗{C_RESET}")
lines.append(f"{C_CYAN}{C_BOLD}║ 🖼️ CYBERCODEX PIXELTRACE : DEEP IMAGE OSINT & FORENSICS DOSSIER ║{C_RESET}")
lines.append(f"{C_CYAN}{C_BOLD}╚══════════════════════════════════════════════════════════════════════════════╝{C_RESET}")
lines.append(f" • {C_BOLD}Target Source:{C_RESET} {rep['source']}")
lines.append(f" • {C_BOLD}Container Format:{C_RESET} {C_GREEN}{rep['format']}{C_RESET} ({rep['format_description']})")
lines.append(f" • {C_BOLD}Dimensions:{C_RESET} {rep['dimensions']} | Size: {rep['size_bytes']:,} bytes")
lines.append(f" • {C_BOLD}Shannon Entropy:{C_RESET} {rep['shannon_entropy']} / 8.00")
lines.append(f" • {C_BOLD}MD5 Checksum:{C_RESET} {rep['md5']}")
lines.append(f" • {C_BOLD}SHA-256 Checksum:{C_RESET} {rep['sha256']}")
if rep["stego_eof_alert"]:
st = rep["stego_eof_alert"]
lines.append(f"\n{C_RED}{C_BOLD} [!] CRITICAL STEGANOGRAPHY / POLYGLOT EOF PAYLOAD DETECTED!{C_RESET}")
lines.append(f" Hidden Bytes After Image End: {C_RED}{st['hidden_bytes']:,} bytes{C_RESET} @ offset {st['offset']}")
lines.append(f" ASCII Preview: {C_YELLOW}{st['preview']}{C_RESET}")
else:
lines.append(f"\n {C_GREEN}[✓] EOF Steganography Check:{C_RESET} Clean (Zero extra bytes appended after image marker)")
if rep["gps_resolved"]:
g = rep["gps_resolved"]
lines.append(f"\n{C_RED}{C_BOLD} [📍] EXACT GEOLOCATION (EXIF GPS + OPENSTREETMAP REVERSE GEOCODING):{C_RESET}")
lines.append(f" • Coordinates: {C_YELLOW}{g['latitude']}, {g['longitude']}{C_RESET} (Altitude: {g['altitude']})")
lines.append(f" • Street Address: {C_GREEN}{g['street_address']}{C_RESET}")
lines.append(f" • Google Maps: {C_CYAN}{g['google_maps']}{C_RESET}")
lines.append(f" • OpenStreetMap: {C_CYAN}{g['openstreetmap']}{C_RESET}")
else:
lines.append(f"\n {C_DIM}[i] Geolocation (GPS IFD): No embedded GPS coordinates found in image.{C_RESET}")
if rep["exif"]:
lines.append(f"\n{C_CYAN}{C_BOLD} [📷] CAMERA & EXIF BINARY METADATA (TIFF IFD0 / ExifIFD):{C_RESET}")
for k, v in rep["exif"].items():
lines.append(f" • {k:<22}: {C_YELLOW}{v}{C_RESET}")
if rep["text_chunks"]:
lines.append(f"\n{C_CYAN}{C_BOLD} [🧬] EMBEDDED PNG/JPEG TEXT CHUNKS & AI PROMPTS:{C_RESET}")
for k, v in rep["text_chunks"].items():
lines.append(f" • {k:<22}: {v[:240]}")
if rep["ai_and_software_markers"]:
lines.append(f"\n{C_MAGENTA}{C_BOLD} [🤖] AI GENERATION / EDITING PROVENANCE SIGNATURES:{C_RESET}")
lines.append(f" • Detected Markers: {', '.join(rep['ai_and_software_markers'])}")
if rep["carved_urls"] or rep["carved_emails"]:
lines.append(f"\n{C_YELLOW}{C_BOLD} [🔍] CARVED OSINT INDICATORS (URLS / EMAILS IN BINARY STREAM):{C_RESET}")
for u in rep["carved_urls"][:10]:
lines.append(f" • [URL] {u}")
for em in rep["carved_emails"][:10]:
lines.append(f" • [EMAIL] {em}")
out_text = "\n".join(lines)
print(out_text)
if export_path:
self._export_dossier(export_path, rep, out_text)
class CyberCodexShell(cmd.Cmd):
"""
Interactive Metasploit-style REPL shell (`codex [TR] >`) for CMD / PowerShell.
"""
def __init__(self, app: CyberCodexApp):
super().__init__()
self.app = app
self._update_prompt()
def _update_prompt(self) -> None:
self.prompt = f"\n{C_CYAN}{C_BOLD}codex [{self.app.i18n.lang.upper()}] > {C_RESET}"
def preloop(self) -> None:
self.app.print_banner()
print(f" Type {C_GREEN}help{C_RESET} or {C_GREEN}list{C_RESET} to view commands. Type {C_GREEN}lang <tr|en|de|ja|...>{C_RESET} to switch language.")
def do_intel(self, arg: str) -> None:
"""intel <ip_or_domain> : Run 21-source zero-cost OSINT, Breach/Leak & Threat Intel scan"""
if not arg.strip():
print("Usage: intel <ip_or_domain>")
return
self.app.render_intel(arg.strip())
def do_image(self, arg: str) -> None:
"""image <file_or_url> : Extract EXIF, GPS Street Address, AI Provenance & Stego payloads from an image"""
if not arg.strip():
print("Usage: image <path_to_image_or_url>")
return
self.app.render_image(arg.strip())
def do_leak(self, arg: str) -> None:
"""leak <domain_or_email> : Analyze latest leak date, largest breach, DataClasses & Infostealers"""
if not arg.strip():
print("Usage: leak <linkedin.com | adobe.com | user@domain.com>")
return
self.app.render_leak(arg.strip())
def do_cve(self, arg: str) -> None:
"""cve <CVE-ID> : Analyze CVE via MITRE, FIRST EPSS, CISA KEV & GitHub PoCs"""
if not arg.strip():
print("Usage: cve CVE-2024-3094")
return
self.app.render_cve(arg.strip())
def do_ioc(self, arg: str) -> None:
"""ioc <hash_or_ip_or_domain> : Malware SHA256/MD5 hash & C2 lookup via ThreatFox & Codex"""
if not arg.strip():
print("Usage: ioc <sha256_or_md5_or_domain>")
return
self.app.render_ioc(arg.strip())
def do_mitre(self, arg: str) -> None:
"""mitre <Txxxx_or_keyword> : Lookup official MITRE ATT&CK technique & detection"""
if not arg.strip():
print("Usage: mitre T1195.002")
return
self.app.render_mitre(arg.strip())
def do_attack(self, arg: str) -> None:
"""attack <name_or_id> : View unbiased anatomy of a major cyber attack"""
if not arg.strip():
print("Usage: attack <stuxnet|solarwinds|notpetya|wannacry|log4shell|xz-backdoor|volt-typhoon|...>")
return
self.app.render_attack(arg.strip())
def do_compare(self, arg: str) -> None:
"""compare <attack1> <attack2> : Side-by-side comparison of two cyber operations"""
parts = shlex.split(arg)
if len(parts) < 2:
print("Usage: compare stuxnet notpetya")
return
self.app.render_compare(parts[0], parts[1])
def do_apt(self, arg: str) -> None:
"""apt <group_name> : View APT threat actor intelligence dossier"""
if not arg.strip():
print("Usage: apt <lazarus|apt29|sandworm|equation-group|volt-typhoon-apt|scattered-spider-apt>")
return
self.app.render_apt(arg.strip())
def do_ransom(self, arg: str) -> None:
"""ransom : View live global ransomware attacks feed"""
self.app.render_ransomware_live()
def do_dict(self, arg: str) -> None:
"""dict <term> : Lookup technical OSINT, DFIR, Red/Blue Team or LOLBAS concept"""
if not arg.strip():
print("Usage: dict <jarm|kerberoasting|pass-the-hash|process-hollowing|catroot-winsxs|byovd|...>")
return
self.app.render_dict(arg.strip())
def do_dork(self, arg: str) -> None:
"""dork <domain_or_ioc> : Generate OSINT dorks and Wazuh/Sigma/KQL SIEM queries"""
if not arg.strip():
print("Usage: dork example.com")
return
self.app.render_dorks(arg.strip())
def do_search(self, arg: str) -> None:
"""search <keyword> : Search across all attacks, APTs, MITRE, and lexicon terms"""
if not arg.strip():
print("Usage: search smb")
return
self.app.render_search(arg.strip())
def do_list(self, arg: str) -> None:
"""list : List all indexed cyber attacks, APT groups, MITRE, and lexicon entries"""
self.app.render_list()
def do_update(self, arg: str) -> None:
"""update : Force live synchronization with CISA KEV, Feodo C2, Tor & Ransomware feeds"""
self.app.render_update()
def do_lang(self, arg: str) -> None:
"""lang <code> : Switch interface language (tr, en, zh, es, hi, ar, pt, ru, ja, de, fr)"""
code = arg.strip().lower()
if self.app.i18n.set_language(code):
self._update_prompt()
print(f"{C_GREEN}[✓] {self.app.i18n.t('lang_changed')}: {SUPPORTED_LANGUAGES[code]}{C_RESET}")
else:
print(f"Supported languages: {', '.join(SUPPORTED_LANGUAGES.keys())}")
def do_exit(self, arg: str) -> bool:
"""exit : Exit CyberCodex shell"""
return True
def do_quit(self, arg: str) -> bool:
"""quit : Exit CyberCodex shell"""
return True
def build_parser() -> argparse.ArgumentParser:
common = argparse.ArgumentParser(add_help=False)
common.add_argument(
"--lang",
default="tr",
choices=list(SUPPORTED_LANGUAGES.keys()),
help="Interface & report language (tr, en, zh, es, hi, ar, pt, ru, ja, de, fr)",
)
common.add_argument(
"--translate-live",
action="store_true",
help="Dynamically translate narrative body into selected language via zero-cost neural endpoint",
)
common.add_argument(
"--export",
default=None,
help="Export output dossier to .md or .json file",
)
parser = argparse.ArgumentParser(
prog="cybercodex",
parents=[common],
description="CyberCodex: Autonomous 22-Source Zero-Cost OSINT, Image Forensics, Data Breach/Leak & Cyber Warfare Codex",
)
sub = parser.add_subparsers(dest="command")
p_intel = sub.add_parser("intel", parents=[common], help="22-Source Zero-Cost parallel OSINT, Breach/Leak & Threat Intel scan")
p_intel.add_argument("target", help="Target IPv4 address or domain name")
p_img = sub.add_parser("image", parents=[common], help="Deep Image OSINT: Binary EXIF, GPS Reverse-Geocoding, AI Provenance & Stego EOF Hunter")
p_img.add_argument("target", help="Local image file path (.jpg, .png, .webp, .tiff) or direct image URL")
p_leak = sub.add_parser("leak", parents=[common], help="Deep-dive Data Breach History (Latest Leak, Largest Leak, DataClasses, Infostealers, COMB & K-Anonymity)")
p_leak.add_argument("query", help="Target website domain (e.g., linkedin.com), email, user:name, or pass:secret")
p_leak.add_argument("--password", action="store_true", help="Check a password via HIBP K-Anonymity (only 5 SHA-1 chars sent)")
p_leak.add_argument("--download", action="store_true", help="Download harvested leak bundle (.txt, .csv, .json, .md) to exports/ folder")
p_cve = sub.add_parser("cve", parents=[common], help="Live CVE analysis (MITRE + FIRST EPSS + CISA KEV + GitHub PoC/Exploits)")
p_cve.add_argument("cve_id", help="CVE identifier (e.g., CVE-2024-3094)")
p_ioc = sub.add_parser("ioc", parents=[common], help="Malware SHA256/MD5 hash & IOC intelligence (ThreatFox / Codex / Feodo)")
p_ioc.add_argument("indicator", help="SHA256/MD5/SHA1 file hash, domain, or IP")
p_mitre = sub.add_parser("mitre", parents=[common], help="Official MITRE ATT&CK technique & SOC detection lookup")
p_mitre.add_argument("query", help="MITRE Technique ID or keyword (e.g., T1195.002, T1055.012, LSASS)")
p_atk = sub.add_parser("attack", parents=[common], help="Unbiased technical anatomy of a historical/modern cyber operation")
p_atk.add_argument("name", help="Attack ID or name (e.g., stuxnet, solarwinds, notpetya, xz-backdoor)")
p_cmp = sub.add_parser("compare", parents=[common], help="Side-by-side comparison matrix of two cyber attacks")
p_cmp.add_argument("attack1", help="First attack ID")
p_cmp.add_argument("attack2", help="Second attack ID")
p_apt = sub.add_parser("apt", parents=[common], help="APT Threat Actor intelligence profile")
p_apt.add_argument("group", help="APT group ID or alias (e.g., lazarus, apt29, sandworm, equation-group)")
sub.add_parser("ransom", parents=[common], help="Live global ransomware victims & active group telemetry")
p_dict = sub.add_parser("dict", parents=[common], help="Dual-perspective Cybersecurity, OSINT, DFIR & LOLBAS lexicon")
p_dict.add_argument("term", help="Term ID or keyword (e.g., jarm, kerberoasting, catroot-winsxs, byovd)")
p_dork = sub.add_parser("dork", parents=[common], help="Automated OSINT dorks & Wazuh/Sigma/KQL/Splunk SIEM queries")
p_dork.add_argument("target", help="Target domain, IP, or indicator")
p_search = sub.add_parser("search", parents=[common], help="Fuzzy search across all attacks, APTs, MITRE, and lexicon terms")
p_search.add_argument("keyword", help="Search keyword")
sub.add_parser("list", parents=[common], help="List all indexed cyber attacks, APTs, MITRE, and lexicon entries")
sub.add_parser("update", parents=[common], help="Force live self-update from CISA KEV, Feodo C2, Tor & Ransomware feeds")
sub.add_parser("shell", parents=[common], help="Launch interactive CyberCodex terminal shell")
return parser