Shell script exec

This section describes how you can enable shell script execute when client is bad for different triggers.

Just an example, the plugin is configured to trigger on registration when report_value >= 10, report_count >= 1, report_reliability >= 3.00

The standard capabilities of the module will allow you to add a client to a special group in BILLmanager, as well as send a notification to the administrator. But not all reports are the same, not all clients are equally dangerous.

Flexibility in how to react to different triggers may be required. You can add any checks, for example, use third-party APIs to check the registration IP address, check the IP address for belonging to TOR, VPN or Proxy. Based on several factors, apply certain sanctions to the client. From the script, you can directly access the BILLmanager API (using the cli mgrctl utility) or make requests directly to the BILLmanager database. React differently for clients, for example, if report_value >= 10 and report_value < 20, then send the client to KYC, if report_value >= 20 and the email ends with proton.me, then immediately block the client, etc. In theory, you can even connect AI to analyze client data.

Configure parameters

Settings

Enter values to get shell script execute after trigger

SettingDescription
Use for triggersSelect when module need to execute shell script
Shell script or commandCan be command or full path to script with all params to execute

Shortcodes

You can use shortcodes in shell script\command parameters. When shell script execute, plugin will replace shortcodes with actual values.

ShortcodeDescription
{check_type}Check type: manual or auto
{account_id}Client account ID
{reg_ip}Client register IP address
{reg_email}Email address of the main user of the client
{report_value}Sum of the all report values sent for the client
{report_count}Number of report sent for the client
{report_reliability}Report Reliability, indicates how many times client reported and queried
{report_code}Report code, you can check result, just add it to the URL: https://fraud.hosting/api/?showreport=

Example scripts

Block client account after registration if report_value >= 20

Shell script command in the FraudHosting module settings:

/usr/local/mgr5/user_blocker.sh {check_type} {account_id} {report_value}

Script content:

#!/bin/bash
check_type="$1"
account_id="$2"
report_value="$3"
logfile='/usr/local/mgr5/var/user_blocker.log'

echo "$(date): Script user_blocker started" >> $logfile

if [[ $check_type != 'auto' ]]; then
  echo "$(date): Script executed from manual check, exit" >> $logfile
  exit 0
else
  echo "$(date): Script executed from auto check, continue" >> $logfile
fi

if [ $report_value -gt 20 ]; then
  echo "$(date): report_value >= 20, need to block client" >> $logfile

  user_ids=$(/usr/local/mgr5/sbin/mysql-billmgr <<< "SELECT id AS user_id FROM user WHERE account=$account_id and enabled='on'" | grep -v 'user_id')
  echo "$(date): Got enabled user_ids for client: $user_ids" >> $logfile

  while read user_id; do
    echo "$(date): Blocking user_id: $user_id" >> $logfile
    /usr/local/mgr5/sbin/mgrctl -m billmgr user.suspend elid=$user_id
  done < <(echo "$user_ids")
else
  echo "$(date): report_value < 20, skip client" >> $logfile
fi

echo "$(date): Script user_blocker ended" >> $logfile

Send client to KYC procedure for all checks

Shell script command in the FraudHosting module settings:

/usr/local/mgr5/sbin/mgrctl -m billmgr kyc.check account_id={account_id}

In this case we have custom function kyc.check that handle verification procedure. We just execute it, then another custom module processing the client KYC.