⚝
One Hat Cyber Team
⚝
Your IP:
18.216.241.11
Server IP:
162.254.39.145
Server:
Linux premium289.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib64
/
nagios
/
plugins
/
nccustom
/
View File Name :
check-cpanel-update.sh
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin resultFile="/var/log/nc_audit/check_sec_updates" agetreshold=16 # 16 hours #input option PROGNAME=${0##*/} print_usage() { echo "" echo "Usage: $PROGNAME [-f Diff path] [-a file Age treshold, hours]" echo "Usage: $PROGNAME -h | --help" } print_help() { print_usage echo "" echo "This script check cPanel security updates (see TOP-347)" echo "" echo "-f Different path and file. Default - /var/log/nc_audit/check_sec_updates" echo "-a Age treshold for logfiles, hours. Default - 16" echo "-h help Print this help screen" echo "--help Print this help screen" echo "" exit 3 } while [ $# -gt 0 ]; do case "$1" in -f) resultFile=$2; shift ;; -a) agetreshold=$2; shift ;; --help) print_help exit 3 ;; -h) print_help exit 3 ;; *) echo >&2 "Unknown argument: $1" print_usage exit 3 ;; esac shift done #file existence if [ ! -f "$resultFile" ]; then echo "UNKNOWN. $resultFile no file" exit 3 fi #check age file resultFileAge=$((($(date +%s) - $(date +%s -r "${resultFile}")) / 3600)) # in hours if (( resultFileAge > agetreshold )) ; then echo "UNKNOWN. File ${resultFile} older than ${agetreshold} hours" exit 3 fi #checking file status read -r firstline<"$resultFile" firstline_code=$(echo "${firstline}" | awk '{print$1}' | sed 's/\[\|\]://g') case "${firstline_code}" in "OK" ) exitcode="0" ;; "FAILED" | "CRITICAL" ) exitcode="2" ;; * ) #Unknown state firstline="UNKNOWN. String from $resultFile does not match any pattern" exitcode="3" ;; esac echo "$firstline" exit "$exitcode"