mirror of
https://github.com/Z4nzu/hackingtool
synced 2026-05-23 08:58:22 +00:00
Fix Docker sudo error, 99 back navigation, and empty input exit
install.py: - sudo prefix now determined by euid (== 0 means root) not by OS name - Previously used 'sudo ' for all Linux — breaks inside Docker where we run as root but sudo is not installed - Single priv variable computed once at top of install_system_packages() Dockerfile: - Add python3-venv back to apt installs - Was removed as 'unused' but install.py uses 'python3 -m venv' to create the virtualenv in APP_INSTALL_DIR; missing package caused venv failure core.py (HackingTool.show_options + HackingToolsCollection.show_options): - 99 always returns now instead of sys.exit() when parent is None Previously: sub-menus with no parent called sys.exit() — since interact_menu() never passes parent, pressing 99 in any category exited the entire program instead of returning to the main menu - Empty Enter (blank input) now continues the loop instead of defaulting to "99" and triggering exit Previously: Prompt default="99" meant pressing Enter without typing anything was treated as choosing exit - "Exit" label on 99 row changed to "Main Menu" since it now returns
This commit is contained in:
parent
64b9062c9e
commit
3953a280ad
3 changed files with 15 additions and 13 deletions
|
|
@ -12,7 +12,7 @@ LABEL org.opencontainers.image.title="hackingtool" \
|
|||
# - --no-install-recommends keeps the layer lean
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
git python3-pip curl wget php && \
|
||||
git python3-pip python3-venv curl wget php && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /root/hackingtool
|
||||
|
|
|
|||
20
core.py
20
core.py
|
|
@ -113,10 +113,12 @@ class HackingTool:
|
|||
|
||||
if self.PROJECT_URL:
|
||||
table.add_row("98", "Open Project Page")
|
||||
table.add_row("99", f"Back to {parent.TITLE if parent else 'Exit'}")
|
||||
table.add_row("99", f"Back to {parent.TITLE if parent else 'Main Menu'}")
|
||||
console.print(table)
|
||||
|
||||
raw = Prompt.ask("\n[bold cyan][?] Select an option[/bold cyan]", default="99")
|
||||
raw = Prompt.ask("\n[bold cyan][?] Select an option[/bold cyan]", default="")
|
||||
if not raw.strip():
|
||||
continue
|
||||
try:
|
||||
choice = int(raw)
|
||||
except ValueError:
|
||||
|
|
@ -125,9 +127,7 @@ class HackingTool:
|
|||
continue
|
||||
|
||||
if choice == 99:
|
||||
if parent is None:
|
||||
sys.exit()
|
||||
return 99
|
||||
return
|
||||
elif choice == 98 and self.PROJECT_URL:
|
||||
self.show_project_page()
|
||||
elif 1 <= choice <= len(self.OPTIONS):
|
||||
|
|
@ -272,10 +272,12 @@ class HackingToolsCollection:
|
|||
if incompatible:
|
||||
console.print(f"[dim]({len(incompatible)} tools hidden — not supported on current OS)[/dim]")
|
||||
|
||||
table.add_row("99", f"Back to {parent.TITLE if parent else 'Exit'}")
|
||||
table.add_row("99", f"Back to {parent.TITLE if parent else 'Main Menu'}")
|
||||
console.print(table)
|
||||
|
||||
raw = Prompt.ask("\n[bold cyan][?] Choose a tool[/bold cyan]", default="99")
|
||||
raw = Prompt.ask("\n[bold cyan][?] Choose a tool[/bold cyan]", default="")
|
||||
if not raw.strip():
|
||||
continue
|
||||
try:
|
||||
choice = int(raw)
|
||||
except ValueError:
|
||||
|
|
@ -283,9 +285,7 @@ class HackingToolsCollection:
|
|||
continue
|
||||
|
||||
if choice == 99:
|
||||
if parent is None:
|
||||
sys.exit()
|
||||
return 99
|
||||
return
|
||||
elif choice == 98 and archived:
|
||||
self._show_archived_tools()
|
||||
elif 0 <= choice < len(active):
|
||||
|
|
|
|||
|
|
@ -107,11 +107,14 @@ def install_system_packages():
|
|||
console.print("[warning]Skipping system packages — no package manager found.[/warning]")
|
||||
return
|
||||
|
||||
# Use sudo only when not already root (uid != 0).
|
||||
# Inside Docker we run as root and sudo is not installed.
|
||||
priv = "" if os.geteuid() == 0 else "sudo "
|
||||
|
||||
# Update index first (skip for brew — not needed)
|
||||
if mgr != "brew":
|
||||
update_cmd = PACKAGE_UPDATE_CMDS.get(mgr, "")
|
||||
if update_cmd:
|
||||
priv = "" if CURRENT_OS.system == "macos" else "sudo "
|
||||
console.print(f"[dim]Updating package index ({mgr})...[/dim]")
|
||||
subprocess.run(f"{priv}{update_cmd}", shell=True, check=False)
|
||||
|
||||
|
|
@ -121,7 +124,6 @@ def install_system_packages():
|
|||
|
||||
install_tpl = PACKAGE_INSTALL_CMDS[mgr]
|
||||
cmd = install_tpl.format(packages=" ".join(packages))
|
||||
priv = "" if CURRENT_OS.system == "macos" else "sudo "
|
||||
console.print(f"[dim]Installing system dependencies ({mgr})...[/dim]")
|
||||
result = subprocess.run(f"{priv}{cmd}", shell=True, check=False)
|
||||
if result.returncode != 0:
|
||||
|
|
|
|||
Loading…
Reference in a new issue