WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
GIF89a;

Priv8 Uploader By InMyMine7

Linux usa-ref 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
GIF89a;

Priv8 Uploader By InMyMine7

Linux usa-ref 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
GIF89a;

Priv8 Uploader By InMyMine7

Linux usa-ref 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
403WebShell
403Webshell
Server IP : 140.82.29.182  /  Your IP : 216.73.217.73
Web Server : nginx/1.18.0
System : Linux usa-ref 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home//monthly_security_report.sh
#!/bin/bash
# =========================================================================
# MONTHLY SECURITY REPORT GENERATOR
#
# Isko cron se monthly chalao (setup instructions neeche hain). Ye:
#   - Is mahine ke ClamAV scan logs se threats count karta hai
#   - Fail2ban ka ban activity dekhta hai
#   - Disk space, SSL, WP plugin status quick-recheck karta hai
#   - Ek report file banata hai
#   - Excel "Monthly Scan Log" tab ke format mein ek CSV row bhi append karta hai
#
# MANUAL USAGE (test karne ke liye):
#   sudo ./monthly_security_report.sh
#
# CRON SETUP (1 tareekh, subah 6 baje, har mahine):
#   sudo crontab -e
#   Add this line:
#   0 6 1 * * /home/monthly_security_report.sh >> /var/log/monthly-report-cron.log 2>&1
# =========================================================================

WEB_ROOT_OVERRIDE="$1"
HOSTNAME_TAG=$(hostname)
MONTH_TAG=$(date +"%b %Y")          # e.g. "Aug 2026"
DATE_TAG=$(date +%Y-%m-%d)
REPORT_DIR="/root/monthly-security-reports"
REPORT="$REPORT_DIR/monthly_report_${HOSTNAME_TAG}_$(date +%Y-%m).txt"
CSV_LOG="$REPORT_DIR/monthly_scan_log_${HOSTNAME_TAG}.csv"

mkdir -p "$REPORT_DIR"

if [ ! -f "$CSV_LOG" ]; then
    echo "Month,Server Name,Scan Tool Used,Scan Date,Threats Found,Threats Removed/Quarantined,Report Sent To,Report Location/Link,Reviewed By,Notes" > "$CSV_LOG"
fi

{
echo "======================================================================="
echo " MONTHLY SECURITY REPORT — $HOSTNAME_TAG — $MONTH_TAG"
echo " Generated: $(date)"
echo "======================================================================="
echo ""

# ---------------------------------------------------------------------
echo "-----------------------------------------------------------------"
echo "1. CLAMAV SCAN SUMMARY (this month)"
echo "-----------------------------------------------------------------"
CLAM_LOG="/var/log/clamav-weekly-scan.log"
THREATS_FOUND=0
LAST_SCAN_DATE="No scan log found"

if [ -f "$CLAM_LOG" ]; then
    LAST_SCAN_DATE=$(date -r "$CLAM_LOG" +%Y-%m-%d 2>/dev/null)
    THREATS_FOUND=$(grep -c "FOUND" "$CLAM_LOG" 2>/dev/null)
    echo "Log file: $CLAM_LOG"
    echo "Last modified: $LAST_SCAN_DATE"
    echo "Infected files found (all-time in this log): $THREATS_FOUND"
    if [ "$THREATS_FOUND" -gt 0 ]; then
        echo ""
        echo "Details:"
        grep "FOUND" "$CLAM_LOG" | sed 's/^/  /'
    fi
else
    echo "No ClamAV scan log found at $CLAM_LOG — scan may not have run yet, or ClamAV not installed/scheduled."
fi
echo ""

# ---------------------------------------------------------------------
echo "-----------------------------------------------------------------"
echo "2. FAIL2BAN ACTIVITY (this month)"
echo "-----------------------------------------------------------------"
if command -v fail2ban-client >/dev/null 2>&1; then
    BAN_COUNT=$(fail2ban-client status sshd 2>/dev/null | grep "Total banned" | awk -F: '{print $2}' | xargs)
    echo "Total banned (all-time, sshd jail): ${BAN_COUNT:-0}"
    CURRENTLY_BANNED=$(fail2ban-client status sshd 2>/dev/null | grep "Banned IP list" | cut -d: -f2)
    echo "Currently banned IPs: ${CURRENTLY_BANNED:-none}"
else
    echo "Fail2ban not installed — no data."
fi
echo ""

# ---------------------------------------------------------------------
echo "-----------------------------------------------------------------"
echo "3. SYSTEM HEALTH QUICK CHECK"
echo "-----------------------------------------------------------------"
df -h / | awk 'NR==2{print "Disk usage: "$3" / "$2" ("$5" used, "$4" free)"}'
if [ "$(df / | awk 'NR==2{print $5}' | tr -d '%')" -ge 85 ] 2>/dev/null; then
    echo "  >>> WARNING: disk usage above 85%"
fi
echo ""
if command -v apt >/dev/null 2>&1; then
    UPGRADABLE=$(apt list --upgradable 2>/dev/null | grep -c upgradable)
    echo "Pending package updates: $UPGRADABLE"
fi
echo ""

# ---------------------------------------------------------------------
echo "-----------------------------------------------------------------"
echo "4. WORDPRESS QUICK STATUS (auto-detected)"
echo "-----------------------------------------------------------------"
SEARCH_ROOT="${WEB_ROOT_OVERRIDE:-/var/www}"
[ ! -d "$SEARCH_ROOT" ] && SEARCH_ROOT="/home"
WP_SITES=$(find "$SEARCH_ROOT" -maxdepth 4 -iname "wp-config.php" 2>/dev/null)
TOTAL_OUTDATED_PLUGINS=0

if [ -z "$WP_SITES" ]; then
    echo "No WordPress sites detected under $SEARCH_ROOT."
else
    for cfg in $WP_SITES; do
        SITE_DIR=$(dirname "$cfg")
        SITE_OUTDATED=0
        if [ -d "$SITE_DIR/wp-content/plugins" ]; then
            for pdir in "$SITE_DIR"/wp-content/plugins/*/; do
                pslug=$(basename "$pdir")
                pver=$(grep -riE "^[[:space:]]*\*?[[:space:]]*Version:" "$pdir"*.php 2>/dev/null | head -1 | sed -E 's/.*[Vv]ersion:[[:space:]]*//' | tr -d '\r' | xargs)
                [ -z "$pver" ] && continue
                platest=$(curl -s "https://api.wordpress.org/plugins/info/1.0/${pslug}.json" | grep -o '"version":"[^"]*"' | head -1 | cut -d\" -f4)
                if [ -n "$platest" ] && [ "$pver" != "$platest" ]; then
                    SITE_OUTDATED=$((SITE_OUTDATED+1))
                fi
            done
        fi
        echo "$SITE_DIR -> $SITE_OUTDATED outdated plugin(s)"
        TOTAL_OUTDATED_PLUGINS=$((TOTAL_OUTDATED_PLUGINS+SITE_OUTDATED))
    done
fi
echo ""

echo "======================================================================="
echo " END OF MONTHLY REPORT"
echo "======================================================================="

} | tee "$REPORT"

# ---------------------------------------------------------------------
# Append a row to the CSV log (matches Excel "Monthly Scan Log" tab columns)
# ---------------------------------------------------------------------
if [ "$THREATS_FOUND" -gt 0 ]; then
    THREAT_NOTE="Review clamav log for details, decide removed/quarantined manually"
else
    THREAT_NOTE="Clean scan"
fi

echo "\"$MONTH_TAG\",\"$HOSTNAME_TAG\",\"ClamAV\",\"$LAST_SCAN_DATE\",\"$THREATS_FOUND\",\"$THREAT_NOTE\",\"\",\"$REPORT\",\"\",\"$TOTAL_OUTDATED_PLUGINS outdated WP plugins across all sites this run\"" >> "$CSV_LOG"

echo ""
echo "Report saved: $REPORT"
echo "CSV log updated: $CSV_LOG"
echo "Is CSV row ko Excel 'Monthly Scan Log' tab mein paste kar do (Report Sent To / Reviewed By columns manually bhar dena)."

Youez - 2016 - github.com/yon3zu
LinuXploit