49 Commits

Author SHA1 Message Date
cschantz 3126944905 Reapply "CRITICAL FIXES: Apply essential improvements from beta branch to production"
This reverts commit e5979a501e.
2026-03-20 15:45:24 -04:00
cschantz e5979a501e Revert "CRITICAL FIXES: Apply essential improvements from beta branch to production"
This reverts commit eabddb553d.
2026-03-19 21:03:11 -04:00
cschantz eabddb553d CRITICAL FIXES: Apply essential improvements from beta branch to production
CRITICAL FIXES:
1. Add missing initialize_system_detection() call (launcher.sh)
   - System detection was never initialized before building reference database
   - This caused all SYS_* variables to be empty
   - Fixed blank system detection output issue reported on Alma 8

2. Fix all unsafe read statements (launcher.sh - 10+ occurrences)
   - Changed all 'read -r choice' to use /dev/tty with error handling
   - Prevents crashes when stdin is piped (curl | bash)
   - Prevents unexpected SSH session termination
   - Gracefully returns instead of exiting

3. Fix remaining read -p statements (launcher.sh)
   - Added </dev/tty and error suppression to startup and exit prompts
   - Prevents hangs when terminal not available

SECURITY FIXES:
4. Fix SQL injection in database queries (reference-db.sh)
   - Escape database names with backticks: WHERE table_schema=`$db`
   - Prevents malicious database names from breaking SQL

5. Fix password exposure in process listings (reference-db.sh)
   - Use MYSQL_PWD environment variable instead of command line
   - Credentials no longer visible in ps aux output
   - Added cleanup with unset MYSQL_PWD

6. Fix race condition in temp directory creation (common-functions.sh)
   - Changed from mkdir -p to mktemp -d
   - Secure permissions (0700) and unpredictable naming
   - Prevents TOCTOU attacks

All changes validated with bash -n syntax checks
Production launcher now matches/exceeds beta stability
2026-03-19 20:50:28 -04:00
cschantz e53ea6f866 Add Website Slowness Diagnostics - Multi-framework analysis tool
Features:
- Support for 8 frameworks: WordPress, Drupal, Joomla, Magento, Laravel, Node.js, Static HTML, Custom PHP
- Auto-detect framework and perform framework-specific analysis
- 40+ slowness indicators across database, configuration, resources, performance
- Comprehensive diagnostics: database optimization, table fragmentation, indexes, PHP config
- Resource analysis: swap usage, I/O performance, process saturation, file descriptors
- Domain-specific analysis with no server-wide impact
- Handles custom WordPress table prefixes automatically
- Graceful error handling for users without shell access
- Domain input sanitization (accepts https://www.example.com, etc.)
- Temp file management with automatic cleanup
- Production-ready with full testing

Fixes applied:
- Fixed temp session initialization using exported variables
- Fixed database credential extraction with proper grep/awk
- Added automatic WordPress table prefix detection
- Added proper error handling for shell-less cPanel users
- Removed problematic progress display calls
- Added domain input sanitization for better UX

Added to menu:
- Main Website Diagnostics menu (Option 3)
- Not limited to WordPress, supports all frameworks

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-26 17:31:06 -05:00
cschantz 701bc76de1 Fix: Move Historical Attack Analysis to Threat Analysis menu
Issue: Historical Attack Analysis was in its own "System Diagnostics"
category with only one tool, but it's actually threat analysis.

Changes:
- Added Historical Attack Analysis to Threat Analysis menu (option 6)
- Removed System Diagnostics sub-menu entirely (both functions)
- Updated main security menu from 5 to 4 categories
- Removed option 5 and its handler

New Structure:
Main Security Menu (4 categories):
  1) Threat Analysis (6 tools) ← Historical Attack Analysis moved here
  2) Live Monitoring (4 tools)
  3) Log Viewers (4 tools)
  4) Security Actions (3 tools)

Benefits:
- More logical grouping - analyzing attacks is threat analysis
- No orphan category with only one tool
- Cleaner main menu (4 options vs 5)

Code Changes:
- Added: +2 lines (option 6 in show/handle)
- Removed: -30 lines (System Diagnostics menu)
- Net: -28 lines

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 20:50:48 -05:00
cschantz 55c50614e0 Reorganize Security & Monitoring menu with sub-menus
Issue: Security menu had 17 flat options, hard to navigate

New Structure:
Main Security Menu now has 5 organized categories:
1) 📊 Threat Analysis (5 tools)
   - Bot & Traffic Analyzer (full + quick scan)
   - IP Reputation Manager
   - Suspicious Login Monitor
   - Malware Scanner

2) 🔴 Live Monitoring (4 tools)
   - Live Attack Monitor
   - SSH Attack Monitor
   - Web Traffic Monitor
   - Firewall Activity Monitor

3) 📋 Log Viewers (4 tools)
   - Apache Access/Error logs
   - Mail log
   - Security log

4) 🔒 Security Actions (3 tools)
   - Enable cPHulk
   - Optimize CT_LIMIT
   - Block Malicious Bots

5) 🛠️  System Diagnostics (1 tool)
   - Historical Attack Analysis

Implementation:
- Added 5 sub-menu show/handle function pairs (10 functions)
- Simplified main security menu to 5 category options
- Maintained all existing module paths (no breaking changes)
- Total: +163 lines, -39 lines (net +124 lines)

Benefits:
- Easier navigation - fewer options per screen
- Logical grouping - related tools together
- Scalable - easy to add new tools to categories
- Clearer purpose - category names show intent

Testing:
✓ Syntax validated
✓ All function calls preserved
✓ Navigation flow: Main → Category → Tool → Back

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 20:39:35 -05:00
cschantz 7638b76f9d Add suspicious login monitor to security menu
Added suspicious login monitor to Security & Monitoring menu as option 17.

LOCATION:
  Main Menu → Security & Monitoring (2) → Suspicious Login Monitor (17)

MENU TEXT:
  🔐 Suspicious Login Monitor - SSH/Panel login analysis

FUNCTION:
  - Analyzes SSH, wtmp, btmp, sudo logs
  - Parses cPanel/Plesk/InterWorx panel logins
  - 95%+ log coverage
  - Integrated with bot-analyzer, IP reputation, threat intelligence
  - Auto-blocks critical threats
  - Triggers rkhunter scans

USAGE:
  bash launcher.sh
  → Select 2 (Security & Monitoring)
  → Select 17 (Suspicious Login Monitor)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 00:23:54 -05:00
cschantz c962fe56e7 Add Cloudflare Domain Detector with datacenter location
Features:
- Scan all domains on server for Cloudflare usage
- Check single domain with detailed analysis
- Detects Cloudflare via: nameservers, IP ranges, HTTP headers
- Shows Cloudflare datacenter location (IATA code from CF-RAY)
- Useful for debugging regional outages and cache issues

Detection Methods:
1. Nameserver check (*.cloudflare.com)
2. IP address check (Cloudflare IP ranges)
3. HTTP header check (CF-RAY, Server: cloudflare)
4. Datacenter location extraction (e.g., ORD, LAX, LHR)

Output shows:
- Domains using Cloudflare [with datacenter code]
- Domains NOT using Cloudflare
- Unknown/uncertain domains

Integrated into Website Diagnostics Menu (option 4)

Example output:
  ✓ pickledperil.com                                [BNA]
  • example.com
2026-01-27 17:37:55 -05:00
cschantz dd585493b8 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)
2026-01-22 19:24:02 -05:00
cschantz 849a112b5c Add Nginx + Varnish Cache Manager with complete cPanel integration
New Features:
- Full Varnish 6.6+ installation and configuration for cPanel servers
- 99.5% stock compliance using settings.json approach (RPM-safe)
- Complete HTTPS caching via SSL termination and config-script automation
- Two-tier revert system (partial/full stack removal)
- Enhanced status display with mode detection and color-coded port status
- Self-healing diagnostics with 8 automatic fixes
- Host header preservation fix for multi-domain WordPress compatibility

Technical Details:
- Supports ea-nginx + Varnish + Apache stack on AlmaLinux 9+
- Caches 93 static file types with smart bypasses for cPanel services
- Config-script ensures HTTPS traffic uses HTTP backend to Varnish
- Adaptive detection handles partial states and manual interventions

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-21 18:53:04 -05:00
cschantz f47a164124 Add Email Diagnostics tool - verify if email/domain is working
Features:
- Check specific email address or entire domain
- Shows if emails are working with PROOF
- Displays recent activity with timestamps highlighted
- Categorizes: delivered, bounced, rejected, deferred
- Shows last 5 examples of each type from selected time period
- Clear verdict: Working / Partially Working / Has Problems
- Extracts bounce reasons and recommendations
- Saves full report for customer evidence

Usage: Email menu → Option 1 (Email Diagnostics)
Perfect for: 'Customer says they're not receiving emails'

Example output:
 EMAIL IS WORKING PROPERLY
Evidence: 15 successful deliveries in last 24 hours
PROOF - Recent deliveries with timestamps shown below
2025-12-31 18:38:10 -05:00
cschantz 4b47a4388d Add email-functions.sh library + menu cleanup
- Add lib/email-functions.sh (email helper functions)
- Remove live-attack-monitor-v2 from security menu (not ready)
- Renumber security menu options
2025-12-31 18:22:08 -05:00
cschantz 65c523f005 CORRECTED FIX: Properly handle SYS_USER_HOME_BASE initialization
Previous attempt (commit 9b0a145) moved ALL variable exports inside the
conditional, which broke the script because variables weren't initialized
on subsequent runs after SYS_DETECTION_COMPLETE was set.

The CORRECT Fix:
Move SYS_USER_HOME_BASE and other session variables INSIDE the conditional
so they're only initialized ONCE, not reset every time system-detect.sh
is sourced.

Changes:
1. lib/system-detect.sh (lines 26-32):
   - Moved SYS_USER_HOME_BASE="" inside conditional
   - Moved SYS_PHP_VERSIONS=() inside conditional
   - Moved firewall variables inside conditional
   - Now all exports only run when SYS_DETECTION_COMPLETE is empty

2. launcher.sh (line 22):
   - Re-added: source "$LIB_DIR/domain-discovery.sh"
   - Lost when reverting broken commit

Impact:
- Fixes Plesk: SYS_USER_HOME_BASE="/var/www/vhosts" persists
- Fixes cPanel: launcher completes successfully and shows menu
- list_all_domains() and all unified functions now available

Tested on cPanel:  WORKING
Ready for Plesk testing
2025-12-23 21:14:23 -05:00
cschantz c1f2f6868d Add comprehensive Plesk control panel support
Core Infrastructure Added:
- lib/plesk-helpers.sh: 30+ Plesk-specific helper functions
  - Domain discovery (list, docroot, logdir, access/error logs)
  - User/subscription management
  - Database discovery
  - PHP version detection (/opt/plesk/php/)
  - PHP-FPM pool discovery
  - Configuration file locations
  - Mail functions
  - Service management
  - Version detection with log structure handling

- lib/domain-discovery.sh: Unified control panel abstraction
  - Consistent API across cPanel, Plesk, InterWorx, standalone
  - list_all_domains() - works on any panel
  - get_domain_docroot() - panel-agnostic document root
  - get_domain_logdir() - panel-agnostic log discovery
  - get_domain_access_log() - access log paths
  - get_domain_error_log() - error log paths
  - get_all_log_files() - all logs across all domains
  - get_domain_owner() - domain owner/user
  - list_all_users() - user enumeration
  - get_domain_fpm_socket() - PHP-FPM pool sockets
  - get_domain_databases() - database discovery
  - domain_exists() - existence checks

Documentation:
- PLESK_REFERENCE.md: Complete Plesk architecture reference
  - Directory structure mapping
  - Log file locations (current & future versions)
  - PHP-FPM pool locations
  - Configuration file paths
  - Plesk CLI command reference
  - Key differences from cPanel
  - Subdomain handling differences

- PLESK_SUPPORT_SUMMARY.md: Implementation summary
  - All functions documented
  - Usage examples
  - Migration guide for existing modules
  - Version compatibility notes
  - Testing checklist

System Detection Enhanced:
- lib/system-detect.sh:
  - Improved Plesk detection with version-aware log paths
  - Auto-sources plesk-helpers.sh when Plesk detected
  - Added /opt/plesk/php/ scanning for PHP versions
  - Sets SYS_USER_HOME_BASE=/var/www/vhosts for Plesk

Email Menu Added:
- launcher.sh: New Email Troubleshooting menu category
  - 9 email diagnostic/maintenance tools (placeholders)
  - Deliverability test, queue inspector, SMTP test
  - SPF/DKIM/DMARC check, blacklist check
  - Mail log analyzer, queue flush
  - Mailbox cleanup, size reports

Plesk Architecture Support:
- /var/www/vhosts/ base directory structure
- system/DOMAIN/logs/ for Plesk <18.0.50
- DOMAIN/logs/ for Plesk 18.0.50+
- Automatic version detection
- Subdomain separate directory handling
- /opt/plesk/php/X.Y/ PHP version detection
- /var/www/vhosts/system/DOMAIN/php-fpm.sock pools
- /var/www/vhosts/system/DOMAIN/conf/ configs

Fallback Mechanisms:
- All functions work with or without Plesk CLI
- Directory scanning fallbacks
- MySQL direct query fallbacks
- Path inference from standard locations

Status: Core infrastructure complete, ready for module integration
Next: Test on actual Plesk server, update existing modules

Ref: system_map.tsv analysis from Plesk production system
2025-12-23 20:20:09 -05:00
cschantz 75f28b9117 Rename Performance Analysis to Performance & Maintenance
The menu now includes both performance analysis tools (MySQL Query
Analyzer, Network & Bandwidth, Hardware Health, PHP Optimizer) and
system maintenance tools (Disk Space Analyzer, Loadwatch).

Changes:
- Main menu: "Performance Analysis" → "Performance & Maintenance"
- Submenu title: "🔧 Performance Analysis" → "🔧 Performance & Maintenance"

This better reflects the dual purpose of the menu category.
2025-12-17 19:28:34 -05:00
cschantz e8aae4249a Move Disk Space Analyzer to Performance Analysis menu
The Disk Space Analyzer is a performance/system health tool, not a
backup tool. Moving it to the Performance Analysis menu makes more
logical sense for users looking for system diagnostics.

Changes:
- Removed from Backup & Recovery → Maintenance section (was option 4)
- Added to Performance Analysis → System Health section (option 6)
- Updated both show_performance_menu() and handle_performance_menu()
- Removed from show_backup_menu() and handle_backup_menu()

New Location:
Main Menu → 4) Performance Analysis → 6) Disk Space Analyzer

This groups it with other system health tools like:
- Loadwatch Health Analyzer
- Hardware Health Check
- Network & Bandwidth analysis
2025-12-17 19:28:02 -05:00
cschantz 5c4c733e47 Add comprehensive disk space analyzer to toolkit
New Feature: WinDirStat-like disk space analyzer for Linux
Location: modules/maintenance/disk-space-analyzer.sh
Menu: Backup & Recovery → Maintenance (option 4)

Key Features:
- 14 different analysis and cleanup options
- Inode usage monitoring (critical for detecting inode exhaustion)
- No external dependencies (bc removed, using awk for math)
- Multi-panel support (cPanel/Plesk/InterWorx)
- Interactive drill-down capability
- Preview before deletion for all cleanup operations

Analysis Types:
1. Disk usage overview with warnings (>90% critical, >75% warning)
2. Inode usage checking (often overlooked but critical)
3. Largest directories with drill-down capability
4. Largest files with type detection (log/db/archive/video/image)
5. Old log files analysis (>30 days with size totals)
6. Temporary files finder (/tmp, /var/tmp with age detection)
7. Package manager cache (yum/dnf/apt)
8. Email storage analysis (mail spools, Maildir, Maildrop)
9. Database storage (MySQL/MariaDB, PostgreSQL data dirs)
10. Backup files finder (.bak, .tar.gz, .sql with age)
11. WordPress analysis (uploads, plugins, cache by site)
12. Report generation (exports all analysis to timestamped file)

Cleanup Operations (all with preview):
13. Clean old log files (>30 days, shows preview, requires "yes")
14. Clean package cache (yum/dnf/apt, requires "yes")
15. Clean WordPress cache (per-site WP Super Cache cleanup)

Technical Improvements:
- size_to_bytes() function for human-readable to bytes conversion
- Uses awk for all floating point math (no bc dependency)
- Excludes system dirs (/proc, /sys, /dev, /run) for faster scans
- Format functions for consistent output (bytes/KB/MB/GB/TB)
- Age detection for files (shows days old)
- File type detection by extension
- Interactive menus with color coding

Safety Features:
- Dry-run preview before all deletions
- Confirmation prompts ("yes" required, not just "y")
- Size calculations shown before deletion
- First 10 files previewed in cleanup operations

Changes to launcher.sh:
- Added option 4 to Backup & Recovery menu
- Added case handler to run disk-space-analyzer.sh
- Menu text: "💿 Disk Space Analyzer - Find space issues & cleanup files"

Testing: Script is executable and ready to use
2025-12-17 19:25:58 -05:00
cschantz a248470392 Cache system detection across module runs for instant launches
Removed subshell isolation that was unsetting SYS_ variables before each
module run. This caused full system re-detection (~530ms) every time a
module launched from the menu.

Changes:
- Removed: Subshell + SYS_ variable unsetting (lines 63-68)
- Now: Direct module execution with cached detection

Benefits:
- Module launches: ~530ms faster (instant after first detection)
- No redundant detection on every menu selection
- Detection only runs once per toolkit session
- Modules still get fresh detection if they explicitly call detect functions

Result: Modules now launch instantly instead of having 0.5s delay
2025-12-16 20:18:06 -05:00
cschantz 29fd2186c8 Delete unneeded fules and add info 2025-12-15 21:54:44 -05:00
cschantz c5d72d6d91 Fix historical attack analyzer path in launcher
Changed $SCRIPT_DIR to $BASE_DIR (correct variable name in launcher.sh)
Now option 15 properly launches: /root/server-toolkit/tools/analyze-historical-attacks.sh
2025-12-13 02:23:14 -05:00
cschantz 1f8e3e2ca8 Add IP reputation tracking for ET Open detections + historical analyzer to menu
IP Reputation Tracking:
- ET attack scores now properly boost IP threat scores
- When ET detects attack (score 85-100), adds to IP's cumulative score
- Example: IP at score 50 + ET attack 95 = total 100 (capped)
- Tracks across multiple requests from same IP
- Higher scores = faster blocking/banning

How it works:
1. ET detection runs: analyze_http_log_line() returns score
2. Score added to IP's existing threat score in IP_DATA array
3. Display shows boosted score
4. Auto-block triggers at combined score ≥90

Menu Integration:
- Added option 15 to Security menu
- 🛡️ Historical Attack Analysis - Scan past logs for attacks (ET Open)
- Launches: tools/analyze-historical-attacks.sh
- Features:
  - Scan last 7/30/custom days
  - Analyze specific log files
  - Generate comprehensive reports
  - Top attackers, signatures, attack types
  - Supports compressed logs (gzip, bzip2)

Testing:
 Syntax validated
 Tracking logic verified (50 + 95 = 100)
 Menu navigation works
 Historical analyzer accessible

Now when IPs attack repeatedly:
- First attack: Score increases by attack severity
- Subsequent attacks: Scores accumulate
- Persistent attackers: Reach blocking threshold faster
- Dashboard shows current cumulative score
2025-12-13 02:21:28 -05:00
cschantz d8d9131b4e Major launcher cleanup - remove all non-existent menu items
Problem:
- Launcher had 100+ menu items for features that don't exist
- Confusing nested menus with placeholder functions
- Most security/monitoring/backup options pointed to unimplemented modules
- 1576 lines with massive complexity

Solution - Streamlined launcher with ONLY implemented features:

Main Menu (6 options):
1. System Health Check
2. Security & Monitoring
3. Website Diagnostics
4. Performance Analysis
5. Backup & Recovery
6. Cleanup Toolkit Data

Security & Monitoring (14 options):
✓ Bot & Traffic Analyzer (full + quick scan)
✓ IP Reputation Manager
✓ Malware Scanner
✓ Live Attack Monitor
✓ SSH Attack Monitor
✓ Web Traffic Monitor
✓ Firewall Activity Monitor
✓ 4x Log Tail viewers (Apache access/error, mail, secure)
✓ Enable cPHulk
✓ Optimize CT_LIMIT

Website Diagnostics (3 options):
✓ Website Error Analyzer
✓ Fast 500 Error Tracker
✓ WordPress Tools (links to existing menu)

Performance Analysis (5 options):
✓ MySQL Query Analyzer
✓ Network & Bandwidth
✓ Hardware Health Check
✓ PHP Configuration Optimizer
✓ Loadwatch Health Analyzer (with time ranges)

Backup & Recovery (3 options):
✓ Acronis Management (9 sub-options)
✓ MySQL File Restore
✓ Cleanup Toolkit Data

Removed (90+ phantom menu items):
✗ All placeholder security analysis functions
✗ All placeholder security action functions
✗ All placeholder monitoring functions
✗ All placeholder reporting functions
✗ All placeholder backup functions (except Acronis & MySQL restore)
✗ All placeholder WordPress management (except cron menu)
✗ Configuration editor (unused)
✗ "Erase traces" function

Benefits:
- Reduced from 1576 lines to 574 lines (64% reduction)
- Every menu item points to a real, working script
- Clear, focused organization
- No more "module not found" errors
- Much faster to navigate
- Easier to maintain

Backup:
- Old launcher saved as launcher-old.sh
- Can be restored if needed
2025-12-11 16:07:45 -05:00
cschantz b95e2b0753 Database convert script 2025-12-10 18:37:57 -05:00
cschantz 86ed92e9e2 Fix critical bugs found by QA tool: grep -F, integer comparisons, function exports
CRITICAL FIXES (8 → 0):
- Fix all 8 grep -F with regex anchors bugs
  - lib/reference-db.sh:420
  - lib/user-manager.sh:195, 254, 258, 317, 583, 590
  - modules/website/500-error-tracker.sh:313
  - Changed grep -F to grep for proper regex support

HIGH PRIORITY FIXES:
- Add 36 function exports for subshell availability
  - lib/system-detect.sh: 10 functions
  - lib/common-functions.sh: 26 functions

- Fix 27 integer comparisons with ${var:-0} validation
  - lib/common-functions.sh: 7 fixes
  - lib/ip-reputation.sh: 3 fixes
  - lib/user-manager.sh: 4 fixes
  - launcher.sh: 7 fixes
  - modules/website/500-error-tracker.sh: 1 fix
  - modules/performance/hardware-health-check.sh: 2 fixes
  - modules/performance/mysql-query-analyzer.sh: 1 fix
  - modules/security/bot-analyzer.sh: 11 fixes

- Change exit to return in library file
  - lib/common-functions.sh:246 (require_root function)

DOCUMENTATION:
- Add [DEVELOPMENT_WORKFLOW] section to REFDB_FORMAT.txt
  - Document QA script as "third option" for validation
  - Add recommended workflow for using QA tool
  - Document all 16 checks (11 bug + 5 performance)

IMPACT:
- Before: 41 issues (8 CRITICAL + 13 HIGH + 9 MEDIUM + 11 LOW)
- After: 30 issues (0 CRITICAL + 10 HIGH + 9 MEDIUM + 11 LOW)
- 27% reduction, all CRITICAL bugs eliminated

QA Tool: bash /tmp/toolkit-qa-check.sh /root/server-toolkit
2025-12-03 19:41:59 -05:00
cschantz efcefc67b9 Integrate PHP Configuration Optimizer into main menu
INTEGRATION:
- Added PHP optimizer to Performance & Diagnostics menu (option 9)
- Placed under "Web Server & PHP" section
- Positioned after PHP-FPM Monitor for logical grouping
- Updated handler to call php-optimizer.sh module

MENU STRUCTURE:
Main Menu → Performance & Diagnostics (4) → PHP Configuration Optimizer (9)

Path: modules/performance/php-optimizer.sh

FEATURES NOW ACCESSIBLE VIA MENU:
✓ Analyze All Domains
✓ Analyze Single Domain
✓ Show OPcache Statistics
✓ Optimize Domain (with apply workflow)
✓ View PHP Error Logs
✓ PHP Version Summary
✓ Find Configuration Files
✓ Backup Configurations
✓ Restore from Backup

WORKFLOW (Option 4 - Optimize Domain):
1. Select domain
2. Review recommendations
3. Confirm apply (y/n)
4. Auto-backup created
5. Changes applied
6. Confirm restart (y/n)
7. PHP-FPM gracefully reloaded
8. Verification & rollback info
2025-12-03 00:40:31 -05:00
cschantz 4bfade1bf3 Add Loadwatch Health Analyzer for system monitoring analysis
NEW FEATURE: Loadwatch Health Analyzer
- Comprehensive system health analysis from loadwatch monitoring logs
- Time-range analysis: 1h, 6h, 24h, 7d, 30d options
- Intelligent problem detection and trending

CAPABILITIES:
- Memory pressure detection (low available memory, high swap usage)
- CPU saturation analysis (idle %, iowait, steal time)
- Load average trending and threshold detection
- Process issue detection (zombie processes, high CPU/MEM consumers)
- MySQL performance monitoring (slow queries, thread counts)
- Network connection analysis
- Historical trending across snapshots (3-minute intervals)

IMPLEMENTATION:
- modules/diagnostics/loadwatch-analyzer.sh - Main analyzer script
- Handles symlinked loadwatch directories
- Parses 7 log sections: alerts, summary, memory, CPU, tasks, MySQL, network
- Generates detailed reports with actionable recommendations
- Saves reports to tmp/ directory for review

INTEGRATION:
- Added to Performance & Diagnostics menu (option 10)
- Time range selection submenu for user-friendly access
- Updated README.md with feature documentation and usage examples

ANALYSIS FEATURES:
- Swap threshold alerts (>= 50% usage)
- CPU saturation detection (< 10% idle)
- High I/O wait warnings (> 20%)
- Zombie process tracking
- Memory availability trending (avg/min/max)
- Top CPU consumers aggregated across period

Perfect for:
- Post-incident investigation
- Capacity planning
- Performance trending
- System health monitoring
- Identifying resource bottlenecks

Works with servers that have loadwatch monitoring enabled
(logs in /root/loadwatch or /var/log/loadwatch)
2025-11-20 20:35:16 -05:00
cschantz c4840e425b Clarify Live Monitoring menu - unified monitor vs simple log tailers
PROBLEM: Menu was confusing - showed 5 separate monitors when option 1
now includes everything

BEFORE:
1) Live Attack Monitor - Real-time threat feed (all sources)
2) SSH Attack Monitor - Live SSH brute force attempts
3) Web Traffic Monitor - Live HTTP/HTTPS requests
4) Firewall Activity Monitor - Live CSF/iptables events
5) cPHulk Live Monitor - Real-time brute force blocks
...
10) Multi-Source Dashboard - Combined view

AFTER:
🛡️  Intelligent Monitoring:
1) Live Attack Monitor - Unified threat intelligence
   ├─ Monitors: Web, SSH, Firewall, cPHulk, Network (SYN floods)
   ├─ Features: Threat scoring, bot detection, attack classification
   └─ Quick Actions: IP blocking, ban management

📋 Simple Log Viewers (No Intelligence):
2) SSH Log Tail - Raw SSH auth attempts
3) Web Traffic Tail - Raw Apache access logs
4) Firewall Log Tail - Raw firewall events

Log Tailing:
5) Tail Apache Access Log
6) Tail Apache Error Log
7) Tail Mail Log
8) Tail Security Log

Advanced:
9) Custom Log Monitor

CHANGES:
- Option 1 clearly shows it monitors ALL sources
- Options 2-4 clarified as "simple log tailers" without intelligence
- Removed redundant option 5 (cPHulk - now built into option 1)
- Removed redundant option 10 (Multi-Source - that's what option 1 is)
- Renumbered options 6-11 → 5-9

USER BENEFIT:
- Clear distinction: Smart monitoring vs raw logs
- No confusion about what option 1 actually does
- Menu accurately reflects new multi-source capability
2025-11-14 15:19:52 -05:00
cschantz 323272b6af Move Malware Scanner to top-level security analysis menu
Malware scanning is now more prominent:
- Moved from Web Application Analysis submenu to main Security Analysis menu
- Now option 1 (🦠 Malware Scanner) in Analysis & Troubleshooting
- Direct path: Security → Analysis → Malware Scanner (2→1→1)
- Removed from Web Application submenu to avoid duplication
- Renumbered all security analysis options accordingly

Much easier to find and access the malware scanner now.
2025-11-11 18:47:16 -05:00
cschantz fae334384e Add wrapper script for automatic cleanup with zero manual steps
New workflow:
1. User runs: source run.sh (instead of bash launcher.sh)
2. Launcher runs normally
3. On exit with cleanup=yes, launcher sets flag file
4. Wrapper detects flag and does ALL cleanup automatically:
   - Cleans ~/.bash_history file
   - Clears current shell's in-memory history
   - Removes toolkit directory
   - No manual commands needed

The key: wrapper is SOURCED so it runs in parent shell and can modify history.

User experience: answer "yes" and cleanup happens instantly, automatically.
2025-11-11 18:22:10 -05:00
cschantz 8d98e7f79e Exit menu now does cleanup automatically with verification
Changes:
- Cleans ~/.bash_history file immediately when user selects yes
- Verifies curl command is gone from file before continuing
- Removes logs, temp files, toolkit directory automatically
- Shows verification: "✓ Verified: No curl download commands in history file"
- User just needs to run: history -c, unset HISTFILE, exit

No more asking user to source scripts. Just do the cleanup and verify.
2025-11-11 18:20:28 -05:00
cschantz cfd70486b2 Simplify exit cleanup to source single trace eraser script
Exit menu now tells user to SOURCE the trace eraser instead of running it as subprocess:
- Single command: TRACE_ERASER_AUTO=yes source tools/erase-toolkit-traces.sh
- Sourcing runs it in current shell, allowing it to modify that shell's history
- No more separate helper scripts or multiple steps
- Single source of truth for all cleanup logic

This fixes the parent shell history issue - by sourcing instead of running as subprocess, the trace eraser can actually modify the shell's history where the curl command was executed.
2025-11-11 18:14:01 -05:00
cschantz 5bae0c8e98 Consolidate cleanup to use single trace eraser script
Exit menu now:
- Calls trace eraser in TRACE_ERASER_AUTO=yes mode (no prompts, removes everything)
- Creates minimal helper script only for parent shell history cleanup
- Single source of truth: tools/erase-toolkit-traces.sh

Removed duplicate cleanup logic from launcher exit handler.
2025-11-11 18:01:03 -05:00
cschantz b305834c6e Fix history cleaning to work from parent shell
The fundamental issue: launcher.sh runs in a subprocess, so it cannot modify the parent shell's history where the curl command was executed.

Solution: Create a temporary cleanup script that the parent shell must source after launcher exits. This allows the history cleaning to run in the correct shell context.

User workflow:
1. Run launcher.sh and select exit with cleanup
2. Source the generated /tmp/.cleanup_history_$$.sh script
3. History is cleaned in the parent shell
4. Exit and restart shell to verify

The cleanup script removes toolkit traces from ~/.bash_history and disables history recording for the current session.
2025-11-11 17:56:42 -05:00
cschantz f96deda52c Use same grep logic as trace eraser for history cleaning
Simplified to match the exact logic from erase-toolkit-traces.sh:
- Use grep -Ev with pattern matching
- Clean file, clear history, reload, unset HISTFILE
- Then run trace eraser subprocess for logs/files/directory

The key fix is running this in the current shell instead of subprocess.
2025-11-11 17:53:19 -05:00
cschantz 2e5b214500 Fix history cleaning on exit to work in parent shell
The trace eraser was running as a subprocess, so history cleaning only affected the subprocess. The parent shell would still write its dirty history back to the file on exit.

Now the exit handler cleans history directly in the current shell before calling trace eraser:
- Cleans ~/.bash_history file with grep -Ev
- Runs history -c to clear in-memory history
- Reloads cleaned history with history -r
- Unsets HISTFILE to prevent re-writing on exit
- Then runs trace eraser subprocess for logs/files/directory cleanup

This ensures curl commands and all toolkit traces are actually removed from bash history.
2025-11-11 17:52:23 -05:00
cschantz 5cfcff0598 Make auto cleanup fast and clean
Changes:
- Suppress trace eraser output in auto mode (only show ✓)
- Clear screen after cleanup
- Leave user in /root directory
- Single success message

Result:
- Question -> yes -> quick cleanup -> ✓ All traces removed -> /root
- Fast, minimal output, clean exit
2025-11-11 17:47:48 -05:00
cschantz d9121768ef Simplify exit cleanup - one question, full cleanup
Changes:
- Single question on exit: 'Clean history and remove traces?'
- If yes: runs full trace eraser automatically
- Auto mode skips all prompts, removes everything
- TRACE_ERASER_AUTO=yes flag for non-interactive mode

User experience:
- Exit (0)
- One question
- If yes: everything cleaned and removed automatically
- No multiple prompts
2025-11-11 17:46:52 -05:00
cschantz db352cc7a2 Add history cleaning prompt on exit
Changes:
- Prompt user to clean history when selecting Exit (0)
- Runs trace eraser if user answers 'yes'
- Shows clear message about what will be cleaned

User experience:
- Exit from main menu
- Asked: 'Clean history? (yes/no)'
- If yes: runs full trace eraser
- Then exits normally
2025-11-11 17:44:42 -05:00
cschantz 4e169f2c4d Reorganize website management menu with WordPress subdirectory
Changes:
- Created modules/website/wordpress/ subdirectory for CMS-specific tools
- Moved wordpress-cron-manager.sh to new subdirectory
- Created wordpress-menu.sh submenu for WordPress tools
- Updated launcher.sh Website Management menu:
  - Simplified to show general tools and CMS submenu options
  - WordPress Management is now a submenu (option 3)
  - Prepared structure for Joomla/Drupal/other CMS support
- Fixed script paths in wordpress-cron-manager.sh for new location
- Tested complete navigation: Main → Website → WordPress → Cron Manager

Menu Structure Now:
  Website Management
  ├── Website Error Analyzer
  ├── 500 Error Tracker
  └── WordPress Management (submenu)
      └── WordPress Cron Manager
          └── (All cron management options working)

https://claude.com/claude-code
2025-11-07 17:37:51 -05:00
cschantz b03179cc95 Add comprehensive Acronis backup management interface
Implemented complete backup management section with acrocmd integration:

New Features:
- Backup Manager: Centralized interface with organized sections
  • Agent Management (status, logs)
  • Backup Operations (list, trigger, status)
  • Plan Management (view, manage protection plans)
  • Restore Operations (placeholder for future)

Scripts Created:
- acronis-backup-manager.sh: Main backup management menu
- acronis-list-backups.sh: Lists archives and backup details
- acronis-trigger-backup.sh: Triggers manual backups with plan selection
- acronis-backup-status.sh: Shows active tasks and recent activities
- acronis-schedule-viewer.sh: Displays protection plans and schedules
- acronis-plan-manager.sh: Manages protection plans (view/enable/disable/delete)

Integration:
- All scripts use acrocmd CLI for programmatic backup operations
- Updated Acronis menu with streamlined "Manage Backups" option
- Reorganized menu structure for better usability
- Added proper error handling and status checks
2025-11-06 16:25:10 -05:00
cschantz f18e92a48d Add comprehensive Acronis backup troubleshooting tool
Created acronis-troubleshoot.sh with intelligent diagnostic capabilities:

7-Point Diagnostic System:
1. Service Health Check
   - Verifies all 4 Acronis services (aakore, mms, schedule, active-protection)
   - Detects stopped/failed services
   - Auto-generates restart recommendations

2. Disk Space Analysis
   - Checks /var/lib/Acronis and root filesystem
   - Warns at 90%, critical at 95% usage
   - Identifies insufficient space for backups

3. Memory Monitoring
   - Tracks system memory usage
   - Warns at high memory conditions (>90%)
   - Detects potential memory leaks

4. Network Connectivity Testing
   - Tests connection to Acronis Cloud URL
   - DNS resolution verification
   - Identifies firewall/network issues

5. Multi-Location Log Scanning
   - Scans multiple log locations:
     * /var/lib/Acronis/BackupAndRecovery/MMS/mms.*.log
     * /var/log/acronis/agent/*.log
     * System logs (/var/log/messages, /var/log/syslog)
   - Pattern detection for 8 common failure types:
     * Insufficient space errors
     * Permission denied
     * Connection failures
     * Authentication failures
     * Backup task failures
     * VSS/snapshot errors
     * Database errors
     * File locking issues

6. Stuck Process Detection
   - Identifies long-running Acronis processes
   - Detects hung backup jobs
   - Recommends service restarts when needed

7. Configuration Verification
   - Checks backup plan configuration
   - Verifies agent version
   - Registration status validation

Intelligent Recommendations:
- Context-aware fix suggestions based on detected issues
- Prioritized action items (critical vs warnings)
- Specific commands to resolve each issue type

Quick Actions Menu:
1. View all errors from logs
2. Restart all services
3. Generate detailed diagnostic report for support
4. Export logs as tar.gz archive

Issue Tracking:
- Categorizes findings as CRITICAL or WARNINGS
- Provides comprehensive summary with counts
- Color-coded output (red=critical, yellow=warning, green=ok)

Added to Acronis menu as option 12 (Troubleshooting section)

This tool enables rapid diagnosis of backup failures without needing
to manually dig through logs or check multiple system components.
2025-11-05 21:36:13 -05:00
cschantz 1f21a596b5 Add Acronis Cyber Protect submenu to Backup & Recovery
Reorganized Backup & Recovery menu to include dedicated Acronis submenu:
- Added Acronis Management submenu (option 9) with 11 operations:
  * Installation & Setup: Install, register, configure
  * Backup Operations: Manual backup, status, list, restore
  * Management: Agent status, update, logs, uninstall
- Moved cleanup-toolkit-data.sh from option 9 to option 10
- Created handle_acronis_menu() function to route to Acronis scripts
- All Acronis operations grouped under backup/acronis-*.sh modules
2025-11-05 21:14:11 -05:00
cschantz 30026e26a7 Add cleanup script for IP reputation and toolkit data
Created comprehensive cleanup tool to remove all server-specific data
before transferring toolkit to another server.

NEW FILE:
- modules/maintenance/cleanup-toolkit-data.sh
  * Removes IP reputation database (/var/lib/server-toolkit/)
  * Cleans all temporary analysis files (/tmp/*bot*, *500-tracker*, etc.)
  * Removes generated reports
  * Clears cache and session data
  * Optional log file removal
  * Shows summary of items removed and space freed
  * Safety confirmation required before cleanup

UPDATED:
- launcher.sh
  * Added cleanup script to Backup & Recovery menu (option 9)
  * Placed in "Data Management" section
  * Clearly marked with trash icon to indicate destructive operation

PURPOSE:
This ensures the IP reputation database and other server-specific data
are not transferred when moving the toolkit between servers. Each server
should build its own IP reputation database based on its own traffic and
attack patterns.

USE CASES:
✓ Moving toolkit to different server
✓ Starting fresh analysis
✓ Removing server-specific data before sharing toolkit
✓ Regular maintenance/cleanup

WHAT GETS CLEANED:
- /var/lib/server-toolkit/ip-reputation/ (IP reputation database)
- /tmp/bot_analysis_* (bot analyzer temp files)
- /tmp/500-tracker-* (error tracker temp files)
- /tmp/live-monitor-* (live monitoring temp files)
- /tmp/*_report_*.txt (generated reports)
- /var/cache/server-toolkit/ (cached data)
- Session/lock files
- Optional: execution logs
2025-11-05 18:48:23 -05:00
cschantz 526fb23ad0 Add centralized IP reputation tracking system
Created a comprehensive IP reputation system that tracks IPs across all
toolkit scripts with tags/attack types, scores, and detailed analytics.

NEW FILES:
- lib/ip-reputation.sh: Core reputation library with optimized database
  * Fast lookup using pipe-delimited file format
  * Attack type tagging system (bitmask: SQL, XSS, RCE, Bot, Scanner, etc.)
  * Reputation scoring (0-100) based on hits and attack severity
  * GeoIP country lookup integration
  * Automatic cleanup of old entries
  * Thread-safe with file locking

- modules/security/ip-reputation-manager.sh: Interactive management tool
  * Query individual IPs with full details
  * View top malicious/active IPs
  * Database statistics and analytics
  * Manual IP flagging/whitelisting
  * Import IPs from logs
  * Export to readable reports
  * Live monitoring mode

INTEGRATION:
All security and analysis scripts now use the centralized reputation system:

- modules/website/500-error-tracker.sh:
  * Tracks IPs generating 500 errors
  * Tags bots/scanners with BOT/SCANNER flags
  * Background processing for performance

- modules/security/live-attack-monitor.sh:
  * Maps attack types to reputation flags
  * Tracks SSH bruteforce, SQL injection, XSS, DDoS, etc.
  * Real-time reputation updates

- modules/website/website-error-analyzer.sh:
  * Tags filtered bots in error analysis
  * Builds IP reputation from website errors

- launcher.sh:
  * Added IP Reputation Manager to Bot & Traffic Analysis menu
  * Menu option 4 in Security > Analysis > Bot & Traffic Analysis

KEY FEATURES:
✓ Centralized IP tracking across ALL scripts
✓ Multi-tag system (IP can have multiple attack types)
✓ Reputation scores increase with more tags/attacks
✓ Country tracking via GeoIP
✓ Optimized for high-volume traffic (attacks with 1000s of IPs)
✓ Fast lookups even during DDoS
✓ Background processing doesn't slow down analysis
✓ Database cleanup/maintenance tools
✓ Export for reports and sharing

BENEFITS:
- Single source of truth for IP reputation
- Scripts share intelligence (bot detected in one script = flagged for all)
- Track IPs across time and multiple attack vectors
- Identify repeat offenders with multiple attack types
- Make blocking decisions based on comprehensive data
- Performance optimized with file locking and background updates
2025-11-05 18:45:55 -05:00
cschantz b6af641b3c Add IP filtering and reorganize Website Management menu
IP Filtering enhancements to 500 error tracker:
- Filter localhost/internal IPs (127.x, 10.x, 172.16-31.x, 192.168.x)
- Detect cloud scanner IPs from AWS, GCP, Azure with user agent validation
- Skip known bot network IP ranges to reduce noise
- More aggressive filtering of non-relevant traffic

Website Management menu reorganization:
Reduced from 16 options to 7 logical categories:

Main menu now has:
1. Website Error Analyzer
2. Fast 500 Error Tracker
3. Debug Log Analyzer
4. Health & Maintenance → (5 tools: health check, DB optimizer, cache, plugin/theme audit)
5. WP-Cron Management → (3 tools: status, mass fix, system cron setup)
6. Mass Updates → (3 tools: core, plugins, themes updates)
7. Security & Compliance → (3 tools: malware scanner, permissions, login audit)

Benefits:
- Cleaner, more organized menu structure
- Related tools grouped together
- Easier navigation with logical subcategories
- Reduced cognitive load (7 vs 16 options)
2025-11-03 21:21:44 -05:00
cschantz d7febf68d3 Add Fast 500 Error Tracker + Fix awk error in analyzer
NEW SCRIPT: modules/website/500-error-tracker.sh
- FAST-ONLY 500 error detection (no menus, no options)
- Scans access logs for 500 errors
- Maps domains to cPanel usernames
- Automatically diagnoses root causes by checking error_log files
- Shows actual PHP errors causing the 500s

ROOT CAUSE DETECTION:
- PHP Memory Exhausted (shows current limit)
- PHP Fatal Errors
- PHP Syntax Errors
- Missing PHP Functions/Extensions
- Database Connection Failures
- .htaccess Issues
- Shows ACTUAL error examples, not just suggestions

FIXES:
- Fixed awk error in website-error-analyzer.sh:
  • Changed "next" in END block to "if (length > 0)"
  • "next" cannot be used in END block in awk

- Added option 2 in Website Management menu
- Renumbered all WordPress tools (3-16)

DIFFERENCE FROM FULL ANALYZER:
Full Analyzer: All errors, filters, time ranges, user choices
Fast Tracker: ONLY 500s, auto-diagnosis, shows WHY not suggestions

Use Fast Tracker when you need to quickly find which domains
are getting 500 errors and the exact PHP errors causing them.
2025-11-03 20:32:19 -05:00
cschantz e3525a3a96 Add intelligent website error analyzer
- Filters out bots, plugin warnings, deprecation notices
- Focuses on real user-facing issues (500s, fatal errors, database failures)
- Discovers ALL log locations (Apache, PHP error_log per domain)
- Analyzes both Apache error logs and per-domain PHP logs
- Added 30-day analysis option
- Intelligent noise filtering and critical error detection
- Provides specific actionable recommendations
- Added to Website Management menu as option 1
2025-11-03 19:02:41 -05:00
cschantz 2ee6d7d698 Add trace eraser tool for privacy
- New tool: erase-toolkit-traces.sh removes all toolkit traces
- Cleans bash history for all users
- Removes toolkit mentions from system logs
- Deletes download artifacts and temp files
- Optional: complete toolkit directory removal
- Added to main menu as option 10
2025-11-03 18:41:30 -05:00
cschantz a51d968185 Initial commit: Server Management Toolkit v2.0
- Complete security menu restructure (3-mode: Analysis/Actions/Live)
- Intelligent cPHulk enablement with CSF whitelist import
- Live network security monitoring dashboard
- Multi-source threat detection and classification
- 50+ organized security tools across 4-level menu hierarchy
- System health diagnostics with cPanel/WHM integration
- Reference database for cross-module intelligence sharing
2025-11-03 18:21:40 -05:00