-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainframe.py
More file actions
3227 lines (2756 loc) · 150 KB
/
Copy pathmainframe.py
File metadata and controls
3227 lines (2756 loc) · 150 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
try:
from core.ui import ConsoleUI, get_ui
from core.ui.console import Colors
except Exception:
class Colors:
RED = '\033[91m'
AMBER = '\033[93m'
YELLOW = '\033[93m'
GREEN = '\033[92m'
CYAN = '\033[96m'
RESET = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
MAGENTA = '\033[95m'
WHITE = '\033[97m'
BLUE = '\033[94m'
BRIGHT_CYAN = '\033[96m'
BRIGHT_GREEN = '\033[92m'
BRIGHT_YELLOW = '\033[93m'
BRIGHT_RED = '\033[91m'
BRIGHT_MAGENTA = '\033[95m'
CLEAR_SCREEN = '\033[2J\033[3J\033[H'
ConsoleUI = None
def get_ui():
return None
ui = get_ui() if ConsoleUI else None
CURRENT_VERSION = "2.0.0"
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
DDoSAttack = None
BruteForceAttack = None
ImageLogger = None
BeastSettings = None
IMPORTS_OK = False
get_lang = None
logo_main = None
menu_ru = None
menu_en = None
logo_ddos = None
logo_bruteforce = None
try:
from core.etc.settings import Settings as BeastSettings
from core.etc.functions import get_lang, logo_main, menu_ru, menu_en, \
logo_ddos, logo_bruteforce
try:
from colorama import init, Fore, Style, Back
init()
except ImportError:
pass
IMPORTS_OK = True
except Exception as e:
print(f"{Colors.RED}[!] Warning: Could not load Beast Bomber UI modules. Check 'core' folder structure.{e}{Colors.RESET}")
try:
from core.ddos_attack.ddos import DDoSAttack
except Exception:
pass
try:
from core.brute_force.bruteforce import BruteForceAttack
except Exception:
pass
try:
from core.image_logger.imagelogger import ImageLogger
except Exception:
pass
try:
from core.ui_theme import (DIR_THEME_STYLES, load_theme, save_theme,
handle_customize, show_theme, render_directory_ui)
_CURRENT_THEME = load_theme()
except Exception:
_CURRENT_THEME = "1"
DIR_THEME_STYLES = {}
load_theme = save_theme = handle_customize = show_theme = render_directory_ui = None
ddos_attack = DDoSAttack() if DDoSAttack else None
bruteforce_attack = BruteForceAttack() if BruteForceAttack else None
image_logger_instance = ImageLogger() if ImageLogger else None
import os
import sys
import time
import random
import base64
import json
import socket
import struct
import subprocess
import shutil
import ctypes
import threading
import _thread
try:
import msvcrt
except ImportError:
msvcrt = None
import hashlib
import platform
import re
import math
import webbrowser
from concurrent.futures import ThreadPoolExecutor
import urllib.request
import urllib.error
import urllib.parse
try:
import psutil
except Exception:
psutil = None
try:
import requests as _requests
except Exception:
_requests = None
from getpass import getpass
if sys.platform.startswith('win'):
try:
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
except Exception:
os.system('')
if ConsoleUI is not None:
from rich.table import Table
from rich.box import ROUNDED, DOUBLE
from rich.text import Text as RichText
else:
Table = None
ROUNDED = None
DOUBLE = None
RichText = None
class DualStreamWriter:
def __init__(self, original_stdout, log_file_handle):
self.terminal = original_stdout
self.log_file = log_file_handle
self.ansi_regex = re.compile(r'\033\[[0-9;]*[a-zA-Z]')
self.write_lock = threading.Lock()
self.excluded_ips = self._load_excluded_ips()
def _load_excluded_ips(self):
excluded = set()
try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
local_ip = s.getsockname()[0]
s.close()
if local_ip and local_ip != '127.0.0.1':
excluded.add(local_ip)
except Exception:
pass
try:
config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'core', 'input', 'excluded_ips.txt')
if os.path.exists(config_path):
with open(config_path, 'r', encoding='utf-8', errors='ignore') as f:
for line in f:
ip = line.strip()
if ip and not ip.startswith('#'):
excluded.add(ip)
except Exception:
pass
return excluded
def _scrub_ips(self, text):
if not self.excluded_ips:
return text
scrubbed = text
for ip in self.excluded_ips:
if ip in scrubbed:
scrubbed = scrubbed.replace(ip, '[REDACTED]')
return scrubbed
def write(self, message):
with self.write_lock:
self.terminal.write(message)
purified_message = self.ansi_regex.sub('', message)
scrubbed_message = self._scrub_ips(purified_message)
self.log_file.write(scrubbed_message)
self.log_file.flush()
def flush(self):
with self.write_lock:
self.terminal.flush()
self.log_file.flush()
def _render_directory_menu(title, items, header_color="cyan", dir_id="01"):
if render_directory_ui is not None:
render_directory_ui(_CURRENT_THEME, dir_id, items)
return
style = DIR_THEME_STYLES.get(_CURRENT_THEME, DIR_THEME_STYLES.get("1", {}))
if style.get("plain"):
print(f" [{title}]")
print()
if not items:
return
maxw = max(len(item[1]) for item in items)
for item in items:
raw_key = item[0]
key = f"{int(raw_key):02d}" if str(raw_key).isdigit() else str(raw_key)
name = item[1]
desc = item[2] if len(item) > 2 else ""
print(f" [{key}] {name.ljust(maxw)} - {desc}")
return
tcolor = style.get("color", header_color)
tmarker = style.get("marker", "")
print(f"{tcolor} [{title}]{Colors.RESET}")
print()
if not items:
return
maxw = max(len(item[1]) for item in items)
for item in items:
raw_key = item[0]
key = f"{int(raw_key):02d}" if str(raw_key).isdigit() else str(raw_key)
name = item[1]
desc = item[2] if len(item) > 2 else ""
print(f"{tcolor} {tmarker} [{key}] {name.ljust(maxw)} - {desc}{Colors.RESET}")
class MainframeUI:
@staticmethod
def draw_banner():
if ui is not None:
ui.banner()
else:
skull_ascii = r"""
______
.-" "-.
/ \
| |
|,. .-. .-. ,|
| )(__/ \__)( |
|/ /\ \|
(_ ^^ _)
\__|IIIIII|__/
| \IIIIII/ |
\ /
`--------`"""
print(f"{Colors.CYAN}{skull_ascii}{Colors.RESET}")
print(f"{Colors.BOLD}{Colors.GREEN}" + "=" * 80)
print(" MAINFRAME COMPREHENSIVE SECURITY RECONNAISSANCE ENGINE // MULTI-CORE")
print(" DEPLOYMENT SPECIFICATION RELEASE v5.90 // COMPLETE 40-IN-1 TOOL PLATFORM")
print("=" * 80 + f"{Colors.RESET}\n")
@staticmethod
def display_main_menu():
if ui is not None:
ui.main_menu()
return
print(f"{Colors.BOLD}{Colors.GREEN}[MAIN SYSTEM DIRECTORY CORE]{Colors.RESET}\n")
print(f" [{Colors.AMBER}1{Colors.RESET}] Sub-Directory 01 // Network Infrastructure & Endpoint Recon Cores")
print(f" [{Colors.CYAN}2{Colors.RESET}] Sub-Directory 02 // External OSINT & Target Record Profilers")
print(f" [{Colors.GREEN}3{Colors.RESET}] Sub-Directory 03 // Local Data Traffic Monitors, Audits & Utilities")
print(f" [{Colors.CYAN}4{Colors.RESET}] Sub-Directory 04 // Advanced Infrastructure Audits & Integrity Cores")
print(f" [{Colors.RED}5{Colors.RESET}] Sub-Directory 05 // Attack Vectors & Exploit Frameworks [SHELL BASELINE]")
print("\n" + f"{Colors.RED}[SYSTEM SHUTDOWN CONTROL]{Colors.RESET}")
print(f" [{Colors.RED}6{Colors.RESET}] Terminate Active Mainframe Operator Control Session")
print(f"\n{Colors.BOLD}{Colors.GREEN}" + "-" * 80 + f"{Colors.RESET}")
@staticmethod
def display_network_menu():
_render_directory_menu(
"SUB-DIRECTORY 01 // NETWORK INFRASTRUCTURE & ENDPOINT RECON",
[
("1", "Rainbow Echo Pinger", "ICMP latency & reachability monitor", "cyan"),
("2", "Reverse DNS Resolver", "IP-to-host PTR resolution", "cyan"),
("3", "Port Scanner", "Multi-threaded port & service profiler", "cyan"),
("4", "Ping Sweeper", "Local subnet parallel host discovery", "cyan"),
("5", "Banner Grabber", "Remote service banner extractor", "cyan"),
("6", "Subdomain Finder", "Passive subdomain discovery via crt.sh logs", "cyan"),
("7", "RDAP Lookup", "WHOIS registration & allocation mapper", "cyan"),
("8", "HTTP Header Auditor", "Security header compliance & hardening", "cyan"),
("9", "DoH Resolver", "DNS-over-HTTPS client resolver", "cyan"),
("10", "IP Lookup", "IP geolocation & metadata reconnaissance", "cyan"),
("11", "Return to Main Directory", "Exit directory and reload the system core", "cyan"),
],
"cyan",
"01",
)
@staticmethod
def display_osint_menu():
_render_directory_menu(
"SUB-DIRECTORY 02 // EXTERNAL OSINT & TARGET PROFILE MANAGEMENT",
[
("1", "Sherlock", "Username tracer across social platforms", "blue"),
("2", "PhoneInfoga", "Telecom & phone-number intelligence scanner", "blue"),
("3", "Holehe", "Breach-email auditor across providers", "blue"),
("4", "Socialscan", "Identity & account existence profiler", "blue"),
("5", "Breach Checker", "Live data breach & password-leak checker", "blue"),
("6", "Tor Exit Validator", "Tor exit-node legitimacy checker", "blue"),
("7", "Homograph Analyzer", "IDN homograph & punycode spoof detector", "blue"),
("8", "Return to Main Directory", "Exit directory and reload the system core", "blue"),
],
"cyan",
"02",
)
@staticmethod
def display_utilities_menu():
_render_directory_menu(
"SUB-DIRECTORY 03 // LOCAL DATA TRAFFIC, SECURITY AUDITS & UTILITIES",
[
("1", "Traffic Monitor", "Inbound packet sniffer & capture engine", "green"),
("2", "Secret Scanner", "Source-code secret & key leak scanner", "green"),
("3", "Hash Matrix", "Cryptographic hash signatures & token analyzer", "green"),
("4", "System Profiler", "Local host OS telemetry profiler", "green"),
("5", "Base64 Matrix", "Encode/decode data-transformation matrix", "green"),
("6", "Return to Main Directory", "Exit directory and reload the system core", "green"),
],
"green",
"03",
)
@staticmethod
def display_advanced_audits_menu():
_render_directory_menu(
"SUB-DIRECTORY 04 // ADVANCED INFRASTRUCTURE AUDITS & INTEGRITY",
[
("1", "File Integrity Monitor", "FIMS directory snapshot tracker", "magenta"),
("2", "SSL/TLS Auditor", "Cert expiry & cipher-suite auditor", "magenta"),
("3", "Connection Profiler", "Active listening-port & connection profiler", "magenta"),
("4", "Password Auditor", "Entropy & complexity compliance matrix", "magenta"),
("5", "ARP Profiler", "ARP table cache & duplicate-MAC auditor", "magenta"),
("6", "CIDR Calculator", "IPv4 subnet range & mask calculator", "magenta"),
("7", "UPnP Discovery", "SSDP smart-device explorer", "magenta"),
("8", "DNS Spoof Auditor", "Hosts-file poisoning & cache audit", "magenta"),
("9", "MAC Vendor Lookup", "OUI manufacturer vendor directory", "magenta"),
("10", "Return to Main Directory", "Exit directory and reload the system core", "magenta"),
],
"magenta",
"04",
)
@staticmethod
def display_attack_menu():
_render_directory_menu(
"SUB-DIRECTORY 05 // ATTACK VECTORS, EXPLOIT FRAMEWORKS & DEFENSIVE AUDITING",
[
("1", "Beast Mode (DDoS)", "Distributed denial-of-service launcher", "red"),
("2", "Image Logger", "Malicious-image payload logger", "red"),
("3", "Brute Force", "Credential brute-force engine", "red"),
("4", "Metasploit Console", "msfconsole exploit-framework interface", "red"),
("5", "Msfvenom Egress", "Payload generation & network-egress tester", "red"),
("6", "Hashcat Auditor", "GPU password-strength compliance auditor", "red"),
("7", "Impacket Remoting", "psexec.py / wmiexec.py admin suite", "red"),
("8", "Log Diagnostic", "Real-time security-log diagnostic module", "red"),
("9", "Nmap Scanner", "Advanced port & service profiler", "red"),
("10", "Return to Main Directory", "Exit directory and reload the system core", "red"),
],
"red",
"05",
)
def find_global_command(command_name):
cmd_path = shutil.which(command_name)
if cmd_path:
return cmd_path
try:
home_dir = os.path.expanduser('~')
pipx_bin_dir = os.path.join(home_dir, '.local', 'bin')
fallback_path = shutil.which(command_name, path=pipx_bin_dir)
if fallback_path:
return fallback_path
except Exception:
pass
if os.name == 'nt':
try:
local_appdata = os.environ.get('LOCALAPPDATA', '')
if local_appdata:
pipx_local_path = os.path.join(local_appdata, 'pipx', 'shared', 'bin')
fallback_path = shutil.which(command_name, path=pipx_local_path)
if fallback_path:
return fallback_path
except Exception:
pass
try:
import site
if hasattr(site, 'getuserbase'):
user_base = site.getuserbase()
if user_base:
fallback_dir = os.path.join(user_base, 'Scripts' if os.name == 'nt' else 'bin')
fallback_path = shutil.which(command_name, path=fallback_dir)
if fallback_path:
return fallback_path
except Exception:
pass
try:
bindir = os.path.dirname(sys.executable)
fallback_path = shutil.which(command_name, path=bindir)
if fallback_path:
return fallback_path
fallback_path = shutil.which(command_name, path=os.path.join(bindir, 'Scripts'))
if fallback_path:
return fallback_path
except Exception:
pass
try:
script_dir = os.path.dirname(os.path.abspath(__file__))
local_tools_dirs = [
os.path.join(script_dir, 'hashcat-*'),
os.path.join(script_dir, 'core', 'hashcat-*'),
]
import glob
for pattern in local_tools_dirs:
for tool_dir in glob.glob(pattern):
if os.path.isdir(tool_dir):
fallback_path = shutil.which(command_name, path=tool_dir)
if fallback_path:
return fallback_path
except Exception:
pass
if os.name == 'nt':
common_paths = [
os.path.join(os.environ.get('ProgramFiles', 'C:\\Program Files'), 'Metasploit', 'bin'),
os.path.join(os.environ.get('ProgramFiles', 'C:\\Program Files'), 'Metasploit-Framework', 'bin'),
os.path.join(os.environ.get('ProgramFiles(x86)', 'C:\\Program Files (x86)'), 'Metasploit', 'bin'),
os.path.join(os.environ.get('ProgramFiles(x86)', 'C:\\Program Files (x86)'), 'Metasploit-Framework', 'bin'),
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Metasploit', 'bin'),
os.path.join(os.environ.get('LOCALAPPDATA', ''), 'Programs', 'Metasploit-Framework', 'bin'),
r'C:\metasploit-framework\bin',
]
for path in common_paths:
if os.path.isdir(path):
fallback_path = shutil.which(command_name, path=path)
if fallback_path:
return fallback_path
return command_name
def title_scrambler_daemon():
is_windows = sys.platform.startswith('win')
machine_name = platform.node() or "mainframe"
cores_online = os.cpu_count() or 1
matrix_chars = "0123456789ABCDEFLEAKTRACKEDSECX⚡☠️"
base_prefix = f"{machine_name} | CORES ONLINE: {cores_online} | "
while True:
random_hash = "".join(random.choice(matrix_chars) for _ in range(12))
scrambled_title = f"{base_prefix}[{random_hash}]"
if is_windows:
try:
ctypes.windll.kernel32.SetConsoleTitleW(scrambled_title)
except Exception:
pass
else:
try:
sys.stderr.write(f"\x1b]2;{scrambled_title}\x07")
sys.stderr.flush()
except Exception:
pass
time.sleep(0.4)
def run_pinger_engine():
if ui is not None:
ui.clear()
ui.panel(
RichText.from_markup("[bold red]NETWORK STREAM ENGINE DEPLOYED[/bold red]\n[yellow]Continuous ICMP echo latency monitor[/yellow]"),
title="WARNING", border_style="red")
else:
print(f"{Colors.CLEAR_SCREEN}{Colors.RED}[WARNING // NETWORK STREAM ENGINE DEPLOYED]{Colors.RESET}")
target_host = (ui.prompt_input("Enter target IP address [Default: 185.220.101.5]:", "185.220.101.5")
if ui is not None
else input(f"{Colors.BOLD}Enter target IP address routing node [Default: 185.220.101.5]: {Colors.RESET}").strip())
if not target_host:
target_host = "185.220.101.5"
if ui is not None:
ui.info("Spawning native network shell utility. Tap Ctrl+C to interrupt...")
else:
print(f"\n{Colors.CYAN}Spawning native network shell utility. Tap Ctrl+C to trigger interrupt signal...{Colors.RESET}\n")
time.sleep(1)
is_windows = sys.platform.startswith('win')
cmd_args = ['ping', '-n', '1', '-w', '1000', target_host] if is_windows else ['ping', '-c', '1', '-W', '1', target_host]
colors_list = ["red", "yellow", "green", "cyan"]
idx = 0
try:
while True:
start_time = time.time()
process = subprocess.run(cmd_args, capture_output=True, text=True)
duration_ms = int((time.time() - start_time) * 1000)
color_name = colors_list[idx % len(colors_list)]
out = process.stdout.lower()
if process.returncode == 0 and ("ttl=" in out or "time=" in out) and "unreachable" not in out and "timed out" not in out:
latency_str = ""
if "time=" in out:
try:
parts = out.split("time=")[1].split()[0]
parts = ''.join(c for c in parts if c.isdigit() or c == '.')
latency_ms = float(parts)
latency_str = f"{latency_ms}ms"
except Exception:
latency_str = f"~{duration_ms}ms"
else:
latency_str = f"~{duration_ms}ms"
if ui is not None:
from rich.text import Text as _Text
row = _Text()
row.append(" \u25cf ", style=color_name)
row.append(f"{target_host} \u2192 ", style="bold white")
row.append(f"{latency_str}", style=color_name)
row.append(" [OK]", style="green")
ui.console.print(row)
else:
print(f"{Colors.RED}{target_host} ➔ {latency_str} // ECHO_SUCCESS_ACK{Colors.RESET}")
else:
if ui is not None:
ui.error(f"{target_host} \u2192 TIMEOUT / DROPPED FRAME")
else:
print(f"{Colors.RED}{target_host} ➔ TIMEOUT or DROPPED FRAME{Colors.RESET}")
idx += 1
time.sleep(0.4)
except KeyboardInterrupt:
if ui is not None:
ui.warning("Stream stop signal logged. Console cache recovered.")
else:
print(f"\n\n{Colors.AMBER}[STREAM STOP SIGNAL LOGGED // CONSOLE CACHE RECOVERED]{Colors.RESET}")
time.sleep(1.5)
def run_reverse_dns():
if ui is not None:
ui.section("MODULE 02 // REVERSE DNS INFRASTRUCTURE RESOLVER", "cyan",
subtitle="Performs lookups against pointer distribution files to track host allocation layers.")
else:
print(f"\n{Colors.AMBER}[MODULE 02 // REVERSE DNS INFRASTRUCTURE RESOLVER]{Colors.RESET}")
print("Performs lookups against pointer distribution files to track host allocation layers.")
target_ip = (ui.prompt_input("Enter target IP address to query:")
if ui is not None
else input("\nEnter target IP address to query: ").strip())
if not target_ip:
return
if ui is not None:
ui.info("Initiating socket gethostbyaddr handshake sequence...")
else:
print(f"\n{Colors.GREEN}Initiating socket gethostbyaddr handshake sequence...{Colors.RESET}")
time.sleep(0.5)
try:
hostname, alias_list, ip_list = socket.gethostbyaddr(target_ip)
if ui is not None:
ui.result_table("RESOLUTION SUCCESSFUL — PTR DISCOVERED",
["FIELD", "VALUE"],
[
("Hostname", hostname),
("Aliases", ", ".join(alias_list) if alias_list else "N/A"),
("Interfaces", ", ".join(ip_list)),
], border_style="green")
else:
print(f"\n{Colors.GREEN}[✓] RESOLUTION SUCCESSFUL // PTR DISCOVERED{Colors.RESET}")
print("-" * 75)
print(f" ➔ Hostname : {Colors.CYAN}{hostname}{Colors.RESET}")
print(f" ➔ Aliases : {alias_list}")
print(f" ➔ Interfaces : {ip_list}")
except socket.herror:
if ui is not None:
ui.error("Host Resolution Miss: No valid reverse name pointers exist for this location.")
else:
print(f"\n{Colors.RED}[!] Host Resolution Miss: No valid reverse name pointers exist for this location.{Colors.RESET}")
except Exception as err:
if ui is not None:
ui.error(f"Network Mapping Exception Logged: {err}")
else:
print(f"\n{Colors.RED}[!] Network Mapping Exception Logged: {err}{Colors.RESET}")
if ui is not None:
ui.pause("Press Enter to return to menu")
else:
input(f"\nModule matrix complete. Press Enter to pull up directory layout...")
def run_port_scanner():
if ui is not None:
ui.section("MODULE 03 // MULTI-THREADED PORT SCANNER & VULNERABILITY PROFILER", "cyan")
else:
print(f"\n{Colors.AMBER}[MODULE 03 // MULTI-THREADED PORT SCANNER & VULNERABILITY PROFILER]{Colors.RESET}")
target = (ui.prompt_input("Enter target domain or IP node:") if ui is not None else input("Enter target domain identifier or IP node: ").strip())
if not target:
return
if ui is not None:
ui.info("Resolving lookup records against root nameservers...")
else:
print(f"\n{Colors.GREEN}Resolving lookup records against root nameservers...{Colors.RESET}")
try:
target_ip = socket.gethostbyname(target)
if ui is not None:
ui.info(f"Target Identity Bound: {target_ip}")
else:
print(f"Target Identity Bound: {Colors.CYAN}{target_ip}{Colors.RESET}\n")
except Exception as e:
if ui is not None:
ui.error(f"Failed to resolve server destination mapping: {e}")
else:
print(f"{Colors.RED}[!] Failed to resolve server destination mapping: {e}{Colors.RESET}")
input("\nPress Enter to return...")
return
port_hardening_db = {
21: ("FTP", "Plaintext credentials exchange. Audit for anonymous logins or transition to SFTP/FTPS."),
22: ("SSH", "Secure Shell interface. Verify key-based authentication is enforced and root login is deactivated."),
23: ("Telnet", "Highly insecure plaintext stream. Immediate deprecation recommended; transition to SSH."),
25: ("SMTP", "Mail relay protocol. Ensure server is not operating as an open relay to prevent exploitation."),
53: ("DNS", "Domain Name System. Audit against zone transfer exposures (AXFR) and amplification risks."),
80: ("HTTP", "Unencrypted web platform. Enforce absolute TLS encryption redirects over port 443."),
110: ("POP3", "Post Office Protocol. Plaintext credential exchange. Transition immediately to POP3S."),
135: ("RPC Endpoint", "Microsoft RPC Endpoint Mapper. Often probed for environment footprinting. Restrict exposure."),
139: ("NetBIOS", "NetBIOS Session Service. Legacy networking transport protocol. Restrict access at gateway boundary."),
443: ("HTTPS", "Secure Web Socket. Verify modern cryptographic cipher baseline suites (TLS 1.2 / TLS 1.3) are mandatory."),
445: ("SMB", "Microsoft Directory Sharing. Ensure message signing is required to mitigate relay threats."),
1433: ("MSSQL", "Microsoft SQL Database engine server interface. Isolate from public ingress routes."),
3306: ("MySQL", "Open-source SQL engine infrastructure node access point. Restrict to internal localhost paths."),
3389: ("RDP", "Remote Desktop Gateway. Enforce Network Level Authentication (NLA) and route inside a defensive VPN."),
8080: ("HTTP-Alt", "Alternative web application runtime proxy port. Review background system dependencies for patches."),
8443: ("HTTPS-Alt", "Alternative secure server administration access dashboard. Restrict via strict ACL configurations.")
}
if ui is not None:
scan_table = Table(title="PORT SCAN RESULTS", border_style="cyan", header_style="bold cyan", box=ROUNDED)
scan_table.add_column("PORT", style="bold", width=10)
scan_table.add_column("SERVICE", style="cyan", width=18)
scan_table.add_column("STATUS", width=12)
scan_table.add_column("DEFENSIVE PROFILING", ratio=1)
else:
print(f"{Colors.BOLD}{'INTERFACE':<12}{'SERVICE':<16}{'STATUS':<12}{'DEFENSIVE PROFILING ARCHIVE'}{Colors.RESET}")
print("-" * 110)
print_lock = threading.Lock()
def scan_port(port):
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(1.2)
result = s.connect_ex((target_ip, port))
if result == 0:
service_meta = port_hardening_db.get(port, ("unknown", "No supplementary baseline audit records compiled."))
with print_lock:
if ui is not None:
scan_table.add_row(str(port), service_meta[0], "[green]OPEN[/green]", service_meta[1])
else:
print(f"{Colors.GREEN}Port {port:<8}{service_meta[0]:<16}{'OPEN':<12}{Colors.RESET}{Colors.AMBER}{service_meta[1]}{Colors.RESET}")
s.close()
except Exception:
pass
with ThreadPoolExecutor(max_workers=30) as executor:
executor.map(scan_port, sorted(port_hardening_db.keys()))
if ui is not None:
ui.console.print()
ui.console.print(scan_table)
ui.console.print()
else:
print("-" * 110)
if ui is not None:
ui.pause("Press Enter to resume")
else:
input(f"\nScan operations sequence terminated. Press Enter to resume...")
def run_ping_sweeper():
if ui is not None:
ui.section("MODULE 04 // LOCAL SUBNET PARALLEL PING SWEEPER", "cyan")
else:
print(f"\n{Colors.AMBER}[MODULE 04 // LOCAL SUBNET PARALLEL PING SWEEPER]{Colors.RESET}")
try:
local_ip = socket.gethostbyname(socket.gethostname())
default_subnet = ".".join(local_ip.split('.')[:3])
except Exception:
default_subnet = "192.168.1"
subnet = (ui.prompt_input(f"Enter target local subnet prefix [Default: {default_subnet}]:", default_subnet)
if ui is not None
else (input(f"Enter target local subnet prefix [Default: {default_subnet}]: ").strip() or default_subnet))
if ui is not None:
ui.info(f"Initializing thread pools for network scan {subnet}.1 to {subnet}.254...")
else:
print(f"\n{Colors.CYAN}Initializing thread pools for network matrix {subnet}.1 to {subnet}.254...{Colors.RESET}\n")
is_windows = sys.platform.startswith('win')
cmd_base = ['ping', '-n', '1', '-w', '400'] if is_windows else ['ping', '-c', '1', '-W', '1']
if ui is not None:
sweep_table = Table(title="SUBNET SWEEP RESULTS", border_style="cyan", header_style="bold cyan", box=ROUNDED)
sweep_table.add_column("IP ADDRESS", style="bold", width=20)
sweep_table.add_column("METRIC STATUS", style="green", width=25)
else:
print(f"{Colors.BOLD}{'IP ADDRESS':<22}{'METRIC STATUS'}{Colors.RESET}")
print("-" * 45)
print_lock = threading.Lock()
def check_host(i):
ip = f"{subnet}.{i}"
try:
if subprocess.run(cmd_base + [ip], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0:
with print_lock:
if ui is not None:
sweep_table.add_row(ip, "[green]RESPONSIVE DEVICE ONLINE[/green]")
else:
print(f"{Colors.GREEN}{ip:<22}[ RESPONSIVE DEVICE ONLINE ]{Colors.RESET}")
except Exception:
pass
with ThreadPoolExecutor(max_workers=35) as executor:
executor.map(check_host, range(1, 255))
if ui is not None:
ui.console.print()
ui.console.print(sweep_table)
ui.console.print()
else:
print("-" * 45)
if ui is not None:
ui.pause("Press Enter to exit subsystem")
else:
input(f"\nSweep operation complete. Press Enter to exit subsystem layer...")
def run_banner_grabber():
if ui is not None:
ui.section("MODULE 05 // NETWORK SERVICE BANNER GRABBER AUDITOR", "cyan")
else:
print(f"\n{Colors.AMBER}[MODULE 05 // NETWORK SERVICE BANNER GRABBER AUDITOR]{Colors.RESET}")
target = (ui.prompt_input("Enter target server domain or address block:") if ui is not None else input("Enter target server domain or address block: ").strip())
if not target:
return
port_input = (ui.prompt_input("Enter operational application port (e.g., 21, 22, 80):") if ui is not None else input("Enter operational application port (e.g., 21, 22, 80): ").strip())
try:
port = int(port_input)
except ValueError:
ui.error("Format Check Exception: Target port must be a numerical value.") if ui else print(f"{Colors.RED}[!] Format Check Exception: Target port must be a numerical value.{Colors.RESET}")
time.sleep(1.2)
return
if ui is not None:
ui.info(f"Opening socket connection pipeline to {target}:{port}...")
else:
print(f"\n{Colors.GREEN}Opening socket connection pipeline to {target}:{port}...{Colors.RESET}")
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(3.5)
s.connect((target, port))
if port in [80, 8080]:
s.sendall(b"HEAD / HTTP/1.1\r\nHost: " + target.encode() + b"\r\n\r\n")
banner = s.recv(1024)
s.close()
if ui is not None:
ui.panel(banner.decode('utf-8', errors='ignore').strip(),
title="REMOTE DATA CAPTURED", border_style="green", box_style=ROUNDED, padding=(1, 2))
else:
print(f"\n{Colors.GREEN}[✓] REMOTE DATA CAPTURED // SOFTWARE RECORD ANCHOR{Colors.RESET}\n")
print("-" * 75)
print(banner.decode('utf-8', errors='ignore').strip())
except Exception as e:
ui.error(f"Pipeline Dropped: Stream handshake interface rejected: {e}") if ui else print(f"\n{Colors.RED}[!] Pipeline Dropped: Stream handshake interface rejected: {e}{Colors.RESET}")
if ui is not None:
ui.pause("Press Enter to return")
else:
input(f"\nPress Enter to return to menu directory structure...")
def run_subdomain_finder():
if ui is not None:
ui.section("MODULE 07 // PASSIVE DOMAIN SUBDOMAIN FINDER", "cyan")
else:
print(f"\n{Colors.AMBER}[MODULE 07 // PASSIVE DOMAIN SUBDOMAIN FINDER]{Colors.RESET}")
target_root = (ui.prompt_input("Enter target parent root domain (e.g., corporate.com):")
if ui is not None
else input("\nEnter target parent root domain (e.g., corporate.com): ").strip())
if not target_root:
return
if ui is not None:
ui.info("Opening stream to transparency certificate logs database endpoint...")
else:
print(f"\n{Colors.GREEN}Opening stream to transparency certificate logs database endpoint...{Colors.RESET}")
url = f"https://crt.sh/?q={target_root}&output=json"
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'})
try:
with urllib.request.urlopen(req, timeout=15) as response:
if response.status == 200:
raw_json = response.read().decode('utf-8')
data = json.loads(raw_json)
isolated_subs = set()
for item in data:
name_value = item.get('name_value', '')
for split_node in name_value.split('\n'):
split_node = split_node.strip().lower()
if split_node.endswith(target_root) and "*" not in split_node:
isolated_subs.add(split_node)
if ui is not None:
sub_table = Table(title=f"DISCOVERED SUBDOMAINS ({len(isolated_subs)})",
border_style="green", header_style="bold green", box=ROUNDED)
sub_table.add_column("#", style="dim", width=5)
sub_table.add_column("SUBDOMAIN", style="cyan", ratio=1)
for i, subdomain in enumerate(sorted(isolated_subs), 1):
sub_table.add_row(str(i), subdomain)
ui.console.print()
ui.console.print(sub_table)
ui.console.print()
else:
print(f"\n{Colors.GREEN}[✓] PASSIVE DISCOVERY RECON LOG INDEX ({len(isolated_subs)} ENTRIES TRACKED){Colors.RESET}")
print("-" * 75)
for subdomain in sorted(isolated_subs):
print(f" ➔ Verified Subdomain Host: {Colors.CYAN}{subdomain}{Colors.RESET}")
else:
ui.error(f"Server Connection Error: Server dropped protocol flag HTTP {response.status}") if ui else print(f"{Colors.RED}[!] Server Connection Error: Server dropped protocol flag HTTP {response.status}{Colors.RESET}")
except Exception as e:
ui.error(f"External Index Disconnected: Registry logs unreadable or stream timeout: {e}") if ui else print(f"\n{Colors.RED}[!] External Index Disconnected: Registry logs unreadable or stream timeout: {e}{Colors.RESET}")
if ui is not None:
ui.pause("Press Enter to return")
else:
input(f"\nProcessing complete. Press Enter to drop layout cache...")
def run_rdap_lookup():
if ui is not None:
ui.section("MODULE 08 // ADVANCED RDAP REGISTRATION INFRASTRUCTURE MAPPER", "cyan")
else:
print(f"\n{Colors.AMBER}[MODULE 08 // ADVANCED RDAP REGISTRATION INFRASTRUCTURE MAPPER]{Colors.RESET}")
target_input = (ui.prompt_input("Enter target system IP address or domain path:")
if ui is not None
else input("Enter target system IP address or domain path: ").strip())
if not target_input:
return
is_raw_ip = True
try:
socket.inet_aton(target_input)
except Exception:
is_raw_ip = False
if not is_raw_ip:
if ui is not None:
ui.info("Resolving domain target to network routing address...")
else:
print(f"{Colors.GREEN}Resolving domain target to network routing address...{Colors.RESET}")
try:
lookup_ip = socket.gethostbyname(target_input)
if ui is not None:
ui.info(f"Domain mapped to routing coordinate: {lookup_ip}")
else:
print(f"Domain mapped to routing coordinate: {Colors.CYAN}{lookup_ip}{Colors.RESET}")
except Exception as e:
ui.warning(f"Error tracking domain mapping: {e}. Attempting direct query format...") if ui else print(f"{Colors.RED}[!] Error tracking domain mapping: {e}. Attempting direct query format...{Colors.RESET}")
lookup_ip = target_input
else:
lookup_ip = target_input
if ui is not None:
ui.info("Sending configuration request packet array to RDAP name registries...")
else:
print(f"\n{Colors.GREEN}Sending configuration request packet array to RDAP name registries...{Colors.RESET}")
url = f"https://rdap.org/ip/{lookup_ip}"
req = urllib.request.Request(url, headers={'User-Agent': 'Mainframe-Terminal-Multitool'})
try:
with urllib.request.urlopen(req, timeout=12) as response:
raw_data = response.read().decode('utf-8')
parsed_records = json.loads(raw_data)
rdap_data = [
("Primary Entity Identifier", parsed_records.get('name', 'UNKNOWN')),
("Assigned Allocation Block", f"{parsed_records.get('startAddress', 'N/A')} - {parsed_records.get('endAddress', 'N/A')}"),
("Registered Country Code", parsed_records.get('country', 'UNKNOWN')),
]
entities = parsed_records.get('entities', [])
if entities:
vcard = entities[0].get('vcardArray', [])
if len(vcard) > 1:
for element in vcard[1]:
if element[0] == 'fn':
rdap_data.append(("Administrative Provider", element[3]))
if ui is not None:
ui.result_table("PRODUCTION INFRASTRUCTURE METRIC DATA BLOCKS",
["FIELD", "VALUE"], rdap_data, border_style="green")
else:
print(f"\n{Colors.GREEN}[✓] PRODUCTION INFRASTRUCTURE METRIC DATA BLOCKS{Colors.RESET}")
print("-" * 75)
print(f" ➔ Primary Entity Identifier : {Colors.CYAN}{parsed_records.get('name', 'UNKNOWN')}{Colors.RESET}")
print(f" ➔ Assigned Allocation Block : {parsed_records.get('startAddress', 'N/A')} - {parsed_records.get('endAddress', 'N/A')}")
print(f" ➔ Registered Country Code : {parsed_records.get('country', 'UNKNOWN')}")
entities = parsed_records.get('entities', [])
if entities:
vcard = entities[0].get('vcardArray', [])
if len(vcard) > 1:
for element in vcard[1]:
if element[0] == 'fn':
print(f" ➔ Administrative Provider : {Colors.AMBER}{element[3]}{Colors.RESET}")
except Exception as err:
if ui is not None:
ui.error(f"Registry Allocation Block Record Missing or Timeout: {err}")
else:
print(f"\n{Colors.RED}[!] Registry Allocation Block Record Missing or Timeout: {err}{Colors.RESET}")
if ui is not None:
ui.pause("Press Enter to return")
else:
input(f"\nModule pipeline sequence finished. Press Enter to navigate back to choices...")
def run_http_header_auditor():
if ui is not None:
ui.section("MODULE 09 // HTTP HEADER SECURITY COMPLIANCE & HARDENING AUDITOR", "cyan")
else:
print(f"\n{Colors.AMBER}[MODULE 09 // HTTP HEADER SECURITY COMPLIANCE & HARDENING AUDITOR]{Colors.RESET}")
target_url = (ui.prompt_input("Enter target domain or URL (e.g., example.com):")
if ui is not None
else input("Enter target domain or URL (e.g., example.com): ").strip())
if not target_url:
return
if not target_url.startswith("http://") and not target_url.startswith("https://"):
target_url = "https://" + target_url
if ui is not None:
ui.info("Sending connection handshake request to analyze header configurations...")
else:
print(f"\n{Colors.GREEN}Sending connection handshake request to analyze header configurations...{Colors.RESET}")
req = urllib.request.Request(target_url, headers={'User-Agent': 'Mainframe-Terminal-Multitool-Auditor'})
try:
with urllib.request.urlopen(req, timeout=10) as response:
headers = response.info()