mirror of
https://github.com/vernu/vps-audit.git
synced 2025-01-23 13:35:06 +03:00
Update vps-audit.sh
Feature: Added support for firewalld, iptables, and nftables in addition to UFW.
This commit is contained in:
parent
07abec919f
commit
0173a4f599
62
vps-audit.sh
62
vps-audit.sh
@ -135,12 +135,62 @@ else
|
|||||||
check_security "SSH Port" "PASS" "Using non-default port $SSH_PORT which helps prevent automated attacks"
|
check_security "SSH Port" "PASS" "Using non-default port $SSH_PORT which helps prevent automated attacks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check UFW status
|
# Check Firewall Status
|
||||||
if ufw status | grep -q "active"; then
|
check_firewall_status() {
|
||||||
check_security "Firewall Status" "PASS" "UFW firewall is active and protecting your system"
|
if command -v ufw >/dev/null 2>&1; then
|
||||||
else
|
if ufw status | grep -q "active"; then
|
||||||
check_security "Firewall Status" "FAIL" "UFW firewall is not active - your system is exposed to network attacks"
|
check_security "Firewall Status (UFW)" "PASS" "UFW firewall is active and protecting your system"
|
||||||
fi
|
else
|
||||||
|
check_security "Firewall Status (UFW)" "FAIL" "UFW firewall is not active - your system is exposed to network attacks"
|
||||||
|
fi
|
||||||
|
elif command -v firewall-cmd >/dev/null 2>&1; then
|
||||||
|
if firewall-cmd --state 2>/dev/null | grep -q "running"; then
|
||||||
|
check_security "Firewall Status (firewalld)" "PASS" "Firewalld is active and protecting your system"
|
||||||
|
else
|
||||||
|
check_security "Firewall Status (firewalld)" "FAIL" "Firewalld is not active - your system is exposed to network attacks"
|
||||||
|
fi
|
||||||
|
elif command -v iptables >/dev/null 2>&1; then
|
||||||
|
if iptables -L | grep -q "Chain INPUT"; then
|
||||||
|
check_security "Firewall Status (iptables)" "PASS" "iptables rules are active and protecting your system"
|
||||||
|
else
|
||||||
|
check_security "Firewall Status (iptables)" "FAIL" "No active iptables rules found - your system may be exposed"
|
||||||
|
fi
|
||||||
|
elif command -v nft >/dev/null 2>&1; then
|
||||||
|
if nft list ruleset | grep -q "table"; then
|
||||||
|
check_security "Firewall Status (nftables)" "PASS" "nftables rules are active and protecting your system"
|
||||||
|
else
|
||||||
|
check_security "Firewall Status (nftables)" "FAIL" "No active nftables rules found - your system may be exposed"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
check_security "Firewall Status" "FAIL" "No recognized firewall tool is installed on this system"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to check and report with three states
|
||||||
|
check_security() {
|
||||||
|
local test_name="$1"
|
||||||
|
local status="$2"
|
||||||
|
local message="$3"
|
||||||
|
|
||||||
|
case $status in
|
||||||
|
"PASS")
|
||||||
|
echo -e "${GREEN}[PASS]${NC} $test_name ${GRAY}- $message${NC}"
|
||||||
|
echo "[PASS] $test_name - $message" >> "$REPORT_FILE"
|
||||||
|
;;
|
||||||
|
"WARN")
|
||||||
|
echo -e "${YELLOW}[WARN]${NC} $test_name ${GRAY}- $message${NC}"
|
||||||
|
echo "[WARN] $test_name - $message" >> "$REPORT_FILE"
|
||||||
|
;;
|
||||||
|
"FAIL")
|
||||||
|
echo -e "${RED}[FAIL]${NC} $test_name ${GRAY}- $message${NC}"
|
||||||
|
echo "[FAIL] $test_name - $message" >> "$REPORT_FILE"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "" >> "$REPORT_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Firewall check
|
||||||
|
check_firewall_status
|
||||||
|
|
||||||
# Check for unattended upgrades
|
# Check for unattended upgrades
|
||||||
if dpkg -l | grep -q "unattended-upgrades"; then
|
if dpkg -l | grep -q "unattended-upgrades"; then
|
||||||
|
Loading…
Reference in New Issue
Block a user