Automate Installing your Tools in new Kali Environment
There are things that we really can’t avoid while we’re working, such as the breaking of something important to us, and it’s even worse if we don’t have a backup. As a Security Engineer, I often use Kali Linux on a virtual machine.
Have you ever experienced updating the environment of your Linux machine, or some dependencies and packages, then it suddenly broke or have conflicts? I mean, there are times when some programs just become broken and stop working or running.
That’s why it’s important to make it a habit to save a snapshot. So, if ever broken packages or dependencies occur while updating, and you can’t fix it anymore, you can simply revert to the snapshot where everything is still working properly.
But sometimes, we reach a point where we need to install a new Linux machine, where everything is fresh and clean.
Why install a new one when we could just update our existing machine?
Cleaner, Faster Performance
Lightweight and Efficient: Linux, especially in minimal installation forms (like using Ubuntu Server, CentOS, or Debian), doesn’t come with unnecessary bloatware. This makes it faster and more resource-efficient.
Optimized for Performance: It offers high performance in both server and desktop environments, allowing you to fine-tune system resources as needed.
No Legacy Issues: Over time, updates can accumulate old configuration files, libraries, and outdated dependencies. A fresh install provides a clean slate by removing unnecessary legacy files and processes that might slow down your system.
Security
Updated Patches: New installations come with the latest security patches, ensuring your system is up to date with the most recent improvements and bug fixes.
No Accumulated Vulnerabilities: When updating an existing system, critical updates might be missed, delayed, or improperly applied. A clean installation ensures there are no lingering vulnerabilities from old configurations or packages.
Reduced Risk of Conflicts
No Shits Dependency Hell: Over time, when you update an existing system, you might encounter issues with package dependencies or incompatible libraries. A fresh install ensures all packages are compatible with each other, with no risk of mismatched versions or broken dependencies.
Fewer Package Conflicts: New installations generally don’t carry over old configuration settings or package conflicts that can arise during updates, especially on systems with custom or third-party software installed.
Updated Software Stack
Up-to-Date Software Versions: A new installation includes the latest versions of software and libraries, ensuring you have access to the most recent features and improvements. This contrasts with updating an old system, where outdated packages might limit your capabilities.
Cleaner Software Repositories: Fresh installations pull from up-to-date and clean software repositories, ensuring all installed packages are the latest and unbroken versions. This can avoid issues seen in older systems that might still pull outdated packages from older repositories.
Support for Modern Features: A fresh install ensures your system is configured with the latest versions of essential libraries, tools, and drivers, which might not be available or supported on an older version of the OS.
Simplified Configuration and Customization
Better System Partitioning: A new installation offers an opportunity to reconfigure your system’s partitioning scheme, allowing you to improve disk usage and optimize performance. You can use tools like LVM (Logical Volume Management) or opt for more advanced filesystems solutions like Btrfs (modern copy on write (COW) file system for Linux).
Avoid Legacy Config Issues: When updating an older instance, some configuration files may be left behind, potentially causing issues when newer versions of packages are installed. A clean installation starts with the correct configuration files designed for the newest software versions.
Increased Stability
No Leftover Shits Issues: If your existing system has been upgraded over time, it may have accumulated minor issues—whether they’re performance-related, hardware incompatibilities, or small bugs. A fresh install allows you to start from scratch with an optimally configured, stable system.
Fewer Risks from Corrupted Update: Updates to existing systems can sometimes fail due to network issues, corrupted files, or other factors. With a new installation, you avoid the potential pitfalls of a failed update.
Installing tools from your old environment on a newly installed Linux system can be tedious and time-consuming. You often forget which tools you need until you actually use them.
That’s why I created a simple bash script that automatically installs the necessary tools from your previous setup. This script is easy to modify based on your needs.
Make sure you are in a sh session before running this script. The default Kali session runs on zsh.
chmod +x automate.sh
Scripts Breakdown
This line checks if the tools are already installed on the machine:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# install the scripts if it doesn't exist arsenal_script() { script_title="$1" shift if ! script "$script_title"; then echo -e "${YELLOW}Installing $script_title...${NC}\n\n" "$@" if [ $? -eq 0 ]; then echo -e "${GREEN}$script_title has been installed.${NC}\n\n" else echo -e "${RED}Failed to install $script_title.${NC}\n\n" fi fi }
This line will update your Kali Linux machine.
1 2 3 4 5 6 7
# Update your shits apt update -y
# Update your shits is something goes wrong apt update --fix-missing -y
# Remove existing Go installation and extract downloaded file --> this line is not working # tar -xvf go1.22.0.linux-amd64.tar.gz && mv go /usr/local && cd .. --> this line is not working
# Create directory for your tools | I named my folder as "arsenal-tools" mkdir -p arsenal-tools cd arsenal-tools || exit
# Install LinkFinder arsenal_script "LinkFinder" git clone https://github.com/GerbenJavado/LinkFinder.git && cd LinkFinder && pip install . && cd ..
# Install github-search arsenal_script "github-search" git clone https://github.com/gwen001/github-search && cd github-search && pip3 install -r requirements.txt && cd ..
# Install paramspider arsenal_script "ParamSpider" git clone https://github.com/devanshbatham/paramspider && cd paramspider && pip install . && cd ..
# Install SecretFinder arsenal_script "SecretFinder" git clone https://github.com/m4ll0k/SecretFinder.git && cd SecretFinder && pip install -r requirements.txt && cd ..
# Install dirsearch arsenal_script "dirSearch" git clone https://github.com/maurosoria/dirsearch.git --depth 1 && cd dirsearch && python setup.py install && cd ..
# add your prepared script here:
This script installs GRC (Generic Colouriser), which acts as a filter: it takes standard input, colorizes it, and writes the output to standard output.
# Create symlinks in /usr/local/bin/ for specific script without the extensions # this will create symbolic links in /usr/local/bin/ for specific scripts # so you can call it in any directories symlink() { if [ ! -h "/usr/local/bin/$1" ]; then ln -s "$(pwd)/$2""/usr/local/bin/$1" echo -e "${GREEN}symlink for $1 created.${NC}\n" else echo -e "${RED}symlink for $1 already exists.${NC}\n" fi }
symlink "linkfinder""LinkFinder/linkfinder.py" symlink "secretfinder""SecretFinder/SecretFinder.py" # separate line only # githubsearch python symlink "git-history""github-search/git-history.py" symlink "github-contributors""github-search/github-contributors.py" symlink "github-dorks""github-search/github-dorks.py" symlink "github-employees""github-search/github-employees.py" symlink "github-endpoints""github-search/github-endpoints.py" symlink "github-secrets""github-search/github-secrets.py" symlink "github-subdomains""github-search/github-subdomains.py" symlink "github-survey""github-search/github-survey.py" symlink "github-survey2""github-search/github-survey2.py" symlink "github-users""github-search/github-users.py" symlink "git-pillage""github-search/git-pillage.py" # # should be run as php <tool> command symlink "php-github-dorks""github-search/github-dorks.php" symlink "php-github-grabrepo""github-search/github-grabrepo.php" symlink "php-github-search""github-search/github-search.php" # # bash scripts symlink "sh-git-history""github-search/git-history.sh" symlink "sh-gsearch-reflog""github-search/gsearch-reflog.sh" symlink "sh-gsearch""github-search/gsearch.sh"
Finally, add more configuration to the .bashrc file:
1 2 3 4 5 6 7 8 9
# Add Go configuration/setup to .bashrc end line echo"" >> ~/.bashrc echo"# Go Configuration" >> ~/.bashrc echo'export GOPATH=$HOME/go-arsenal' >> ~/.bashrc echo'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc echo"" sleep 1
GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m'# No Color
# check if the script/tool is already exists in your linux instance script() { ifcommand -v "$1" &>/dev/null; then echo -e "${GREEN}$1 is already installed.${NC}" return 0 else return 1 fi }
# install the scripts if it doesn't exist arsenal_script() { script_title="$1" shift if ! script "$script_title"; then echo -e "${YELLOW}Installing $script_title...${NC}\n\n" "$@" if [ $? -eq 0 ]; then echo -e "${GREEN}$script_title has been installed.${NC}\n\n" else echo -e "${RED}Failed to install $script_title.${NC}\n\n" fi fi }
# Update your shits apt update -y
# Update your shits is something goes wrong apt update --fix-missing -y
# Remove existing Go installation and extract downloaded file --> this line is not working # tar -xvf go1.22.0.linux-amd64.tar.gz && mv go /usr/local && cd .. --> this line is not working
# this will create symbolic links in /usr/local/bin/ for specific scripts # so you can call it in any directories symlink() { if [ ! -h "/usr/local/bin/$1" ]; then ln -s "$(pwd)/$2""/usr/local/bin/$1" echo -e "${GREEN}symlink for $1 created.${NC}\n" else echo -e "${RED}symlink for $1 already exists.${NC}\n" fi }
# Create symlinks in /usr/local/bin/ for specific script without the extensions symlink "linkfinder""LinkFinder/linkfinder.py" symlink "secretfinder""SecretFinder/SecretFinder.py" # separate line only # githubsearch python symlink "git-history""github-search/git-history.py" symlink "github-contributors""github-search/github-contributors.py" symlink "github-dorks""github-search/github-dorks.py" symlink "github-employees""github-search/github-employees.py" symlink "github-endpoints""github-search/github-endpoints.py" symlink "github-secrets""github-search/github-secrets.py" symlink "github-subdomains""github-search/github-subdomains.py" symlink "github-survey""github-search/github-survey.py" symlink "github-survey2""github-search/github-survey2.py" symlink "github-users""github-search/github-users.py" symlink "git-pillage""github-search/git-pillage.py" # # should be run as php <tool> command symlink "php-github-dorks""github-search/github-dorks.php" symlink "php-github-grabrepo""github-search/github-grabrepo.php" symlink "php-github-search""github-search/github-search.php" # # bash scripts symlink "sh-git-history""github-search/git-history.sh" symlink "sh-gsearch-reflog""github-search/gsearch-reflog.sh" symlink "sh-gsearch""github-search/gsearch.sh"
# Add GRC configuration to your .bashrc echo"" >> ~/.bashrc echo"# GRC Configuration" >> ~/.bashrc echo'GRC=`which grc`' >> ~/.bashrc echo'if [ "$TERM" != dumb ] && [ -n "$GRC" ]' >> ~/.bashrc echo"then" >> ~/.bashrc echo' alias colourify="$GRC -es --colour=auto"' >> ~/.bashrc echo' alias configure="colourify ./configure"' >> ~/.bashrc echo' alias diff="colourify diff"' >> ~/.bashrc echo' alias make="colourify make"' >> ~/.bashrc echo' alias gcc="colourify gcc"' >> ~/.bashrc echo' alias g++="colourify g++"' >> ~/.bashrc echo' alias as="colourify as"' >> ~/.bashrc echo' alias gas="colourify gas"' >> ~/.bashrc echo' alias ld="colourify ld"' >> ~/.bashrc echo' alias netstat="colourify netstat"' >> ~/.bashrc echo' alias ping="colourify ping"' >> ~/.bashrc echo' alias traceroute="colourify /usr/sbin/traceroute"' >> ~/.bashrc echo' alias head="colourify head"' >> ~/.bashrc echo' alias tail="colourify tail"' >> ~/.bashrc echo' alias dig="colourify dig"' >> ~/.bashrc echo' alias mount="colourify mount"' >> ~/.bashrc echo' alias ps="colourify ps"' >> ~/.bashrc echo' alias mtr="colourify mtr"' >> ~/.bashrc echo' alias df="colourify df"' >> ~/.bashrc echo' alias nmap="grc nmap"' >> ~/.bashrc echo' alias id="grc id"' >> ~/.bashrc echo' alias whoami="colourify whoami"' >> ~/.bashrc echo' alias hostname="colourify hostname"' >> ~/.bashrc echo"fi" >> ~/.bashrc
# Add Go configuration/setup to .bashrc end line echo"" >> ~/.bashrc echo"# Go Configuration" >> ~/.bashrc echo'export GOPATH=$HOME/go-arsenal' >> ~/.bashrc echo'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc echo"" sleep 1