From c40ae9620b1e766fc2505e8faf9f6dce03800af7 Mon Sep 17 00:00:00 2001 From: Hardik Zinzuvadiya Date: Sat, 4 Mar 2023 06:07:11 -0500 Subject: [PATCH] [FIX]#Install & Update Script fixed, added gitignore --- .gitignore | 185 +++++++++++++++++++++++++++++++++++++++++++++++++++ install.sh | 190 +++++++++++++++++++++++++++++++++-------------------- update.sh | 82 +++++++++++------------ 3 files changed, 345 insertions(+), 112 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f4e2cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,185 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python,venv +# Edit at https://www.toptal.com/developers/gitignore?templates=python,venv + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ +.idea/ +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +### venv ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +pip-selfcheck.json + +# End of https://www.toptal.com/developers/gitignore/api/python,venv diff --git a/install.sh b/install.sh index a5c3b6e..0b954dc 100644 --- a/install.sh +++ b/install.sh @@ -4,19 +4,33 @@ set -e clear -BLACK='\e[30m' -RED='\e[31m' -GREEN='\e[92m' -YELLOW='\e[33m' -ORANGE='\e[93m' -BLUE='\e[34m' -PURPLE='\e[35m' -CYAN='\e[36m' -WHITE='\e[37m' +RED='\e[1;31m' +GREEN='\e[1;32m' +YELLOW='\e[1;33m' +BLUE='\e[1;34m' +CYAN='\e[1;36m' +WHITE='\e[1;37m' +ORANGE='\e[1;93m' NC='\e[0m' -purpal='\033[35m' -echo -e "${ORANGE} " +if [[ $EUID -ne 0 ]]; then + echo -e "${RED}This script must be run as root" + exit 1 +fi + +COLOR_NUM=$((RANDOM % 7)) +# Assign a color variable based on the random number +case $COLOR_NUM in + 0) COLOR=$RED;; + 1) COLOR=$GREEN;; + 2) COLOR=$YELLOW;; + 3) COLOR=$BLUE;; + 4) COLOR=$CYAN;; + 5) COLOR=$ORANGE;; + *) COLOR=$WHITE;; +esac + +echo -e "${COLOR}" echo "" echo " ▄█ █▄ ▄████████ ▄████████ ▄█ ▄█▄ ▄█ ███▄▄▄▄ ▄██████▄ ███ ▄██████▄ ▄██████▄ ▄█ "; echo " ███ ███ ███ ███ ███ ███ ███ ▄███▀ ███ ███▀▀▀██▄ ███ ███ ▀█████████▄ ███ ███ ███ ███ ███ "; @@ -30,74 +44,110 @@ echo " ▀ echo -e "${BLUE} https://github.com/Z4nzu/hackingtool ${NC}" echo -e "${RED} [!] This Tool Must Run As ROOT [!]${NC}\n" -echo -e ${CYAN} "Select Best Option : \n" +echo -e "${CYAN} Select Best Option : \n" echo -e "${WHITE} [1] Kali Linux / Parrot-Os (apt)" echo -e "${WHITE} [2] Arch Linux (pacman)" # added arch linux support because of feature request #231 echo -e "${WHITE} [0] Exit " -echo -n -e "Z4nzu >> " -read choice -INSTALL_DIR="/usr/share/doc/hackingtool" -BIN_DIR="/usr/bin/" -if [ $choice == 1 ] || [ $choice == 2 ]; then - echo "[*] Checking Internet Connection .." - wget -q --tries=10 --timeout=20 --spider https://google.com - if [[ $? == 0 ]]; then - echo -e ${BLUE}"[✔] Loading ... " - if [ $choice == 1 ]; then - sudo apt-get update -y && apt-get upgrade -y - sudo apt-get install python3-pip -y - elif [ $choice == 2 ]; then # added arch linux support because of feature request #231 - sudo pacman -Suy - sudo pacman -S python-pip yay - fi - echo "[✔] Checking directories..." - if [ -d "$INSTALL_DIR" ]; then - echo "[!] A Directory hackingtool Was Found.. Do You Want To Replace It ? [y/n]:" ; - read input - if [ "$input" = "y" ]; then - sudo rm -R "$INSTALL_DIR" - else - exit - fi - fi +echo -e "${COLOR}┌──($USER㉿$HOST)-[$(pwd)]" +read -p "└─$>>" choice - echo "[✔] Installing ...\n"; - sudo git clone https://github.com/Z4nzu/hackingtool.git "$INSTALL_DIR"; - echo "#!/bin/bash - python3 $INSTALL_DIR/hackingtool.py" '${1+"$@"}' > hackingtool; - sudo chmod +x hackingtool; - sudo cp hackingtool /usr/bin/ && rm hackingtool; - echo "\n[✔] Trying to installing Requirements ..." - if [ $choice == 1 ]; then - sudo pip3 install lolcat boxes flask requests - sudo apt-get install -y figlet - elif [ $choice == 2 ]; then # added arch linux support because of feature request #231 - sudo pip3 install lolcat boxes flask requests - yay -S boxes --noconfirm - sudo pacman -S figlet - fi +# Define installation directories +install_dir="/usr/share/hackingtool" +bin_dir="/usr/bin" - else - echo -e $RED "Please Check Your Internet Connection ..!!" - fi - - if [ -d "$INSTALL_DIR" ]; then +# Check if the user chose a valid option and perform the installation steps +if [[ $choice =~ ^[1-2]+$ ]]; then + 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 ""; - echo "[✔] Successfuly Installed !!! \n\n"; - echo -e $ORANGE " [+]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[+]" - echo " [+] [+]" - echo -e $ORANGE " [+] ✔✔✔ Now Just Type In Terminal (hackingtool) ✔✔✔ [+]" - echo " [+] [+]" - echo -e $ORANGE " [+]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[+]" + echo -e "${YELLOW}[*] Updating package list ..." + # Perform installation steps based on the user's choice + if [[ $choice == 1 ]]; then + sudo apt update -y && sudo apt upgrade -y + sudo apt-get install -y git python3-pip figlet boxes php curl xdotool wget -y ; + elif [[ $choice == 2 ]]; then + sudo pacman -Suy -y + sudo pacman -S python-pip-19.1.1-1 yay -y + else + exit + fi + echo ""; + echo -e "${YELLOW}[*] Checking directories...${NC}" + if [[ -d "$install_dir" ]]; then + echo -e -n "${RED}[!] The directory $install_dir already exists. Do you want to replace it? [y/n]: ${NC}" + read input + if [[ $input == "y" ]] || [[ $input == "Y" ]]; then + echo -e "${YELLOW}[*]Removing existing module.. ${NC}" + sudo rm -rf "$install_dir" + else + echo -e "${RED}[✘]Installation Not Required[✘] ${NC}" + exit + fi + fi + echo ""; + echo -e "${YELLOW}[✔] Downloading hackingtool...${NC}" + if sudo git clone https://github.com/Z4nzu/hackingtool.git $install_dir; then + # Install virtual environment + echo -e "${YELLOW}[*] Installing Virtual Environment...${NC}" + sudo apt install python3-venv -y + echo ""; + # Create a virtual environment for the tool + echo -e "${YELLOW}[*] Creating virtual environment..." + sudo python3 -m venv $install_dir/venv + source $install_dir/venv/bin/activate + # Install requirements + echo -e "${GREEN}[✔] Virtual Environment successfully [✔]${NC}"; + echo ""; + echo -e "${YELLOW}[*] Installing requirements...${NC}" + if [[ $choice == 1 ]]; then + pip3 install -r $install_dir/requirement.txt + sudo apt install figlet -y + elif [[ $choice == 2 ]]; then + pip3 install -r $install_dir/requirement.txt + yay -S boxes --noconfirm + sudo pacman -S figlet -y + fi + # Create a shell script to launch the tool + echo -e "${YELLOW}[*] Creating a shell script to launch the tool..." +# echo '#!/bin/bash' > hackingtool.sh + echo '#!/bin/bash' > $install_dir/hackingtool.sh + echo "source $install_dir/venv/bin/activate" >> $install_dir/hackingtool.sh + echo "python3 $install_dir/hackingtool.py \$@" >> $install_dir/hackingtool.sh + chmod +x $install_dir/hackingtool.sh + sudo mv $install_dir/hackingtool.sh $bin_dir/hackingtool + echo -e "${GREEN}[✔] Script created successfully [✔]" + else + echo -e "${RED}[✘] Failed to download Hackingtool [✘]" + exit 1 + fi + else - echo "[✘] Installation Failed !!! [✘]"; - exit + echo -e "${RED}[✘] Internet connection is not available [✘]${NC}" + exit 1 fi -elif [ $choice == 0 ] && [ $choice != 1 ] && [ $choice != 2 ]; then # fixed the "./test.sh: line 107: [: asd: integer expression expected" when entering any invalid input containing letters - echo -e $RED "[✘] THank Y0u !! [✘] " - exit + + if [ -d $install_dir ]; then + echo ""; + echo -e "${GREEN}[✔] Successfully Installed [✔]"; + echo ""; + echo ""; + echo -e "${ORANGE}[+]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[+]" + echo "[+] [+]" + echo -e "${ORANGE}[+] ✔✔✔ Now Just Type In Terminal (hackingtool) ✔✔✔ [+]" + echo "[+] [+]" + echo -e "${ORANGE}[+]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[+]" + else + echo -e "${RED}[✘] Installation Failed !!! [✘]"; + exit 1 + fi + +elif [[ $choice == 0 ]]; then + echo -e "${RED}[✘] Exiting tool [✘]" + exit 1 else - echo -e $RED "[!] Select Valid Option [!]" + echo -e "${RED}[!] Select Valid Option [!]" fi diff --git a/update.sh b/update.sh index b932440..4f6554b 100644 --- a/update.sh +++ b/update.sh @@ -1,3 +1,10 @@ +#!/bin/bash + +RED='\e[1;31m' +GREEN='\e[1;32m' +YELLOW='\e[1;33m' +BLUE='\e[1;34m' + echo "███████╗██╗ ██╗███╗ ██╗███████╗██╗ ██╗ "; echo "╚══███╔╝██║ ██║████╗ ██║╚══███╔╝██║ ██║ "; echo " ███╔╝ ███████║██╔██╗ ██║ ███╔╝ ██║ ██║ "; @@ -6,48 +13,39 @@ echo "███████╗ ██║██║ ╚████║██ echo "╚══════╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═════╝ "; echo " "; -clear +# 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 -sudo chmod +x /etc/ +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 -clear +# 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 -sudo chmod +x /usr/share/doc - -clear - -sudo rm -rf /usr/share/doc/hackingtool/ - -clear - -cd /etc/ - -clear - -sudo rm -rf /etc/hackingtool - -clear - -mkdir hackingtool - -clear - -cd hackingtool - -clear - -git clone https://github.com/Z4nzu/hackingtool.git - -clear - -cd hackingtool - -clear - -sudo chmod +x install.sh - -clear - -./install.sh - -clear +echo -e "${GREEN}[SUCCESS]\e[0m Tool updated successfully."