mirror of
https://github.com/Z4nzu/hackingtool
synced 2026-05-23 08:58:22 +00:00
replace (update.sh) with (update.py)
This commit is contained in:
parent
e27a9215a7
commit
612fe9b4f4
2 changed files with 90 additions and 51 deletions
90
update.py
Normal file
90
update.py
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#!/usr/bin/env python3
|
||||
from rich.console import Console
|
||||
from rich.panel import Panel
|
||||
from rich.table import Table
|
||||
from rich.prompt import Prompt
|
||||
from rich.text import Text
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
console = Console()
|
||||
|
||||
ASCII = r"""
|
||||
███████╗██╗ ██╗███╗ ██╗███████╗██╗ ██╗
|
||||
╚══███╔╝██║ ██║████╗ ██║╚══███╔╝██║ ██║
|
||||
███╔╝ ███████║██╔██╗ ██║ ███╔╝ ██║ ██║
|
||||
███╔╝ ╚════██║██║╚██╗██║ ███╔╝ ██║ ██║
|
||||
███████╗ ██║██║ ╚████║███████╗╚██████╔╝
|
||||
╚══════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═════╝
|
||||
|
||||
"""
|
||||
|
||||
purple = "bold #7B61FF"
|
||||
green = "bold green"
|
||||
red = "bold red"
|
||||
yellow = "bold yellow"
|
||||
blue = "bold blue"
|
||||
|
||||
console.print(Panel(Text(ASCII, justify="center"), style=purple, padding=(1,2)))
|
||||
|
||||
if os.geteuid() != 0:
|
||||
console.print(f"[{red}][ERROR][/{red}] This script must be run as root.")
|
||||
sys.exit(1)
|
||||
|
||||
install_dir = "/usr/share/hackingtool"
|
||||
|
||||
try:
|
||||
os.chdir(install_dir)
|
||||
except Exception:
|
||||
console.print(f"[{red}][ERROR][/{red}] Could not change to directory containing install.sh.")
|
||||
sys.exit(1)
|
||||
|
||||
console.print(f"[{yellow}][*][/{yellow}] Checking Internet Connection ..\n")
|
||||
ok = False
|
||||
urls = ["https://www.google.com", "https://www.github.com"]
|
||||
for u in urls:
|
||||
try:
|
||||
r = subprocess.run(["curl", "-s", "-m", "10", u], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
if r.returncode == 0:
|
||||
ok = True
|
||||
break
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
if ok:
|
||||
console.print(f"[{green}][✔] Internet connection is OK [✔][/{green}]\n")
|
||||
else:
|
||||
console.print(f"[{red}][✘] Please check your internet connection[✘][/{red}]\n")
|
||||
sys.exit(1)
|
||||
|
||||
console.print("[*]Marking hackingtool directory as safe-directory")
|
||||
cfg = subprocess.run(["git", "config", "--global", "--add", "safe.directory", install_dir])
|
||||
if cfg.returncode != 0:
|
||||
console.print(f"[{red}][ERROR][/{red}] Failed to mark safe.directory.")
|
||||
sys.exit(1)
|
||||
|
||||
console.print(f"[{blue}][INFO][/{blue}] Updating repository and tool...")
|
||||
pull = subprocess.run(["git", "pull"])
|
||||
if pull.returncode != 0:
|
||||
console.print(f"[{red}][ERROR][/{red}] Failed to update repository or tool.")
|
||||
sys.exit(1)
|
||||
|
||||
console.print(f"[{green}][INFO][/{green}] Running installation script...")
|
||||
run_inst = subprocess.run(["bash", "install.sh"])
|
||||
if run_inst.returncode != 0:
|
||||
console.print(f"[{red}][ERROR][/{red}] Failed to run installation script.")
|
||||
sys.exit(1)
|
||||
|
||||
console.print(f"[{green}][SUCCESS][/{green}] Tool updated successfully.")
|
||||
|
||||
menu_table = Table(show_header=False, box=None)
|
||||
menu_table.add_row(Text("Index 99 → Exit", style=purple))
|
||||
console.print(Panel(menu_table, title="Return to Menu", style=purple))
|
||||
|
||||
try:
|
||||
Prompt.ask("Press Enter to finish", default="")
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
sys.exit(0)
|
||||
51
update.sh
51
update.sh
|
|
@ -1,51 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
RED='\e[1;31m'
|
||||
GREEN='\e[1;32m'
|
||||
YELLOW='\e[1;33m'
|
||||
BLUE='\e[1;34m'
|
||||
|
||||
echo "███████╗██╗ ██╗███╗ ██╗███████╗██╗ ██╗ ";
|
||||
echo "╚══███╔╝██║ ██║████╗ ██║╚══███╔╝██║ ██║ ";
|
||||
echo " ███╔╝ ███████║██╔██╗ ██║ ███╔╝ ██║ ██║ ";
|
||||
echo " ███╔╝ ╚════██║██║╚██╗██║ ███╔╝ ██║ ██║ ";
|
||||
echo "███████╗ ██║██║ ╚████║███████╗╚██████╔╝ ";
|
||||
echo "╚══════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ ";
|
||||
echo " ";
|
||||
|
||||
# Check if the script is run as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo -e "${RED}[ERROR]\e[0m This script must be run as root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
install_dir="/usr/share/hackingtool"
|
||||
# Change to the directory containing the install.sh script
|
||||
cd $install_dir || { echo -e "${RED}[ERROR]\e[0m Could not change to directory containing install.sh."; exit 1; }
|
||||
echo -e "${YELLOW}[*] Checking Internet Connection ..${NC}"
|
||||
echo "";
|
||||
if curl -s -m 10 https://www.google.com > /dev/null || curl -s -m 10 https://www.github.com > /dev/null; then
|
||||
echo -e "${GREEN}[✔] Internet connection is OK [✔]${NC}"
|
||||
echo ""
|
||||
else
|
||||
echo -e "${RED}[✘] Please check your internet connection[✘]"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
echo -e "[*]Marking hackingtool directory as safe-directory"
|
||||
git config --global --add safe.directory $install_dir
|
||||
# Update the repository and the tool itself
|
||||
echo -e "${BLUE}[INFO]\e[0m Updating repository and tool..."
|
||||
if ! sudo git pull; then
|
||||
echo -e "${RED}[ERROR]\e[0m Failed to update repository or tool."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Re-run the installation script
|
||||
echo -e "${GREEN}[INFO]\e[0m Running installation script..."
|
||||
if ! sudo bash install.sh; then
|
||||
echo -e "${RED}[ERROR]\e[0m Failed to run installation script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}[SUCCESS]\e[0m Tool updated successfully."
|
||||
Loading…
Reference in a new issue