LittleDemon WebShell


Linux sh105.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
Path : /opt/
File Upload :
Command :
Current File : //opt/abuse_history.sh

#!/bin/bash
domains=( `blmodsec list | awk '/DOMAIN/ {print $2}'` )
prom_file="/opt/nf-observability/prometheus/data/modsecblock.prom"
if [[ -z $domains ]]; then
  rm -f $prom_file
else
cat <<EOF > "$prom_file"
# HELP modsec_blacklist_rule_duration_seconds Duration of ModSec rule in seconds
# TYPE modsec_blacklist_rule_duration_seconds gauge
EOF
chown grafana-agent:grafana-agent $prom_file
for domain in ${domains[@]}; do
  file=$(grep -ril "$domain" /opt/mod_security/blacklists/ | head -n1)
  expiry_epoch=$(grep -m1 '^#' $file | awk '{print $4}')
  created_epoch=$(stat -c %Y "$file")
  duration=$((expiry_epoch - created_epoch))
  prom_file="/opt/nf-observability/prometheus/data/modsecblock.prom"
  echo "modsec_blacklist_rule_duration_seconds{domain=\"$domain\",expiry=\"$expiry_epoch\"} $duration" >> "$prom_file"
done
fi

suspended_users=( `grep -l '^SUSPENDED=1' /var/cpanel/users/* | xargs -n1 basename` )
prom_file1="/opt/nf-observability/prometheus/data/suspended_users.prom"
if [[ -z $suspended_users ]]; then
  rm -f ${prom_file1}
else
cat <<EOF > "$prom_file1"
# HELP suspended_accounts_list Number of suspensions per account
# TYPE suspended_accounts_list gauge
EOF
chown grafana-agent:grafana-agent $prom_file1
for user in ${suspended_users[@]}; do
  domain_owned=$(awk -F': ' -v d="$user" '$1 == d { print $2 }' /etc/domainusers)
  current_time=$(date +%s)
  created_epoch=$(stat -c %Y /var/cpanel/suspended/$user)
  duration=$((current_time - created_epoch))
  echo "suspended_accounts_list{cpanel_user=\"$user\",domain=\"$domain_owned\",timestamp=\"$created_epoch\"} $duration" >> "$prom_file1"
done
fi

LittleDemon - FACEBOOK
[ KELUAR ]