New Kali Instance 🍥

Automate Installing your Tools in new Kali Environment

Debian-Logo

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 do we even install a new one when we could just update our existing machine?

Cleaner, Faster Performance

  • Lightweight and Efficient: Linux, especially in its minimal installation form (like using Ubuntu Server, CentOS, or Debian), doesn’t come with unnecessary bloatware, making it faster and more resource-efficient.
  • Optimized for Performance: It offers high performance in both server and desktop environments, with the ability to fine-tune system resources as needed.
  • No Legacy Issues: Over time, as an operating system is updated, old configuration files, libraries, and outdated dependencies can accumulate. A fresh install provides a clean slate, removing unnecessary legacy files and processes that might slow down your system.

Security

  • Updated Patches: New installations come with the latest security patches, which means your system is up to date with the latest security improvements and bug fixes.
  • No Accumulated Vulnerabilities: Sometimes, when updating an existing system, critical updates may be missed, delayed, or improperly applied. With a clean installation, you ensure that 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 will include the latest versions of software and libraries, ensuring you are running the most recent features and improvements. This contrasts with updating an old system, where you might encounter limitations on some outdated packages.
  • Cleaner Software Repositories: Fresh installations pull from up-to-date, clean software repositories, ensuring all installed packages are the latest, 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 that 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 with tools like LVM (Logical Volume Management) or use more advanced filesystems 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 problems when newer versions of packages are installed. A clean installation starts with the correct configuration files that are designed for the newest versions of software.

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 the tools you use from your old environment to a newly installed Linux can be boring and time-consuming. Also, it’s like you can’t remember all the tools you use — you only recall them when you actually need to use them.

That’s why I created a simple bash script that automatically installs the tools from your old machine. This script is quite simple and you can modify it based on your needs.

Make sure you are on sh session before running this script. Default Kali session is running on zsh

chmod +x automate.sh

Scripts Breakdown

this line will check the tools are already installed on the machine:


# 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


# Update your shits
apt update -y

# Update your shits is something goes wrong
apt update --fix-missing -y

this line will install GoLang


# remove pre-installed golang
rm -rf /usr/local/go
sleep 1

rm -rf /usr/bin/go
sleep 1

apt remove --purge golang-go -y
sleep 1

apt autoclean -y
sleep 1

apt autoremove -y
sleep 1

# Navigate to Downloads directory
apt install gccgo-go -y
sleep 1

apt install golang-go -y
sleep 1

# Download Golang
# wget https://go.dev/dl/go1.22.5.linux-amd64.tar.gz
# sleep 1

# rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
# sleep 2

# 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

echo ""
sleep 1

echo -e "${GREEN}Golang installed successfully.${NC}"
sleep 1

This line will install the tools you need. You can add yours, just follow the instruction:


# 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 will install GRC (generic colouriser). which acts as a filter, i.e. taking standard input, colourising it and writing to standard output.


# Install GRC
arsenal_script "grc" apt install grc -y

# Install libpcap-dev
arsenal_script "libpcap-dev" apt install -y libpcap-dev

and this line will add GRC configuration on your [.bashrc] file


# 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


# 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 in [.bashrc] file:


# 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

Heres the full script code:


#!/bin/bash

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() {
if command -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 pre-installed golang
rm -rf /usr/local/go
sleep 1

rm -rf /usr/bin/go
sleep 1

apt remove --purge golang-go -y
sleep 1

apt autoclean -y
sleep 1

apt autoremove -y
sleep 1

# Navigate to Downloads directory
apt install gccgo-go -y
sleep 1

apt install golang-go -y
sleep 1

# Download Golang
# wget https://go.dev/dl/go1.22.5.linux-amd64.tar.gz
# sleep 1

# rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
# sleep 2

# 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

echo ""
sleep 1

echo -e "${GREEN}Golang installed successfully.${NC}"
sleep 1


# 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:

# Install GRC
arsenal_script "grc" apt install grc -y

# Install libpcap-dev
arsenal_script "libpcap-dev" apt install -y libpcap-dev

# 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

export GOPATH=$HOME/go-arsenal
sleep 1

export PATH=$PATH:$GOPATH/bin
sleep 1

# reload .bashrc
source ~/.bashrc
sleep 1

source ~/.profile
sleep 1

echo ""
echo -e "${GREEN} Golang environment variables set.${NC}"
sleep 2

echo ""
echo -e "${GREEN} Installation complete.${NC}"
sleep 1

echo ""
echo -e "${GREEN} Please reboot your machine. ${NC}"

echo ""
echo -e "${GREEN} don't forget to paste this in your terminal after. ${NC}"

echo ""
echo -e 'export PATH=$PATH:/usr/local/go/bin'


Don’t forget to restart your machine after. ;)