Add Bot Blocker - Apache User-Agent blocking manager

Features:
- Enable/disable bot blocking with one click
- Blocks security scanners (nikto, sqlmap, nmap, etc.)
- Blocks aggressive SEO bots (AhrefsBot, SemrushBot, etc.)
- Blocks AI crawlers (GPTBot, Claude-Web, ChatGPT-User, etc.)
- Blocks generic scrapers (Go-http-client, etc.)
- Automatic backups before changes
- Apache syntax validation before applying
- Safe restart with rollback on failure
- View current configuration
- Manage backups and restore

Configuration:
- File: /etc/apache2/conf.d/includes/pre_main_global.conf
- Blocks 24+ malicious bot user-agents
- Returns HTTP 403 Forbidden to blocked bots
- Zero impact on legitimate traffic

Integrated into Security Menu (option 16)
This commit is contained in:
cschantz
2026-01-22 19:24:02 -05:00
parent 5b8bea29a3
commit dd585493b8
2 changed files with 499 additions and 0 deletions
+2
View File
@@ -139,6 +139,7 @@ show_security_menu() {
echo ""
echo -e " ${YELLOW}13)${NC} 🔒 Enable cPHulk Protection - Brute force protection"
echo -e " ${YELLOW}14)${NC} ⚙️ Optimize CT_LIMIT - Connection tracking tuning"
echo -e " ${YELLOW}16)${NC} 🤖 Block Malicious Bots - User-Agent blocking (Apache)"
echo ""
echo -e "${BOLD}Analysis Tools:${NC}"
echo ""
@@ -171,6 +172,7 @@ handle_security_menu() {
13) run_module "security" "enable-cphulk.sh" ;;
14) run_module "security" "optimize-ct-limit.sh" ;;
15) bash "$BASE_DIR/tools/analyze-historical-attacks.sh" ;;
16) run_module "security" "bot-blocker.sh" ;;
0) return ;;
*) echo -e "${RED}Invalid option${NC}"; sleep 1 ;;
esac