Compare commits
12 Commits
dev
...
93ca221ba2
| Author | SHA1 | Date | |
|---|---|---|---|
| 93ca221ba2 | |||
| c072942a3c | |||
| ed00dd4a50 | |||
| 92da267f4c | |||
| 655bf18f91 | |||
| b0646f21f2 | |||
| 5fb3640004 | |||
| 9942296714 | |||
| aa432a08bd | |||
| 3126944905 | |||
| e5979a501e | |||
| eabddb553d |
+44
-14
@@ -53,7 +53,7 @@ run_module() {
|
||||
echo ""
|
||||
echo -e "${RED}✗ Module not found: $category/$module${NC}"
|
||||
echo ""
|
||||
read -p "Press Enter to continue..."
|
||||
read -p "Press Enter to continue..." < /dev/tty 2>/dev/null || true
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -74,7 +74,7 @@ run_module() {
|
||||
echo -e "${RED}✗ Exited with code: $exit_code${NC}"
|
||||
fi
|
||||
echo ""
|
||||
read -p "Press Enter to continue..."
|
||||
read -p "Press Enter to continue..." < /dev/tty 2>/dev/null || true
|
||||
}
|
||||
|
||||
#############################################################################
|
||||
@@ -135,7 +135,9 @@ show_threat_analysis_menu() {
|
||||
handle_threat_analysis_menu() {
|
||||
while true; do
|
||||
show_threat_analysis_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "security" "bot-analyzer.sh" ;;
|
||||
@@ -169,7 +171,9 @@ show_live_monitoring_menu() {
|
||||
handle_live_monitoring_menu() {
|
||||
while true; do
|
||||
show_live_monitoring_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "security" "live-attack-monitor.sh" ;;
|
||||
@@ -201,7 +205,9 @@ show_log_viewers_menu() {
|
||||
handle_log_viewers_menu() {
|
||||
while true; do
|
||||
show_log_viewers_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "security" "tail-apache-access.sh" ;;
|
||||
@@ -232,7 +238,9 @@ show_security_actions_menu() {
|
||||
handle_security_actions_menu() {
|
||||
while true; do
|
||||
show_security_actions_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "security" "enable-cphulk.sh" ;;
|
||||
@@ -266,7 +274,9 @@ show_security_menu() {
|
||||
handle_security_menu() {
|
||||
while true; do
|
||||
show_security_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) handle_threat_analysis_menu ;;
|
||||
@@ -314,7 +324,9 @@ show_website_menu() {
|
||||
handle_website_menu() {
|
||||
while true; do
|
||||
show_website_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "website" "website-error-analyzer.sh" ;;
|
||||
@@ -367,7 +379,9 @@ show_performance_menu() {
|
||||
handle_performance_menu() {
|
||||
while true; do
|
||||
show_performance_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "performance" "mysql-query-analyzer.sh" ;;
|
||||
@@ -473,7 +487,9 @@ show_acronis_menu() {
|
||||
handle_backup_menu() {
|
||||
while true; do
|
||||
show_backup_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) handle_acronis_menu ;;
|
||||
@@ -488,7 +504,9 @@ handle_backup_menu() {
|
||||
handle_acronis_menu() {
|
||||
while true; do
|
||||
show_acronis_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "backup" "acronis-install.sh" ;;
|
||||
@@ -542,7 +560,9 @@ show_email_menu() {
|
||||
handle_email_menu() {
|
||||
while true; do
|
||||
show_email_menu
|
||||
read -r choice
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "email" "email-diagnostics.sh" ;;
|
||||
@@ -573,6 +593,11 @@ init_directories() {
|
||||
}
|
||||
|
||||
startup_detection() {
|
||||
# Initialize system detection first (required for proper reference database)
|
||||
if [ -z "${SYS_DETECTION_COMPLETE:-}" ]; then
|
||||
initialize_system_detection
|
||||
fi
|
||||
|
||||
if ! db_is_fresh; then
|
||||
clear
|
||||
print_banner "Server Management Toolkit - Initializing"
|
||||
@@ -608,7 +633,7 @@ startup_detection() {
|
||||
print_success "Detection complete! Cached for 1 hour."
|
||||
echo ""
|
||||
|
||||
read -p "Press Enter to continue..."
|
||||
read -p "Press Enter to continue..." < /dev/tty 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -622,7 +647,12 @@ main() {
|
||||
|
||||
while true; do
|
||||
show_main_menu
|
||||
read -r choice
|
||||
|
||||
# Read from terminal (use /dev/tty directly for interaction)
|
||||
if ! read -r choice 2>/dev/null </dev/tty; then
|
||||
# No terminal available, return from function gracefully
|
||||
return 0
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
1) run_module "diagnostics" "system-health-check.sh" ;;
|
||||
|
||||
@@ -169,8 +169,7 @@ show_terminal_info() {
|
||||
# Create temporary session directory
|
||||
create_temp_session() {
|
||||
export SESSION_ID=$$
|
||||
export TEMP_SESSION_DIR="/tmp/server-toolkit-${SESSION_ID}"
|
||||
mkdir -p "$TEMP_SESSION_DIR"
|
||||
export TEMP_SESSION_DIR=$(mktemp -d -t server-toolkit.XXXXXX)
|
||||
|
||||
# Cleanup on exit
|
||||
trap '[ -n "$TEMP_SESSION_DIR" ] && rm -rf "$TEMP_SESSION_DIR" 2>/dev/null' EXIT INT TERM
|
||||
|
||||
+6
-3
@@ -162,8 +162,8 @@ build_databases_section() {
|
||||
# Build MySQL command with credentials if needed
|
||||
local mysql_cmd="mysql"
|
||||
if [ "$SYS_CONTROL_PANEL" = "plesk" ] && [ -f /etc/psa/.psa.shadow ]; then
|
||||
local plesk_mysql_pass=$(cat /etc/psa/.psa.shadow)
|
||||
mysql_cmd="mysql -uadmin -p${plesk_mysql_pass}"
|
||||
export MYSQL_PWD=$(cat /etc/psa/.psa.shadow)
|
||||
mysql_cmd="mysql -uadmin"
|
||||
fi
|
||||
|
||||
local total_dbs=$($mysql_cmd -Ns -e "SHOW DATABASES" 2>/dev/null | grep -v "^information_schema$\|^mysql$\|^performance_schema$\|^sys$" | wc -l)
|
||||
@@ -180,7 +180,7 @@ build_databases_section() {
|
||||
|
||||
local size_mb=$($mysql_cmd -Ns -e "SELECT ROUND(SUM(data_length + index_length) / 1024 / 1024, 2)
|
||||
FROM information_schema.TABLES
|
||||
WHERE table_schema='$db'" 2>/dev/null)
|
||||
WHERE table_schema=\`$db\`" 2>/dev/null)
|
||||
[ -z "$size_mb" ] && size_mb=0
|
||||
|
||||
local table_count=$($mysql_cmd -Ns "$db" -e "SHOW TABLES" 2>/dev/null | wc -l)
|
||||
@@ -190,6 +190,9 @@ build_databases_section() {
|
||||
|
||||
finish_progress
|
||||
echo "" >> "$SYSREF_DB"
|
||||
|
||||
# Clean up password environment variable
|
||||
unset MYSQL_PWD
|
||||
}
|
||||
|
||||
# Check domain HTTP/HTTPS status codes
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
# Scan scope: Single domain, user account, or entire server
|
||||
################################################################################
|
||||
|
||||
# Color definitions (matching launcher.sh)
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m'
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
# Source required libraries (warn if missing, but allow graceful degradation)
|
||||
@@ -32,6 +40,7 @@ validate_required_functions() {
|
||||
local required_functions=(
|
||||
"confirm"
|
||||
"print_header"
|
||||
"print_banner"
|
||||
"select_user_interactive"
|
||||
"get_user_domains"
|
||||
)
|
||||
@@ -91,13 +100,9 @@ detect_scanners() {
|
||||
available_scanners+=("rkhunter")
|
||||
fi
|
||||
|
||||
if [ ${#available_scanners[@]} -eq 0 ]; then
|
||||
echo -e "${RED}No malware scanners detected!${NC}"
|
||||
echo ""
|
||||
show_scanner_installation_guide
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Note: If no scanners are found, available_scanners array will be empty
|
||||
# Menu option 9 allows installation, so we don't exit here
|
||||
# Just return success to allow menu to display
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -210,31 +215,76 @@ install_all_scanners() {
|
||||
if ! is_clamav_installed; then
|
||||
echo -e "${CYAN}[1/4] Installing ClamAV...${NC}"
|
||||
|
||||
# Try control panel-specific methods first
|
||||
if [ -f "/usr/local/cpanel/cpanel" ]; then
|
||||
# cPanel method - check if already installed but not configured
|
||||
if rpm -qa | grep -q "cpanel-clamav"; then
|
||||
# cPanel method - use cPanel's package management only
|
||||
if rpm -qa 2>/dev/null | grep -q "cpanel-clamav"; then
|
||||
echo -e "${GREEN}✓ ClamAV already installed (cPanel)${NC}"
|
||||
else
|
||||
/scripts/update_local_rpm_versions --edit target_settings.clamav installed 2>/dev/null
|
||||
/scripts/check_cpanel_rpms --fix --targets=clamav 2>&1 | grep -E "Installing|Updating|up to date"
|
||||
echo " → Installing via cPanel package manager..."
|
||||
|
||||
# Check if cPanel scripts exist before using them
|
||||
if [ -f "/scripts/update_local_rpm_versions" ] && [ -f "/scripts/check_cpanel_rpms" ]; then
|
||||
/scripts/update_local_rpm_versions --edit target_settings.clamav installed 2>/dev/null || true
|
||||
if ! /scripts/check_cpanel_rpms --fix --targets=clamav 2>&1 | tail -3; then
|
||||
# cPanel scripts failed, fall back to standard yum
|
||||
echo " → cPanel package manager unavailable, trying standard yum..."
|
||||
yum install -y clamav clamav-update 2>&1 | grep -E "Installing|Installed|already" || echo " (installation in progress)"
|
||||
fi
|
||||
else
|
||||
# cPanel scripts don't exist, fall back to standard yum
|
||||
echo " → cPanel tools not available, using standard package manager..."
|
||||
yum install -y clamav clamav-update 2>&1 | grep -E "Installing|Installed|already" || echo " (installation in progress)"
|
||||
fi
|
||||
fi
|
||||
# IMPORTANT: Don't fall through to standard yum - cPanel packages conflict!
|
||||
elif [ -f "/usr/local/psa/version" ]; then
|
||||
# Plesk method - use standard package manager
|
||||
echo " → Detected Plesk system, using standard package manager..."
|
||||
if command -v yum &>/dev/null; then
|
||||
yum install -y clamav clamav-update 2>&1 | grep -E "Installing|Installed|already installed" || echo " (installation may already be complete)"
|
||||
elif command -v apt-get &>/dev/null; then
|
||||
apt-get update 2>&1 | grep -E "Reading|Building|Hit|Get" | head -3 || true
|
||||
apt-get install -y clamav clamav-daemon 2>&1 | grep -E "Setting up|already|newest" || echo " (installation may already be complete)"
|
||||
fi
|
||||
elif command -v yum &>/dev/null; then
|
||||
yum install -y clamav clamav-update 2>&1 | grep -E "Installing|Updating|already installed"
|
||||
# RHEL/CentOS based systems (non-cPanel)
|
||||
echo " → Installing via yum..."
|
||||
yum install -y clamav clamav-update 2>&1 | grep -E "Installing|Installed|already installed" || echo " (installation may already be complete)"
|
||||
elif command -v apt-get &>/dev/null; then
|
||||
apt-get update && apt-get install -y clamav clamav-daemon
|
||||
# Debian/Ubuntu: Update package list first, then install ClamAV
|
||||
echo " → Updating package list..."
|
||||
apt-get update 2>&1 | grep -E "Reading|Building|Hit|Get" | head -3 || true
|
||||
echo " → Installing ClamAV..."
|
||||
apt-get install -y clamav clamav-daemon 2>&1 | grep -E "Setting up|already|newest" || echo " (installation may already be complete)"
|
||||
fi
|
||||
|
||||
if is_clamav_installed; then
|
||||
echo -e "${GREEN}✓ ClamAV installed${NC}"
|
||||
|
||||
# Find freshclam binary
|
||||
local freshclam_bin=$(command -v freshclam || find /usr -name freshclam 2>/dev/null | head -1)
|
||||
# Find freshclam binary - try standard locations first before using find
|
||||
local freshclam_bin=""
|
||||
for path in /usr/bin/freshclam /usr/sbin/freshclam \
|
||||
/usr/local/bin/freshclam /usr/local/sbin/freshclam \
|
||||
/usr/local/cpanel/3rdparty/bin/freshclam; do
|
||||
if [ -x "$path" ]; then
|
||||
freshclam_bin="$path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
# Only use find as last resort if standard paths don't work
|
||||
if [ -z "$freshclam_bin" ]; then
|
||||
freshclam_bin=$(find /usr/local /usr -name freshclam -type f 2>/dev/null | head -1)
|
||||
fi
|
||||
|
||||
# Update virus signatures immediately
|
||||
if [ -n "$freshclam_bin" ]; then
|
||||
echo " → Updating virus signatures (this may take a moment)..."
|
||||
$freshclam_bin 2>&1 | grep -E "updated|Downloaded|up-to-date" || $freshclam_bin &>/dev/null
|
||||
echo " → Updating virus signatures (timeout 60s)..."
|
||||
if timeout 60 "$freshclam_bin" 2>&1 | grep -qE "updated|Downloaded|up-to-date"; then
|
||||
echo -e " ${GREEN}✓${NC} Signatures updated"
|
||||
else
|
||||
echo -e " ${YELLOW}⚠${NC} Signature update inconclusive (may still be current)"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ ClamAV installation failed${NC}"
|
||||
@@ -249,14 +299,18 @@ install_all_scanners() {
|
||||
if ! is_maldet_installed; then
|
||||
echo -e "${CYAN}[2/4] Installing Maldet...${NC}"
|
||||
|
||||
(
|
||||
cd /tmp || { echo -e "${RED}✗ Cannot access /tmp${NC}"; return 1; }
|
||||
|
||||
# Download Maldet
|
||||
echo " → Downloading Maldet..."
|
||||
# Try HTTPS first (more secure), fallback to HTTP if needed
|
||||
if ! wget -q https://www.rfxn.com/downloads/maldetect-current.tar.gz 2>/dev/null; then
|
||||
if ! wget -q http://www.rfxn.com/downloads/maldetect-current.tar.gz; then
|
||||
echo -e "${RED}✗ Download failed - check internet connectivity${NC}"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f maldetect-current.tar.gz ]; then
|
||||
echo " → Extracting archive..."
|
||||
@@ -270,8 +324,6 @@ install_all_scanners() {
|
||||
local maldet_dir=$(find /tmp -maxdepth 1 -type d -name "maldetect-*" 2>/dev/null | head -1)
|
||||
if [ -z "$maldet_dir" ]; then
|
||||
echo -e "${RED}✗ Cannot find extracted directory${NC}"
|
||||
echo " Available directories in /tmp:"
|
||||
ls -la /tmp | grep maldetect | sed 's/^/ /'
|
||||
cd /tmp
|
||||
rm -rf "maldetect-"*
|
||||
return 1
|
||||
@@ -303,10 +355,17 @@ install_all_scanners() {
|
||||
echo -e "${GREEN}✓ Maldet installed${NC}"
|
||||
rm -f "$install_log"
|
||||
|
||||
# Update malware signatures immediately
|
||||
# Update malware signatures immediately with timeout
|
||||
echo " → Updating malware signatures..."
|
||||
maldet -u 2>&1 | grep -E "update completed|signatures" || maldet -u &>/dev/null
|
||||
# Try to find maldet binary (might not be in PATH yet)
|
||||
local maldet_bin=$(command -v maldet || find /usr/local -name maldet -type f 2>/dev/null | head -1)
|
||||
if [ -n "$maldet_bin" ]; then
|
||||
if timeout 120 "$maldet_bin" -u 2>&1 | grep -qE "update completed|signatures"; then
|
||||
echo -e " ${GREEN}✓${NC} Signatures updated"
|
||||
else
|
||||
echo -e " ${YELLOW}⚠${NC} Signature update inconclusive (continuing with current definitions)"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ Maldet installation failed${NC}"
|
||||
|
||||
@@ -317,28 +376,13 @@ install_all_scanners() {
|
||||
echo ""
|
||||
echo -e "${YELLOW}Full log saved to: $install_log${NC}"
|
||||
fi
|
||||
|
||||
# Check for common Plesk issues
|
||||
if command -v plesk >/dev/null 2>&1; then
|
||||
echo -e "${YELLOW}Detected Plesk system - checking for conflicts...${NC}"
|
||||
|
||||
# Check if cron is accessible
|
||||
if [ ! -w /var/spool/cron ] && [ ! -w /etc/cron.d ]; then
|
||||
echo " → Cron directory permissions may be restricted"
|
||||
fi
|
||||
|
||||
# Check if required directories exist
|
||||
if [ ! -d /usr/local/sbin ]; then
|
||||
echo " → /usr/local/sbin does not exist (required for maldet)"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
echo -e "${RED}✗ Download failed - maldetect-current.tar.gz not found${NC}"
|
||||
return 1
|
||||
return 0
|
||||
fi
|
||||
) || true
|
||||
else
|
||||
echo -e "${GREEN}✓ Maldet already installed${NC}"
|
||||
fi
|
||||
@@ -356,20 +400,41 @@ install_all_scanners() {
|
||||
rm -f imav-deploy.sh
|
||||
fi
|
||||
|
||||
wget -q https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh
|
||||
# Download deployment script with timeout
|
||||
if timeout 30 wget -q -O imav-deploy.sh https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh 2>/dev/null; then
|
||||
if [ ! -f imav-deploy.sh ] || [ ! -s imav-deploy.sh ]; then
|
||||
echo -e "${RED} Failed to download installation script (empty file)${NC}"
|
||||
else
|
||||
# Run deployment script with timeout and capture output
|
||||
echo " → Running deployment script..."
|
||||
local deploy_log="/tmp/imav-deploy-$$.log"
|
||||
if timeout 300 bash imav-deploy.sh > "$deploy_log" 2>&1; then
|
||||
# Check if any actual installation happened
|
||||
if grep -qiE "installed|complete|success" "$deploy_log"; then
|
||||
echo " → Deployment script executed"
|
||||
else
|
||||
echo " → Deployment script ran (check for errors below)"
|
||||
fi
|
||||
|
||||
if [ -f imav-deploy.sh ]; then
|
||||
# Run deployment script with progress indicators
|
||||
bash imav-deploy.sh 2>&1 | grep -E "Installing|Installed|Complete|Error|Failed" || bash imav-deploy.sh
|
||||
rm -f imav-deploy.sh
|
||||
|
||||
# Enable cPanel UI plugin if installed
|
||||
if [ -f "/opt/alt/python35/share/imunify360/scripts/av-userside-plugin.sh" ]; then
|
||||
echo " → Enabling cPanel UI plugin..."
|
||||
/opt/alt/python35/share/imunify360/scripts/av-userside-plugin.sh &>/dev/null
|
||||
# Show any errors from deployment
|
||||
if grep -qi "error\|failed\|conflict" "$deploy_log"; then
|
||||
echo -e " ${YELLOW}⚠ Warnings detected:${NC}"
|
||||
grep -iE "error|failed|conflict" "$deploy_log" | sed 's/^/ /' | head -3
|
||||
fi
|
||||
else
|
||||
echo -e "${RED} Failed to download installation script${NC}"
|
||||
echo -e "${YELLOW} ⚠ Deployment script timed out or failed${NC}"
|
||||
fi
|
||||
rm -f "$deploy_log"
|
||||
rm -f imav-deploy.sh
|
||||
|
||||
# Try to start the service if installed
|
||||
if command -v systemctl &>/dev/null && is_imunify_installed; then
|
||||
echo " → Starting ImunifyAV service..."
|
||||
systemctl start imunify-antivirus 2>/dev/null || true
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "${RED} Failed to download installation script (network error or timeout)${NC}"
|
||||
fi
|
||||
|
||||
if is_imunify_installed; then
|
||||
@@ -382,11 +447,15 @@ install_all_scanners() {
|
||||
# Update malware signatures immediately
|
||||
if [ -n "$imunify_bin" ]; then
|
||||
echo " → Updating malware signatures..."
|
||||
$imunify_bin update 2>&1 | grep -E "updated|Success|completed" || $imunify_bin update &>/dev/null
|
||||
if timeout 60 "$imunify_bin" update 2>&1 | grep -qiE "updated|Success|completed"; then
|
||||
echo -e " ${GREEN}✓${NC} Signatures updated"
|
||||
else
|
||||
echo -e " ${YELLOW}⚠${NC} Signature update inconclusive (continuing with current definitions)"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ ImunifyAV installation failed${NC}"
|
||||
echo -e "${YELLOW} Note: ImunifyAV FREE is primarily supported on CloudLinux, cPanel, and Plesk systems${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${GREEN}✓ ImunifyAV already installed${NC}"
|
||||
@@ -398,17 +467,32 @@ install_all_scanners() {
|
||||
if ! is_rkhunter_installed; then
|
||||
echo -e "${CYAN}[4/4] Installing Rootkit Hunter...${NC}"
|
||||
|
||||
# Ensure EPEL repo is enabled
|
||||
if command -v yum &>/dev/null; then
|
||||
if ! rpm -qa | grep -q epel-release; then
|
||||
# Ensure repo is enabled (OS-specific)
|
||||
if command -v dnf &>/dev/null; then
|
||||
# CentOS 8+, RHEL 8+, Fedora - use dnf as primary package manager
|
||||
if ! rpm -qa 2>/dev/null | grep -q epel-release; then
|
||||
echo " → Installing EPEL repository..."
|
||||
yum install -y epel-release 2>&1 | grep -E "Installing|Installed|already installed"
|
||||
dnf install -y epel-release 2>&1 | grep -E "Installing|Installed|already installed" || echo " (repo may already be enabled)"
|
||||
fi
|
||||
|
||||
# Install rkhunter
|
||||
yum install -y rkhunter 2>&1 | grep -E "Installing|Installed|already installed"
|
||||
dnf install -y rkhunter 2>&1 | grep -E "Installing|Installed|already installed" || echo " (installation may already be complete)"
|
||||
elif command -v yum &>/dev/null; then
|
||||
# CentOS 7, RHEL 7 - use yum
|
||||
if ! rpm -qa 2>/dev/null | grep -q epel-release; then
|
||||
echo " → Installing EPEL repository..."
|
||||
yum install -y epel-release 2>&1 | grep -E "Installing|Installed|already installed" || echo " (repo may already be enabled)"
|
||||
fi
|
||||
# Install rkhunter
|
||||
yum install -y rkhunter 2>&1 | grep -E "Installing|Installed|already installed" || echo " (installation may already be complete)"
|
||||
elif command -v apt-get &>/dev/null; then
|
||||
apt-get update && apt-get install -y rkhunter
|
||||
# Debian/Ubuntu - universe repo (rkhunter is in universe)
|
||||
echo " → Ensuring universe repository is enabled..."
|
||||
if ! grep -q "universe" /etc/apt/sources.list 2>/dev/null; then
|
||||
# Add universe to existing deb lines (handles both HTTP and HTTPS)
|
||||
sed -i 's/^\(deb.*\) \(main\|restricted\)$/\1 \2 universe/' /etc/apt/sources.list 2>/dev/null || true
|
||||
apt-get update 2>&1 | grep -E "Hit|Get|Reading|Building" | head -3 || true
|
||||
fi
|
||||
apt-get install -y rkhunter 2>&1 | grep -E "Setting up|already|newest" || echo " (installation may already be complete)"
|
||||
fi
|
||||
|
||||
if is_rkhunter_installed; then
|
||||
@@ -416,13 +500,19 @@ install_all_scanners() {
|
||||
|
||||
# Update definitions
|
||||
echo " → Updating rootkit definitions..."
|
||||
rkhunter --update 2>&1 | grep -E "updated|downloaded" || rkhunter --update &>/dev/null
|
||||
if timeout 120 rkhunter --update 2>&1 | grep -qE "updated|downloaded"; then
|
||||
echo -e " ${GREEN}✓${NC} Definitions updated"
|
||||
else
|
||||
echo -e " ${YELLOW}⚠${NC} Definitions update inconclusive (continuing)"
|
||||
fi
|
||||
|
||||
# Initialize baseline (propupd creates file property database)
|
||||
echo " → Initializing baseline database..."
|
||||
rkhunter --propupd &>/dev/null
|
||||
if timeout 300 rkhunter --propupd 2>&1 | grep -q "Updating" || timeout 300 rkhunter --propupd &>/dev/null; then
|
||||
echo -e " ${GREEN}✓${NC} Baseline initialized"
|
||||
else
|
||||
echo -e " ${YELLOW}⚠${NC} Baseline initialization inconclusive"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ Rootkit Hunter installation failed${NC}"
|
||||
fi
|
||||
@@ -823,10 +913,51 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# If no scanners found, show installation guide and exit gracefully
|
||||
if [ ${#AVAILABLE_SCANNERS[@]} -eq 0 ]; then
|
||||
log_message "ERROR: No scanners found!"
|
||||
log_message "WARNING: No scanners found on this system"
|
||||
echo ""
|
||||
echo -e "${RED}No malware scanners detected!${NC}"
|
||||
exit 1
|
||||
echo ""
|
||||
echo -e "${YELLOW}Available Malware Scanners:${NC}"
|
||||
echo ""
|
||||
|
||||
echo -e "${CYAN}ImunifyAV${NC} - FREE real-time malware scanner"
|
||||
echo " Status: Not installed"
|
||||
echo " Installation (cPanel):"
|
||||
echo " yum install imunify-antivirus imunify-antivirus-cpanel"
|
||||
echo " /opt/alt/python35/share/imunify360/scripts/av-userside-plugin.sh"
|
||||
echo " Installation (manual):"
|
||||
echo " wget https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh"
|
||||
echo " bash imav-deploy.sh"
|
||||
echo " Docs: https://docs.imunify360.com/imunifyav/"
|
||||
echo ""
|
||||
|
||||
echo -e "${CYAN}ClamAV${NC} - Open source antivirus engine"
|
||||
echo " Status: Not installed"
|
||||
echo " Installation:"
|
||||
echo " yum install clamav clamav-update # RHEL/CentOS"
|
||||
echo " apt-get install clamav clamav-daemon # Debian/Ubuntu"
|
||||
echo ""
|
||||
|
||||
echo -e "${CYAN}Maldet (LMD)${NC} - Linux Malware Detect"
|
||||
echo " Status: Not installed"
|
||||
echo " Installation:"
|
||||
echo " cd /tmp && wget http://www.rfxn.com/downloads/maldetect-current.tar.gz"
|
||||
echo " tar -xzf maldetect-current.tar.gz && cd maldetect-*"
|
||||
echo " ./install.sh"
|
||||
echo ""
|
||||
|
||||
echo -e "${CYAN}Rootkit Hunter${NC} - Rootkit/backdoor/exploit scanner"
|
||||
echo " Status: Not installed"
|
||||
echo " Installation:"
|
||||
echo " yum install epel-release rkhunter # RHEL/CentOS"
|
||||
echo " apt-get install rkhunter # Debian/Ubuntu"
|
||||
echo ""
|
||||
|
||||
echo -e "${YELLOW}Recommendation:${NC} Install at least ClamAV + RKHunter (both free)"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
log_message "Found ${#AVAILABLE_SCANNERS[@]} scanner(s): ${AVAILABLE_SCANNERS[*]}"
|
||||
@@ -2181,20 +2312,33 @@ delete_standalone_sessions() {
|
||||
|
||||
# Main scan menu
|
||||
show_scan_menu() {
|
||||
# Ensure print_banner is available before calling it
|
||||
if ! declare -f "print_banner" &>/dev/null; then
|
||||
echo "ERROR: print_banner function not found" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Build reference database once for the entire menu session
|
||||
if command -v build_reference_database &>/dev/null; then
|
||||
echo "Building system reference database..."
|
||||
build_reference_database 2>/dev/null || true
|
||||
if command -v db_ensure_fresh &>/dev/null; then
|
||||
db_ensure_fresh 2>/dev/null || true
|
||||
clear
|
||||
fi
|
||||
|
||||
while true; do
|
||||
print_banner "Malware Scanner"
|
||||
# Call print_banner - MUST succeed
|
||||
print_banner "Malware Scanner" || {
|
||||
echo "ERROR: print_banner failed" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "Available Scanners:"
|
||||
if [ ${#available_scanners[@]} -eq 0 ]; then
|
||||
echo " (None currently installed)"
|
||||
else
|
||||
for scanner in "${available_scanners[@]}"; do
|
||||
echo " • ${scanner^}"
|
||||
done
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo -e "${CYAN}Create New Scan:${NC}"
|
||||
@@ -2540,10 +2684,17 @@ generate_client_report() {
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
if ! detect_scanners; then
|
||||
exit 1
|
||||
# Detect scanners (populate available_scanners array)
|
||||
# Don't exit if none found - menu option 9 allows installation
|
||||
detect_scanners || true
|
||||
|
||||
# Verify show_scan_menu exists and is callable
|
||||
if ! declare -f "show_scan_menu" &>/dev/null; then
|
||||
echo "ERROR: show_scan_menu function not found" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Call the menu function
|
||||
show_scan_menu
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user