-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
204 lines (167 loc) · 6.75 KB
/
Copy pathmain.py
File metadata and controls
204 lines (167 loc) · 6.75 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
import sys
import os
import shutil
import subprocess
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
import questionary
from utils.validator import ToolValidator
console = Console()
BANNER = r"""
_ _
/x\ /x\
/v\x\ /v\/\
\><\x\ /></x/
\><\x\ /></x/
__ __ __|><\x/></x/___
/##_##\/ \</x/ \__________
|###|###| \ \ __________\
\##|##/ \__\____\____\__/ \\
|_| | | | | | | \|
\*/ \ | | | | / /
____ __ __ _ _ ___ ____ ____ _ _ _
/ __ \| \/ | \ | |_ _/ ___| / ___| / \ | \ | |
| | | | |\/| | \| || |\___ \| | / _ \ | \| |
| |__| | | | | |\ || | ___) | |___ / ___ \| |\ |
\____/|_| |_|_| \_|___|____/ \____/_/ \_\_| \_|
> The All-in-One Recon & Wordlist Suite <
"""
MENU_CHOICES = [
"1. Wordlist Generator",
"2. Web Analysis & Fuzzing [ffuf, gobuster, wpscan]",
"3. Network Scanning [nmap, netcat, enum4linux]",
"4. OSINT & Recon [amass, sherlock, theHarvester]",
"5. Info Gathering [whois, nslookup]",
"6. Exit",
]
# Ordered list of terminal emulators to try when spawning a new window.
# Each entry: (binary, [args_before_exec_flag], exec_flag)
TERMINAL_CANDIDATES = [
("kitty", [], None), # kitty runs cmd directly
("alacritty", [], "-e"),
("gnome-terminal",["--"], None), # uses -- separator
("konsole", [], "-e"),
("xfce4-terminal",[], "-x"),
("tilix", [], "-e"),
("terminator", [], "-x"),
("urxvt", [], "-e"),
("rxvt", [], "-e"),
("xterm", [], "-e"),
]
# ---------------------------------------------------------------------------
# New-window launcher
# ---------------------------------------------------------------------------
def _find_terminal() -> tuple[str, list[str], str | None] | None:
"""Return the first available terminal entry, or None if none found."""
for binary, pre_args, exec_flag in TERMINAL_CANDIDATES:
if shutil.which(binary):
return binary, pre_args, exec_flag
return None
def relaunch_in_new_window() -> None:
"""
Spawn a new terminal window running OmniScan, then exit this process.
If no supported terminal is found, continue in the current window with a warning.
"""
entry = _find_terminal()
if entry is None:
console.print(
"[bold yellow][!] No supported terminal emulator found.[/bold yellow]\n"
"[dim] Tried: " + ", ".join(b for b, *_ in TERMINAL_CANDIDATES) + "\n"
" Running in current window.[/dim]\n"
)
return
binary, pre_args, exec_flag = entry
# Reconstruct the command that launched us, preserving venv python
python = sys.executable
script = os.path.abspath(__file__)
workdir = os.path.dirname(script)
# Pass a special env var so the relaunched process skips the window-spawn
env = os.environ.copy()
env["OMNISCAN_NEW_WINDOW"] = "1"
if binary == "kitty":
cmd = ["kitty", "--directory", workdir, python, script]
elif binary == "gnome-terminal":
cmd = ["gnome-terminal", "--working-directory", workdir, "--"] + [python, script]
else:
cmd = [binary] + pre_args
if exec_flag:
cmd += [exec_flag]
cmd += [python, script]
try:
subprocess.Popen(cmd, env=env, cwd=workdir)
sys.exit(0)
except Exception as e:
console.print(f"[bold yellow][!] Could not open new window: {e}[/bold yellow]\n"
"[dim] Running in current window.[/dim]\n")
# ---------------------------------------------------------------------------
# Startup checks
# ---------------------------------------------------------------------------
def display_banner() -> None:
text = Text(BANNER, style="bold cyan")
console.print(Panel(text, expand=False, border_style="cyan"))
def validate_environment() -> None:
"""
Check tool availability at startup.
Tools resolved via an alias (e.g. theharvester instead of theHarvester)
are considered available and are NOT listed as missing.
"""
validator = ToolValidator()
missing = validator.check_all()
if missing:
console.print(
f"\n[bold yellow][!] Tools not found: {', '.join(missing)}[/bold yellow]"
)
console.print(
"[dim] Install them or add them to your PATH. "
"If inside a venv, they may only be available system-wide.[/dim]\n"
)
# ---------------------------------------------------------------------------
# Main menu
# ---------------------------------------------------------------------------
def main_menu() -> None:
while True:
choice = questionary.select(
"Select a scan category:",
choices=MENU_CHOICES,
style=questionary.Style([
("selected", "fg:cyan bold"),
("pointer", "fg:cyan bold"),
("highlighted", "fg:cyan"),
]),
).ask()
if choice is None:
raise KeyboardInterrupt
if choice.startswith("1"):
from core.generator import WordlistGenerator
WordlistGenerator(console).run()
elif choice.startswith("2"):
from modules.web import WebModule
WebModule(console).run()
elif choice.startswith("3"):
from modules.network import NetworkModule
NetworkModule(console).run()
elif choice.startswith("4"):
from modules.osint import OSINTModule
OSINTModule(console).run()
elif choice.startswith("5"):
from modules.info import InfoModule
InfoModule(console).run()
elif choice.startswith("6"):
console.print("\n[bold green]Happy Hacking! Goodbye.[/bold green]\n")
sys.exit(0)
# ---------------------------------------------------------------------------
# Entry point
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# Only try to open a new window on the first launch (not when already
# running inside the spawned window).
if not os.environ.get("OMNISCAN_NEW_WINDOW"):
relaunch_in_new_window()
display_banner()
validate_environment()
try:
main_menu()
except KeyboardInterrupt:
console.print("\n[bold red]\n[!] Interrupted by user. Goodbye.[/bold red]\n")
sys.exit(0)