-
Notifications
You must be signed in to change notification settings - Fork 0
/
PentestBoxSetup.sh
executable file
·131 lines (108 loc) · 5.62 KB
/
PentestBoxSetup.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
#!/bin/bash
# MIT License
#
# Copyright (c) 2023 Anthony Hanel
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# This script installs various tools for a Linux-based penetration testing environment.
# Function to handle errors
error_handling() {
echo "Error: $1"
exit 1
}
# Check if the script is running with root privileges
if [ "$EUID" -ne 0 ]; then
echo "This script requires root privileges. Please run with sudo."
exit 1
fi
# Update package lists
sudo apt update -y || error_handling "Failed to update package lists"
# Install necessary software
sudo apt install -y software-properties-common apt-transport-https wget || error_handling "Failed to install required packages"
# Install Visual Studio Code
if ! command -v code &> /dev/null; then
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - || error_handling "Failed to add Microsoft repository key"
sudo add-apt-repository -y "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" || error_handling "Failed to add Visual Studio Code repository"
sudo apt install -y code || error_handling "Failed to install Visual Studio Code"
fi
# Install various penetration testing tools and dependencies
penetration_tools=("seclists" "curl" "enum4linux" "feroxbuster" "impacket-scripts" "nbtscan" "nikto" "nmap" "onesixtyone" "oscanner" "redis-tools" "smbclient" "smbmap" "snmp" "sslscan" "sipvicious" "tnscmd10g" "whatweb" "wkhtmltopdf" "snap" "snapd" "python3-pip" "gobuster" "npm")
sudo apt install -y "${penetration_tools[@]}" || error_handling "Failed to install penetration testing tools"
# Remove unused packages
sudo apt autoremove -y || error_handling "Failed to remove unused packages"
# Check and configure snapd service
if ! systemctl is-active --quiet snapd.service; then
sudo systemctl start snapd.service || error_handling "Failed to start snapd.service"
sudo systemctl enable snapd.service || error_handling "Failed to enable snapd.service"
sudo systemctl enable --now snapd apparmor || error_handling "Failed to enable snapd apparmor"
fi
# Add snap and local bin directories to PATH
if [[ ":$PATH:" != *":/snap/bin:"* ]]; then
echo "export PATH=\"/snap/bin:$PATH\"" | sudo tee -a /etc/environment
fi
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo "export PATH=\"\$HOME/.local/bin:\$PATH\"" >> "$HOME/.zshrc"
fi
# Install jwt-cracker
if ! command -v jwt-cracker &> /dev/null; then
npm install --global jwt-cracker || error_handling "Failed to install jwt-cracker"
fi
# Uncompress rockyou.txt wordlist
if [ ! -f /usr/share/wordlists/rockyou.txt ]; then
sudo gzip -d /usr/share/wordlists/rockyou.txt.gz || error_handling "Failed to uncompress rockyou.txt"
fi
# Install AutoRecon
if [ ! -d /opt/AutoRecon ]; then
sudo git clone "https://github.com/Tib3rius/AutoRecon.git" /opt/AutoRecon || error_handling "Failed to clone AutoRecon repository"
python3 -m pip install -r /opt/AutoRecon/requirements.txt || error_handling "Failed to install AutoRecon dependencies"
fi
# Install Impacket
if [ ! -d /opt/impacket ]; then
sudo git clone "https://github.com/SecureAuthCorp/impacket.git" /opt/impacket || error_handling "Failed to clone Impacket repository"
python3 -m pip install -r /opt/impacket/requirements.txt || error_handling "Failed to install Impacket dependencies"
fi
# Install Kerbrute
if [ ! -f /opt/kerbrute ]; then
sudo wget -O /opt/kerbrute "https://github.com/ropnop/kerbrute/releases/download/v1.0.3/kerbrute_linux_amd64" || error_handling "Failed to download Kerbrute binary"
sudo chmod +x /opt/kerbrute || error_handling "Failed to make Kerbrute executable"
fi
# Install GitTools
if [ ! -d /opt/GitTools ]; then
sudo git clone "https://github.com/internetwache/GitTools.git" /opt/GitTools || error_handling "Failed to clone GitTools repository"
fi
# Install git-dumper
if [ ! -d /opt/git-dumper ]; then
sudo git clone "https://github.com/arthaud/git-dumper.git" /opt/git-dumper || error_handling "Failed to clone git-dumper repository"
fi
# Add bash aliases to .zshrc if not already present
# Get the script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
# Read aliases from the bash_aliases file
if [ -f "${SCRIPT_DIR}/bash_aliases" ]; then
while IFS= read -r alias_entry; do
if ! grep -q "$alias_entry" "$HOME/.zshrc"; then
echo "alias $alias_entry" >> "$HOME/.zshrc"
fi
done < "${SCRIPT_DIR}/bash_aliases"
else
echo "Error: bash_aliases file not found in the script directory"
exit 1
fi
# Update, upgrade, and clean up packages
sudo apt update && sudo apt autoremove -y || error_handling "Failed to update or remove packages"