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

This line will install GoLang.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

# 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 installs the necessary tools. You can add your own, just follow the instructions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

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

1
2
3
4
5
6
7

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

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

This line adds GRC configuration to your .bashrc file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

# 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

And this line adds symlinks for the tools you installed. Add your own as needed:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

# 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

Here is the full script code:

install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214

#!/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 afterward. :)