ROOTPLOIT
Server: Apache
System: Linux node6122.myfcloud.com 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64
User: bashacomputer (1004)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib64/nagios/plugins/a2_csf_modsecsync.mvps.mdedi
#!/bin/bash
#
# Ensure CSF and Modsec are in sync - OPSPROJ-8

imunify360_binary="/usr/sbin/imunify360-webshield"

# Skip unsupported (MWP) Plesk type servers
if [ -f /sbin/plesk ]; then
  exit
fi

# CSF is not supported if Imunify360 is installed.
if [ -f "${imunify360_binary}" ]; then
  exit
fi

# CSF may be unmanaged - SYSENG-14499
if [ -f /opt/csf_unmanaged ]; then
  echo "OK - unmanaged"
  exit 0
fi

cmk_name="csfmodsec_sync"
csf_sync="/etc/csf/a2_sync"
modsec_sync="/etc/apache2/conf.d/modsec/a2_sync"

cfm_get_status=$(/opt/bin/cfm_control status)
cfm_type=$(echo ${cfm_get_status} | awk '{print $2}' | sed 's/://')

if echo "${cfm_get_status}" | grep -q active; then
  exit_status=2
  cfm_status="active"
else
  exit_status=1
  cfm_status="downtimed"  
fi

if [ -f ${csf_sync} ] && [ -f ${modsec_sync} ]; then
  echo "CSF and Modsec is in sync"
  exit 0
elif [ ! -f ${csf_sync} ] && [ -f ${modsec_sync} ]; then
  echo "CSF is not in sync and ${cfm_type} is ${cfm_status}"
  exit ${exit_status}
elif [ -f ${csf_sync} ] && [ ! -f ${modsec_sync} ]; then
  echo "Modsec is not in sync and ${cfm_type} is ${cfm_status}"
  exit ${exit_status}
elif [ ! -f ${csf_sync} ] && [ ! -f ${modsec_sync} ]; then
  echo "CSF and Modsec is not in sync and ${cfm_type} is ${cfm_status}"
  exit ${exit_status}
fi