From bbbb5d95bf992fb14f28546d43d53d98b29dca3b Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 4 Dec 2025 17:43:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20paranoia-shutdown.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- paranoia-shutdown.sh | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 paranoia-shutdown.sh diff --git a/paranoia-shutdown.sh b/paranoia-shutdown.sh new file mode 100644 index 0000000..635a062 --- /dev/null +++ b/paranoia-shutdown.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +allowIp=$2 +pidFile="/var/run/paranoia-shutdown.pid" + +start(){ + + echo $$ > "$pidFile" + + tail -f -n0 /var/log/auth.log | while read string + do + if echo "$string" | grep "Accepted password for" + then + ip=$(echo "$string" | grep -o -E '([0-9]{1,3}[\.]){3}[0-9]{1,3}') + + if [ "$ip" != "$allowIp" ] + then + logger "Alert!!! Alert!!! Alert!!! Login from not confirmed ip $ip. Faster shutdown!" + systemctl poweroff + fi + fi + done +} + +stop(){ + + kill $(cat "$pidFile") + +} + +case "$1" in + start) + start;; + + stop) + stop;; + + restart) + stop + sleep 3 + start + ;; + *) + + echo $"Usage: $0 {start|stop|restart}" + exit 3 +esac