diff --git a/modules/security/malware-scanner.sh b/modules/security/malware-scanner.sh index 1de66bd..cc26780 100755 --- a/modules/security/malware-scanner.sh +++ b/modules/security/malware-scanner.sh @@ -1559,9 +1559,8 @@ echo " cat $RESULTS_DIR/client_report.txt" echo "" # Prompt for cleanup (RKHunter cleanup handled by trap) -read -p "Delete scan script? (Logs and results will be preserved) (yes/no): " cleanup_choice - -if [ "$cleanup_choice" = "yes" ]; then +echo "" +if confirm "Delete scan script? (Logs and results will be preserved)"; then log_message "User requested cleanup - deleting scan script" echo "" echo "Removing scan script..." @@ -1572,11 +1571,11 @@ if [ "$cleanup_choice" = "yes" ]; then echo "" else log_message "User chose to keep scan script" - echo "" - echo "Scan script and results preserved at: $SCAN_DIR" - echo "" fi +echo "Scan script and results preserved at: $SCAN_DIR" +echo "" + echo "You can:" echo " • Review logs: ls $LOG_DIR" echo " • View summary: cat $SUMMARY_FILE" @@ -2172,40 +2171,48 @@ show_scan_menu() { echo "" echo -e "${CYAN}Create New Scan:${NC}" - echo " 1. Scan entire server (ClamAV, Maldet, RKHunter)" - echo " 2. Scan all user accounts (All scanners - recommended)" - echo " 3. Scan specific user account (All scanners)" - echo " 4. Scan specific domain (All scanners)" - echo " 5. Scan custom path (All scanners)" + echo -e " ${CYAN}1.${NC} Scan entire server (ClamAV, Maldet, RKHunter)" + echo -e " ${CYAN}2.${NC} Scan all user accounts (All scanners - recommended)" + echo -e " ${CYAN}3.${NC} Scan specific user account (All scanners)" + echo -e " ${CYAN}4.${NC} Scan specific domain (All scanners)" + echo -e " ${CYAN}5.${NC} Scan custom path (All scanners)" echo "" echo -e "${CYAN}Monitor & Manage:${NC}" - echo " 6. Check scan status" - echo " 7. View scan results" - echo " 8. Delete scan sessions" + echo -e " ${CYAN}6.${NC} Check scan status" + echo -e " ${CYAN}7.${NC} View scan results" + echo -e " ${CYAN}8.${NC} Delete scan sessions" echo "" echo -e "${CYAN}Configuration:${NC}" - echo " 9. Install all scanners" - echo " 10. Scanner settings" + echo -e " ${CYAN}9.${NC} Install all scanners" + echo -e " ${CYAN}10.${NC} Scanner settings" echo "" echo -e " ${RED}0.${NC} Back" echo "" - read -p "Select option: " choice + # Validate choice input with retry loop + while true; do + read -p "Select option (0-10): " choice - case $choice in - 1) launch_standalone_scanner_menu "server" ;; - 2) launch_standalone_scanner_menu "all_users" ;; - 3) launch_standalone_scanner_menu "user" ;; - 4) launch_standalone_scanner_menu "domain" ;; - 5) launch_standalone_scanner_menu "custom" ;; - 6) check_standalone_status ;; - 7) view_scan_results ;; - 8) delete_standalone_sessions ;; - 9) install_all_scanners ;; - 10) scanner_settings ;; - 0) return 0 ;; - *) echo -e "${RED}Invalid option${NC}"; sleep 1 ;; - esac + if ! [[ "$choice" =~ ^([0-9]|10)$ ]]; then + echo -e "${RED}Invalid option${NC}" + sleep 1 + continue + fi + + case $choice in + 1) launch_standalone_scanner_menu "server"; break ;; + 2) launch_standalone_scanner_menu "all_users"; break ;; + 3) launch_standalone_scanner_menu "user"; break ;; + 4) launch_standalone_scanner_menu "domain"; break ;; + 5) launch_standalone_scanner_menu "custom"; break ;; + 6) check_standalone_status; break ;; + 7) view_scan_results; break ;; + 8) delete_standalone_sessions; break ;; + 9) install_all_scanners; break ;; + 10) scanner_settings; break ;; + 0) return 0 ;; + esac + done done }