diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index db0c78a..d1c1118 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -1391,21 +1391,21 @@ log_message "Scan session started" # Create marker file to indicate scan is running touch "$SCAN_DIR/.scan_running" -# Detect available scanners -AVAILABLE_SCANNERS=() +# Detect available scanners (consolidate into lowercase array) +available_scanners=() if command -v imunify-antivirus &>/dev/null; then - AVAILABLE_SCANNERS+=("imunify") + available_scanners+=("imunify") log_message "Detected: ImunifyAV" fi if command -v clamscan &>/dev/null; then - AVAILABLE_SCANNERS+=("clamav") + available_scanners+=("clamav") log_message "Detected: ClamAV" fi if command -v maldet &>/dev/null; then - AVAILABLE_SCANNERS+=("maldet") + available_scanners+=("maldet") log_message "Detected: Maldet" fi @@ -1413,7 +1413,7 @@ fi RKHUNTER_TEMP_INSTALLED=false if command -v rkhunter &>/dev/null; then - AVAILABLE_SCANNERS+=("rkhunter") + available_scanners+=("rkhunter") log_message "Detected: Rootkit Hunter" else # Auto-install rkhunter temporarily for this scan @@ -1442,7 +1442,7 @@ else log_message "WARNING: RKHunter property baseline creation failed" fi - AVAILABLE_SCANNERS+=("rkhunter") + available_scanners+=("rkhunter") RKHUNTER_TEMP_INSTALLED=true log_message "RKHunter installed temporarily" echo " ✓ RKHunter installed (will be removed after scan)" @@ -1465,7 +1465,7 @@ else log_message "WARNING: RKHunter property baseline creation failed" fi - AVAILABLE_SCANNERS+=("rkhunter") + available_scanners+=("rkhunter") RKHUNTER_TEMP_INSTALLED=true log_message "RKHunter installed temporarily" echo " ✓ RKHunter installed (will be removed after scan)" @@ -1495,7 +1495,7 @@ if [ "${MALDET_ONLY:-0}" = "1" ]; then fi # If no scanners found, show installation guide and exit gracefully -if [ ${#AVAILABLE_SCANNERS[@]} -eq 0 ]; then +if [ ${#available_scanners[@]} -eq 0 ]; then log_message "WARNING: No scanners found on this system" echo "" echo -e "${RED}No malware scanners detected!${NC}" @@ -1541,7 +1541,7 @@ if [ ${#AVAILABLE_SCANNERS[@]} -eq 0 ]; then exit 0 fi -log_message "Found ${#AVAILABLE_SCANNERS[@]} scanner(s): ${AVAILABLE_SCANNERS[*]}" +log_message "Found ${#available_scanners[@]} scanner(s): ${available_scanners[*]}" # Scan paths (will be replaced) SCAN_PATHS=() @@ -1603,7 +1603,7 @@ fi echo "==========================================" echo "Session: $(basename "$SCAN_DIR")" echo "Started: $(date)" - echo "Scanners: ${AVAILABLE_SCANNERS[*]}" + echo "Scanners: ${available_scanners[*]}" echo "Paths: ${#SCAN_PATHS[@]}" echo "" printf '%s\n' "${SCAN_PATHS[@]}" @@ -1614,10 +1614,10 @@ fi # Track completion SCANNERS_COMPLETED=0 -TOTAL_SCANNERS=${#AVAILABLE_SCANNERS[@]} +TOTAL_SCANNERS=${#available_scanners[@]} # Run each scanner -for scanner in "${AVAILABLE_SCANNERS[@]}"; do +for scanner in "${available_scanners[@]}"; do SCANNER_NUM=$((SCANNERS_COMPLETED + 1)) echo "" @@ -2072,24 +2072,24 @@ done echo "────────────────────────────────────────" # ImunifyAV results - if echo "${AVAILABLE_SCANNERS[*]}" | grep -q "imunify"; then + if echo "${available_scanners[*]}" | grep -q "imunify"; then IMUNIFY_COUNT=$(grep -o "ImunifyAV scan complete - Found: [0-9]*" "$SUMMARY_FILE" | grep -o "[0-9]*$" || echo "N/A") printf "%-20s %s\n" "ImunifyAV:" "$IMUNIFY_COUNT threats detected" fi # ClamAV results - if echo "${AVAILABLE_SCANNERS[*]}" | grep -q "clamav"; then + if echo "${available_scanners[*]}" | grep -q "clamav"; then CLAM_COUNT=$(grep -o "ClamAV scan complete - Found: [0-9]*" "$SUMMARY_FILE" | grep -o "[0-9]*$" || echo "N/A") printf "%-20s %s\n" "ClamAV:" "$CLAM_COUNT infected files" fi # Maldet results - if echo "${AVAILABLE_SCANNERS[*]}" | grep -q "maldet"; then + if echo "${available_scanners[*]}" | grep -q "maldet"; then printf "%-20s %s\n" "Maldet:" "Scan complete (check logs)" fi # RKHunter results - if echo "${AVAILABLE_SCANNERS[*]}" | grep -q "rkhunter"; then + if echo "${available_scanners[*]}" | grep -q "rkhunter"; then RKH_COUNT=$(grep -o "RKHunter scan complete - Warnings: [0-9]*" "$SUMMARY_FILE" | grep -o "[0-9]*$" || echo "N/A") printf "%-20s %s\n" "Rootkit Hunter:" "$RKH_COUNT warnings" fi @@ -2132,7 +2132,7 @@ log_message "Validating scan results..." validation_issues=0 # Check that each scanner produced output -for scanner in "${AVAILABLE_SCANNERS[@]}"; do +for scanner in "${available_scanners[@]}"; do case "$scanner" in imunify) if [ ! -s "$LOG_DIR/imunify.log" ]; then