2025-10-14 02:02:18 -04:00
|
|
|
from rich.console import Console
|
|
|
|
|
from rich.panel import Panel
|
|
|
|
|
from rich.table import Table
|
|
|
|
|
from rich import box
|
|
|
|
|
from rich.traceback import install
|
|
|
|
|
from rich.theme import Theme
|
|
|
|
|
|
2020-08-14 16:41:59 +05:30
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import webbrowser
|
|
|
|
|
from platform import system
|
|
|
|
|
from traceback import print_exc
|
2025-10-14 02:02:18 -04:00
|
|
|
from typing import Callable, List, Tuple
|
|
|
|
|
|
|
|
|
|
# Enable rich tracebacks
|
|
|
|
|
install()
|
|
|
|
|
_theme = Theme({"purple": "#7B61FF"})
|
|
|
|
|
console = Console(theme=_theme)
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def clear_screen():
|
2022-06-13 12:56:48 +02:00
|
|
|
os.system("cls" if system() == "Windows" else "clear")
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_input(ip, val_range):
|
2022-06-13 12:56:48 +02:00
|
|
|
val_range = val_range or []
|
2020-08-14 16:41:59 +05:30
|
|
|
try:
|
|
|
|
|
ip = int(ip)
|
|
|
|
|
if ip in val_range:
|
|
|
|
|
return ip
|
2022-06-13 12:56:48 +02:00
|
|
|
except Exception:
|
2022-06-13 13:02:58 +02:00
|
|
|
return None
|
2022-06-13 12:56:48 +02:00
|
|
|
return None
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
class HackingTool(object):
|
2025-10-14 02:02:18 -04:00
|
|
|
TITLE: str = ""
|
2020-08-14 16:41:59 +05:30
|
|
|
DESCRIPTION: str = ""
|
|
|
|
|
INSTALL_COMMANDS: List[str] = []
|
|
|
|
|
INSTALLATION_DIR: str = ""
|
|
|
|
|
UNINSTALL_COMMANDS: List[str] = []
|
|
|
|
|
RUN_COMMANDS: List[str] = []
|
|
|
|
|
OPTIONS: List[Tuple[str, Callable]] = []
|
|
|
|
|
PROJECT_URL: str = ""
|
|
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def __init__(self, options=None, installable=True, runnable=True):
|
2022-06-13 12:59:39 +02:00
|
|
|
options = options or []
|
2020-08-14 16:41:59 +05:30
|
|
|
if isinstance(options, list):
|
|
|
|
|
self.OPTIONS = []
|
|
|
|
|
if installable:
|
2025-10-14 02:02:18 -04:00
|
|
|
self.OPTIONS.append(("Install", self.install))
|
2020-08-14 16:41:59 +05:30
|
|
|
if runnable:
|
2025-10-14 02:02:18 -04:00
|
|
|
self.OPTIONS.append(("Run", self.run))
|
2020-08-14 16:41:59 +05:30
|
|
|
self.OPTIONS.extend(options)
|
|
|
|
|
else:
|
2025-10-14 02:02:18 -04:00
|
|
|
raise Exception("options must be a list of (option_name, option_fn) tuples")
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
def show_info(self):
|
2025-10-14 02:02:18 -04:00
|
|
|
desc = f"[cyan]{self.DESCRIPTION}[/cyan]"
|
2020-08-14 16:41:59 +05:30
|
|
|
if self.PROJECT_URL:
|
2025-10-14 02:02:18 -04:00
|
|
|
desc += f"\n[green]🔗 {self.PROJECT_URL}[/green]"
|
|
|
|
|
console.print(Panel(desc, title=f"[bold purple]{self.TITLE}[/bold purple]", border_style="purple", box=box.DOUBLE))
|
2020-08-14 16:41:59 +05:30
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def show_options(self, parent=None):
|
2020-08-14 16:41:59 +05:30
|
|
|
clear_screen()
|
|
|
|
|
self.show_info()
|
2025-10-14 02:02:18 -04:00
|
|
|
|
|
|
|
|
table = Table(title="Options", box=box.SIMPLE_HEAVY)
|
|
|
|
|
table.add_column("No.", style="bold cyan", justify="center")
|
|
|
|
|
table.add_column("Action", style="bold yellow")
|
|
|
|
|
|
2020-08-14 16:41:59 +05:30
|
|
|
for index, option in enumerate(self.OPTIONS):
|
2025-10-14 02:02:18 -04:00
|
|
|
table.add_row(str(index + 1), option[0])
|
|
|
|
|
|
2020-08-14 16:41:59 +05:30
|
|
|
if self.PROJECT_URL:
|
2025-10-14 02:02:18 -04:00
|
|
|
table.add_row("98", "Open Project Page")
|
|
|
|
|
table.add_row("99", f"Back to {parent.TITLE if parent else 'Exit'}")
|
|
|
|
|
|
|
|
|
|
console.print(table)
|
|
|
|
|
|
|
|
|
|
option_index = input("\n[?] Select an option: ").strip()
|
2020-08-14 16:41:59 +05:30
|
|
|
try:
|
|
|
|
|
option_index = int(option_index)
|
|
|
|
|
if option_index - 1 in range(len(self.OPTIONS)):
|
|
|
|
|
ret_code = self.OPTIONS[option_index - 1][1]()
|
|
|
|
|
if ret_code != 99:
|
2025-10-14 02:02:18 -04:00
|
|
|
input("\nPress [Enter] to continue...")
|
2020-08-14 16:41:59 +05:30
|
|
|
elif option_index == 98:
|
|
|
|
|
self.show_project_page()
|
|
|
|
|
elif option_index == 99:
|
|
|
|
|
if parent is None:
|
|
|
|
|
sys.exit()
|
|
|
|
|
return 99
|
|
|
|
|
except (TypeError, ValueError):
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print("[red]⚠ Please enter a valid option.[/red]")
|
|
|
|
|
input("\nPress [Enter] to continue...")
|
2020-08-14 16:41:59 +05:30
|
|
|
except Exception:
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print_exception(show_locals=True)
|
|
|
|
|
input("\nPress [Enter] to continue...")
|
|
|
|
|
return self.show_options(parent=parent)
|
2020-08-14 16:41:59 +05:30
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def before_install(self): pass
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
def install(self):
|
|
|
|
|
self.before_install()
|
|
|
|
|
if isinstance(self.INSTALL_COMMANDS, (list, tuple)):
|
|
|
|
|
for INSTALL_COMMAND in self.INSTALL_COMMANDS:
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print(f"[yellow]→ {INSTALL_COMMAND}[/yellow]")
|
2020-08-14 16:41:59 +05:30
|
|
|
os.system(INSTALL_COMMAND)
|
|
|
|
|
self.after_install()
|
|
|
|
|
|
|
|
|
|
def after_install(self):
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print("[green]✔ Successfully installed![/green]")
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
def before_uninstall(self) -> bool:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def uninstall(self):
|
|
|
|
|
if self.before_uninstall():
|
|
|
|
|
if isinstance(self.UNINSTALL_COMMANDS, (list, tuple)):
|
|
|
|
|
for UNINSTALL_COMMAND in self.UNINSTALL_COMMANDS:
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print(f"[red]→ {UNINSTALL_COMMAND}[/red]")
|
2020-08-14 16:41:59 +05:30
|
|
|
os.system(UNINSTALL_COMMAND)
|
|
|
|
|
self.after_uninstall()
|
|
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def after_uninstall(self): pass
|
2020-08-14 16:41:59 +05:30
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def before_run(self): pass
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
self.before_run()
|
|
|
|
|
if isinstance(self.RUN_COMMANDS, (list, tuple)):
|
|
|
|
|
for RUN_COMMAND in self.RUN_COMMANDS:
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print(f"[cyan]⚙ Running:[/cyan] [bold]{RUN_COMMAND}[/bold]")
|
2020-08-14 16:41:59 +05:30
|
|
|
os.system(RUN_COMMAND)
|
|
|
|
|
self.after_run()
|
|
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def after_run(self): pass
|
2020-08-14 16:41:59 +05:30
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def is_installed(self, dir_to_check=None):
|
|
|
|
|
console.print("[yellow]⚠ Unimplemented: DO NOT USE[/yellow]")
|
2020-08-14 16:41:59 +05:30
|
|
|
return "?"
|
|
|
|
|
|
|
|
|
|
def show_project_page(self):
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print(f"[blue]🌐 Opening project page: {self.PROJECT_URL}[/blue]")
|
2020-08-14 16:41:59 +05:30
|
|
|
webbrowser.open_new_tab(self.PROJECT_URL)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HackingToolsCollection(object):
|
2025-10-14 02:02:18 -04:00
|
|
|
TITLE: str = ""
|
2020-08-14 16:41:59 +05:30
|
|
|
DESCRIPTION: str = ""
|
2025-10-14 02:02:18 -04:00
|
|
|
TOOLS: List = []
|
2020-08-14 16:41:59 +05:30
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def show_info(self):
|
2025-10-14 02:02:18 -04:00
|
|
|
console.rule(f"[bold purple]{self.TITLE}[/bold purple]", style="purple")
|
|
|
|
|
console.print(f"[italic cyan]{self.DESCRIPTION}[/italic cyan]\n")
|
2020-08-14 16:41:59 +05:30
|
|
|
|
2025-10-14 02:02:18 -04:00
|
|
|
def show_options(self, parent=None):
|
2020-08-14 16:41:59 +05:30
|
|
|
clear_screen()
|
|
|
|
|
self.show_info()
|
2025-10-14 02:02:18 -04:00
|
|
|
|
|
|
|
|
table = Table(title="Available Tools", box=box.MINIMAL_DOUBLE_HEAD)
|
|
|
|
|
table.add_column("No.", justify="center", style="bold cyan")
|
|
|
|
|
table.add_column("Tool Name", style="bold yellow")
|
|
|
|
|
|
2020-08-14 16:41:59 +05:30
|
|
|
for index, tool in enumerate(self.TOOLS):
|
2025-10-14 02:02:18 -04:00
|
|
|
table.add_row(str(index), tool.TITLE)
|
|
|
|
|
|
|
|
|
|
table.add_row("99", f"Back to {parent.TITLE if parent else 'Exit'}")
|
|
|
|
|
console.print(table)
|
|
|
|
|
|
|
|
|
|
tool_index = input("\n[?] Choose a tool: ").strip()
|
2020-08-14 16:41:59 +05:30
|
|
|
try:
|
|
|
|
|
tool_index = int(tool_index)
|
|
|
|
|
if tool_index in range(len(self.TOOLS)):
|
2025-10-14 02:02:18 -04:00
|
|
|
ret_code = self.TOOLS[tool_index].show_options(parent=self)
|
2020-08-14 16:41:59 +05:30
|
|
|
if ret_code != 99:
|
2025-10-14 02:02:18 -04:00
|
|
|
input("\nPress [Enter] to continue...")
|
2020-08-14 16:41:59 +05:30
|
|
|
elif tool_index == 99:
|
|
|
|
|
if parent is None:
|
|
|
|
|
sys.exit()
|
|
|
|
|
return 99
|
|
|
|
|
except (TypeError, ValueError):
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print("[red]⚠ Please enter a valid option.[/red]")
|
|
|
|
|
input("\nPress [Enter] to continue...")
|
2022-06-13 12:56:48 +02:00
|
|
|
except Exception:
|
2025-10-14 02:02:18 -04:00
|
|
|
console.print_exception(show_locals=True)
|
|
|
|
|
input("\nPress [Enter] to continue...")
|
|
|
|
|
return self.show_options(parent=parent)
|