[ SEA-GHOST MINI SHELL]

Path : /proc/3/cwd/var/lib/zabbix/
FILE UPLOADER :
Current File : //proc/3/cwd/var/lib/zabbix/ipsec.check.sh

#!/bin/bash

# https://github.com/a-schild/zabbix-ipsec.git
# to check ipsec tunnels
# 0 - "Tunnel $CONN not ESTABLISHED"
# 1 - "Tunnel $CONN look ok" 
# 2 - "Tunnel $CONN established without route"
# 3 - "CRITICAL - $IPSECBIN not exist"
# 4 - "Can not find any tunnel up for $CONN, let start it"

# ------------------------------------------
IPV4_REGEX="(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])"
IPSECBIN="/usr/sbin/ipsec"
# ------------------------------------------
# Testing availability of $IPSECBIN, $FPINGBIN and $GATEWAYLIST

test -e $IPSECBIN
if [ $? -ne 0 ]; then
    #echo CRITICAL - $IPSECBIN not exist
    return 3
    exit $STATE_CRITICAL
else
    STRONG=`$IPSECBIN --version |grep strongSwan | wc -l`
fi

test_tunnel() {
    CONN="$1"
    if [[ "$STRONG" -eq "1" ]]; then
        if [[ $(ipsec status | grep -e "$CONN") ]]; then
            if [[ $(ipsec status | grep -e "$CONN" | grep -e "ESTABLISHED") ]] || [[ $(ipsec status | grep -e "$CONN" | grep -e "IPsec SA established" | grep -e "newest") ]]; then
                if [[ $(ipsec status | grep -e "$CONN" | grep -v "ESTABLISHED" | grep -E "$IPV4_REGEX") ]]; then
                    # echo " Tunnel $CONN look ok"
                    return 1
                else
                    # echo "Tunnel $CONN established without route"
                    return 2
                fi
            else
                # echo "Tunnel $CONN not ESTABLISHED"
                return 0
            fi
        else
            # echo "Can not find any tunnel up for $CONN, let start it"
            return 4
        fi
    fi

}

test_tunnel $1
echo $?


SEA-GHOST - SHELL CODING BY SEA-GHOST