AnonSec Shell
Server IP : 162.0.209.157  /  Your IP : 13.58.103.70   [ Reverse IP ]
Web Server : LiteSpeed
System : Linux premium178.web-hosting.com 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64
User : balaoqob ( 2395)
PHP Version : 8.0.30
Disable Function : NONE
Domains : 1 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib64/nagios/plugins/nccustom/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib64/nagios/plugins/nccustom/check_cwaf.sh
#!/bin/bash

#########################################################
#							#
# Check updates for CWAF client and rules		#
# created by Max.N v 0.0.3				#
#							#
#########################################################

CWAFDIR="/var/cpanel/cwaf/scripts"
CWAFRULES="updater.pl"
CWAFCLIENT="update-client.pl"
TMPFILE="/tmp/cwaf.lock"
ALERTTIME="24"
UNIXTIME=$(date +%s)
re='^[0-9.]+$'
#warn="\b\b"

function SCHEDULER() {
#LASTCHANGES=$(grep -m1 "[0-9]*" ${TMPFILE})
#echo $((${UNIXTIME} - ${LASTCHANGES})) $((${ALERTTIME} * 60))
if [ -f ${TMPFILE} ]; then
    LASTCHANGES=$(grep -m1 "[0-9]*" ${TMPFILE})
    if [ $((${UNIXTIME} - ${LASTCHANGES})) -le $((${ALERTTIME} * 60 * 60)) ]
    then
	#echo "lock file exist"
        warn="Alert scheduled. ${warn}"
        exitcode=0
    fi
else 
    echo ${UNIXTIME} > ${TMPFILE}
    warn="Alert scheduled. ${warn}"
    exitcode=0
fi
}

#ARR1=($(sudo ${CWAFDIR}/${CWAFRULES} --version | grep -owP "(?<=rules version=)(\d+\.?\d+)"))
#ARR2=($(sudo ${CWAFDIR}/${CWAFCLIENT} --version | grep -owP "(?<= version=)(\d+\.?\d+)"))


ARR1=($(sudo ${CWAFDIR}/${CWAFRULES} --version | awk -F 'rules version=' '{print $2}'))
ARR2=($(sudo ${CWAFDIR}/${CWAFCLIENT} --version | awk -F 'version=' '{print $2}'))


#ARR ("current ver" "avalible ver")
#ARR1=(1 2) #catch to array vars from updater.pl --version
#ARR2=(1 2) #catch to array vars from update-client.pl --version

#clietn ver https://waf.comodo.com/doc/version.dat and local /etc/cwaf/version.dat

if [ -z "${ARR1[1]}" ] ||  [ -z "${ARR2[1]}" ]
then 
    warn="Can't check latest version."
fi 



if ! [[ "${ARR1[1]}" =~ $re ]]
then
    warn="${warn} ${ARR1[@]:1}."

elif ! [[ "${ARR2[1]}" =~ $re ]]
then
    warn="${warn} ${ARR2[@]:1}."

elif ! [[ "${ARR2[1]}" =~ $re ]] && [[ "${ARR2[1]}" =~ $re ]]
then
    warn="${warn} ${ARR1[@]:1} and ${ARR2[@]:1}."
fi



if [ "${ARR1[0]}" == "${ARR1[1]}" ] && [ "${ARR2[0]}" == "${ARR2[1]}" ]
then
    echo "[OK]"
    rm -f ${TMPFILE}
    exit 0
elif [ "${ARR1[0]}" != "${ARR1[1]}" ] && [ "${ARR2[0]}" != "${ARR2[1]}" ]
then
    out="client and rules"
    exitcode="2"
elif [ "${ARR1[0]}" != "${ARR1[1]}" ]
then 
    out="CWAF rules"
    exitcode="2"
elif [ "${ARR2[0]}" != "${ARR2[1]}" ]
then
    out="CWAF client"
    exitcode="2"
else
    warn="check license can't stat current version"
    out="CWAF"
    exitcode="2"
fi

SCHEDULER

echo -e "[CRITICAL]: ${warn} Please check updates for ${out} manually."| sed -e 's% [[:space:]]*% %g'


exit "${exitcode}"





Anon7 - 2022
AnonSec Team