aboutsummaryrefslogtreecommitdiff
path: root/check_ssh_geoip.sh
diff options
context:
space:
mode:
Diffstat (limited to 'check_ssh_geoip.sh')
-rwxr-xr-xcheck_ssh_geoip.sh60
1 files changed, 0 insertions, 60 deletions
diff --git a/check_ssh_geoip.sh b/check_ssh_geoip.sh
deleted file mode 100755
index 05a77ac..0000000
--- a/check_ssh_geoip.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-
-if [ x"${BASH_VERSINFO}" = x ]; then
- echo "BASH_VERSINFO not found. Is \`/bin/bash\` a valid bash interpreter?"
- exit 1
-fi
-if [ "${BASH_VERSINFO}" -lt 4 ]; then
- echo "Bash version >= 4 required for declaring/using arrays/dicts."
- exit 1
-fi
-
-export DESTHOST="host.lan"
-export DESTUSER="someuser"
-
-if [ x"$1" != x ]; then
- DEST="$1"
-else
- DEST="${DESTUSER}@${DESTHOST}"
-fi
-
-if [ x"$2" != x ]; then
- LOGCMD="$2"
-else
- LOGCMD="logread"
-fi
-
-if [ x"$3" != x ]; then
- LOGREP="$3"
-else
- LOGREP="dropbear"
-fi
-
-LINE="-------------------------"
-IFS=' ';
-OUT=$(ssh -o LogLevel=Error ${DEST} ${LOGCMD} | \
- sed -ne 's/.*'"${LOGREP}"'.*\s\+\([0-9\.]\+\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p' | \
- uniq | tr '\n' ' ')
-declare -A ORIGINS
-for host in ${OUT}; do \
- echo "${host}" | grep -qoE '(192.168.|10.10.|172.)'
- [ $? -eq 0 ] && continue
- echo "${LINE}"
- echo "HOST: ${host}"
- GEOIP=$(geoiplookup "${host}")
- if [ x"${ORIGINS["${GEOIP}"]}" != x ]; then
- ORIGINS["${GEOIP}"]=$(expr ${ORIGINS["${GEOIP}"]} + 1)
- else
- ORIGINS["${GEOIP}"]=1
- fi
- echo "${GEOIP}"
-done
-
-echo "${LINE}"
-echo -e "${LINE}\nEOF"
-echo "${LINE}"
-
-echo "COUNTRY STATS"
-for origin in "${!ORIGINS[@]}"; do
- echo "${origin} -> ${ORIGINS["${origin}"]}"
-done