-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecurityLab1.2.sh
More file actions
122 lines (102 loc) · 4.35 KB
/
Copy pathSecurityLab1.2.sh
File metadata and controls
122 lines (102 loc) · 4.35 KB
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
#!/bin/bash
# Author: Peter Mwangi Ngugi
# This is a bash script program to install a Security lab on Fedora OS
# Ensure script is run with superuser privileges for required steps
if [ "$EUID" -ne 0 ]; then
echo "Please run as root or use sudo for package installations."
exit 1
fi
# Trap to handle script interruption
trap "echo 'Script interrupted. Cleaning up...'; exit 1" SIGINT SIGTERM
# Log file for recording errors
LOGFILE="/var/log/security_lab_install.log"
echo "Starting installation..." | tee -a "$LOGFILE"
echo "Installation started at $(date)" | tee -a "$LOGFILE"
# Update system packages
echo "Updating system..." | tee -a "$LOGFILE"
dnf update -y >> "$LOGFILE" 2>&1
if [ $? -ne 0 ]; then
echo "System update failed. Check $LOGFILE for details." | tee -a "$LOGFILE"
exit 1
fi
# Function to install a package
install_package() {
local package=$1
local description=$2
echo "Installing $package: $description" | tee -a "$LOGFILE"
if dnf install -y "$package" >> "$LOGFILE" 2>&1; then
echo "$package installed successfully." | tee -a "$LOGFILE"
else
echo "Error installing $package. Check $LOGFILE for details." | tee -a "$LOGFILE"
exit 1
fi
}
# Install necessary security tools
echo "Installing security packages..." | tee -a "$LOGFILE"
declare -A PACKAGES=(
[etherape]="Graphical network monitor"
[ettercap]="Suite for man-in-the-middle attacks"
[wireshark]="Network traffic analyzer"
[medusa]="Login brute-forcer"
[nmap]="Network discovery and security auditing tool"
[scap-workbench]="SCAP scanner with GUI"
[skipfish]="Active web application security reconnaissance tool"
[sqlninja]="SQL Injection vulnerability testing tool"
[yersinia]="Exploit weaknesses in network protocols"
[hydra]="Login cracker supporting various protocols"
[aircrack-ng]="Wireless network security toolset"
[john]="Password cracker"
[nikto]="Web server scanner"
[ncrack]="Network authentication cracker"
[burpsuite]="Web vulnerability scanning tool"
[hashcat]="GPU-based password cracking tool"
[lynis]="Security auditing tool"
[tcpdump]="Network packet analyzer"
[gobuster]="Brute-forcer for directories, files, and DNS subdomains"
[openvas]="Vulnerability scanner"
)
# Loop through packages and install each one
for package in "${!PACKAGES[@]}"; do
install_package "$package" "${PACKAGES[$package]}"
done
# Install additional dependencies for pwntools
echo "Installing additional dependencies for pwntools..." | tee -a "$LOGFILE"
dnf install -y python3 python3-pip python3-devel git openssl-devel libffi-devel make gcc >> "$LOGFILE" 2>&1
if [ $? -ne 0 ]; then
echo "Failed to install dependencies. Check $LOGFILE for details." | tee -a "$LOGFILE"
exit 1
fi
# Upgrade pip and install pwntools
python3 -m pip install --upgrade pip >> "$LOGFILE" 2>&1
python3 -m pip install --upgrade pwntools >> "$LOGFILE" 2>&1
if [ $? -ne 0 ]; then
echo "Failed to install pwntools. Check $LOGFILE for details." | tee -a "$LOGFILE"
exit 1
fi
# ---- METASPLOIT INSTALLATION WITHOUT ROOT ISSUES ----
# Install Metasploit using the Metasploit installer
echo "Installing Metasploit..." | tee -a "$LOGFILE"
METASPLOIT_INSTALLER_URL="https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate"
curl -sSL "$METASPLOIT_INSTALLER_URL" | bash >> "$LOGFILE" 2>&1
if [ $? -ne 0 ]; then
echo "Failed to install Metasploit. Check $LOGFILE for details." | tee -a "$LOGFILE"
exit 1
fi
# Set up Metasploit database as a non-root user
echo "Setting up Metasploit database..." | tee -a "$LOGFILE"
if sudo -u "$SUDO_USER" msfdb init >> "$LOGFILE" 2>&1; then
echo "Metasploit database initialized successfully." | tee -a "$LOGFILE"
else
echo "Failed to initialize Metasploit database. Check $LOGFILE for details." | tee -a "$LOGFILE"
exit 1
fi
# Post-installation configuration for Wireshark
echo "Configuring Wireshark..." | tee -a "$LOGFILE"
if usermod -aG wireshark "$SUDO_USER" >> "$LOGFILE" 2>&1; then
echo "Wireshark configured successfully. Please log out and log back in for group changes to take effect." | tee -a "$LOGFILE"
else
echo "Failed to configure Wireshark. Check $LOGFILE for details." | tee -a "$LOGFILE"
fi
echo "All installations and configurations are complete. Check $LOGFILE for any errors." | tee -a "$LOGFILE"
echo "Installation completed at $(date)" | tee -a "$LOGFILE"
# End of script