From 0a324bcce934bd4def29fda912d1211f9495becf Mon Sep 17 00:00:00 2001 From: InfoSec211 <55150298+InfoSec211@users.noreply.github.com> Date: Sat, 1 Mar 2025 13:42:38 -0600 Subject: [PATCH 1/2] Update unit4_project.sh --- Scripts/unit4_project.sh | 51 ++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/Scripts/unit4_project.sh b/Scripts/unit4_project.sh index f8cdab2..cd25996 100644 --- a/Scripts/unit4_project.sh +++ b/Scripts/unit4_project.sh @@ -1,50 +1,45 @@ #!/bin/bash +set -e # Exit on any error + red='\033[0;31m' green='\033[0;32m' none='\033[0m' echo "[UNIT 4 PROJECT] Starting script..." -# Are pip3 and Slowloris already installed? +# Check if Slowloris is already installed if command -v pip3 &> /dev/null; then - if pip3 freeze | grep -iq "Slowloris" ; then - echo -e "${green}[UNIT 4 PROJECT]${none} Slowloris already installed." + if pip3 show slowloris &> /dev/null; then + echo -e "${green}[UNIT 4 PROJECT]${none} Slowloris is already installed." exit 0 fi fi -echo "The slowloris library is installed." - -# Install curl, gnupg2, ca-certificates, lsb-release, and ubuntu-keyring -sudo apt install -y curl gnupg2 ca-certificates lsb-release ubuntu-keyring - -# Import NGINX signing key -curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null - -# Add NGINX to sources list -echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list - -# Pin NGINX packages -echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | sudo tee /etc/apt/preferences.d/99nginx - # Update package lists +echo "[UNIT 4 PROJECT] Updating package lists..." sudo apt update +# Install dependencies +echo "[UNIT 4 PROJECT] Installing required dependencies..." +sudo apt install -y curl gnupg2 ca-certificates lsb-release ubuntu-keyring python3-pip + # Install NGINX +echo "[UNIT 4 PROJECT] Installing NGINX..." +curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null +echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list +echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | sudo tee /etc/apt/preferences.d/99nginx +sudo apt update sudo apt install -y nginx -# Install Python -sudo apt install -y python3-pip - # Install Slowloris +echo "[UNIT 4 PROJECT] Installing Slowloris..." sudo pip3 install slowloris -# Did pip3 and Slowloris install? -if command -v pip3 &> /dev/null; then - if pip3 freeze | grep -i "Slowloris" ; then - echo -e "${green}[UNIT 4 PROJECT]${none} Slowloris successfully installed." - exit 0 - fi +# Verify installation +if pip3 show slowloris &> /dev/null; then + echo -e "${green}[UNIT 4 PROJECT]${none} Slowloris successfully installed." + exit 0 +else + echo -e "${red}[UNIT 4 PROJECT]${none} ERROR: Slowloris did not install correctly!" + exit 1 fi -echo -e "${red}[UNIT 4 PROJECT]${none} ERROR: Slowloris did not install correctly!" -exit 1 \ No newline at end of file From a94783270752ebb1565a970f817e6b574403b5b3 Mon Sep 17 00:00:00 2001 From: InfoSec211 <55150298+InfoSec211@users.noreply.github.com> Date: Sat, 1 Mar 2025 13:47:10 -0600 Subject: [PATCH 2/2] Update unit4_project.sh --- Scripts/unit4_project.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Scripts/unit4_project.sh b/Scripts/unit4_project.sh index cd25996..f9821a2 100644 --- a/Scripts/unit4_project.sh +++ b/Scripts/unit4_project.sh @@ -32,8 +32,9 @@ sudo apt update sudo apt install -y nginx # Install Slowloris +# TODO: For CodePath (Will this break the system if installed)-Otherwise slowloris won't install properly echo "[UNIT 4 PROJECT] Installing Slowloris..." -sudo pip3 install slowloris +sudo pip3 install --break-system-packages slowloris # Verify installation if pip3 show slowloris &> /dev/null; then