mgeeky-Penetration-Testing-.../linux/toggleWaf.sh

40 lines
900 B
Bash
Raw Normal View History

2020-05-05 15:03:36 +02:00
#!/bin/bash
modname=security2
friendlyname=WAF
if [ $# -ne 1 ]; then
echo "Usage: ./toggleWaf <on|off|status>"
exit 1
fi
case $1 in
"on")
if [ $EUID -ne 0 ]; then
echo "[!] This function must be run as root. Use sudo."
exit 1
fi
a2enmod $modname > /dev/null
systemctl reload apache2
echo "[+] $friendlyname enabled."
;;
"off")
if [ $EUID -ne 0 ]; then
echo "[!] This function must be run as root. Use sudo."
exit 1
fi
a2dismod $modname > /dev/null
systemctl reload apache2
echo "[-] $friendlyname disabled."
;;
"status")
if a2query -m $modname 2> /dev/null | grep -q 'enabled' ; then
echo "[+] $friendlyname is enabled."
else
echo "[-] $friendlyname is disabled."
fi
;;
esac