Files
2025-03-24 21:28:20 +00:00

29 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# run this every 10 mins
# if string is found in apache2 log, last 10 minutes, then disable the ufw
RDT=$(grep 93048r7203498v093840r2934870r29380h4fr239nh840r27840ndr489 /var/log/apache2/access.log | tail -1 | awk '$0=$2' FS=[ RS=] |sed -e 's,/,-,g' -e 's,:, ,')
if [[ ${RDT} > '' ]]; then
DT=$(date --date="${RDT}" +"%s")
NOW=$(date +"%s")
(( SECS = NOW - DT ))
# echo "$RDT, $DT, $NOW, $SECS"
if [[ ${SECS} -lt 700 ]] ; then
echo "will stop the FW"
addEvent.sh "ERROR,ufw,0,0,Firewall has been stopped by apache-log (ignace code)"
ufw disable
fi
fi
RDT=$(grep 648934852480922541718468161210828654060355211868993811248702 /var/log/apache2/access.log | tail -1 | awk '$0=$2' FS=[ RS=] |sed -e 's,/,-,g' -e 's,:, ,')
if [[ ${RDT} > '' ]]; then
DT=$(date --date="${RDT}" +"%s")
NOW=$(date +"%s")
(( SECS = NOW - DT ))
# echo "$RDT, $DT, $NOW, $SECS"
if [[ ${SECS} -lt 700 ]] ; then
echo "will reset the FW"
addEvent.sh "ERROR,ufw,0,0,Firewall has been reset by apache-log (severines code)"
/opt/Monitor/fw/reset
fi
fi