Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Mehani <shtrom@ssji.net>2017-08-15 13:07:43 +0200
committerOlivier Mehani <shtrom@ssji.net>2017-08-17 12:26:59 +0200
commitef40366c9864c0ce405395be6124b7f580354f0b (patch)
tree103f4f22044fccef66adbf338d0ea8431d832dfc
parentadd51fb4fbcf99f316c4498f80c658819bee746e (diff)
[denyhosts] Fix SSH blockers log
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
-rwxr-xr-xopenbsd/denyhost.sh15
1 files changed, 8 insertions, 7 deletions
diff --git a/openbsd/denyhost.sh b/openbsd/denyhost.sh
index ea82369..c9a21d6 100755
--- a/openbsd/denyhost.sh
+++ b/openbsd/denyhost.sh
@@ -143,22 +143,23 @@ NEW_BLOCKERS_FILE=$(mktemp ${TMP_DIR}/denyhost.blockers.list.XXXXXX)
# HTTP exploiters
HTTP_FILTERED_LOG=$(mktemp ${TMP_DIR}/denyhost.http.log.XXXXXX)
grep ${HTTP_PATTERN} ${HTTP_LOG} \
- | cut -d" " -f 2 \
+ > ${HTTP_FILTERED_LOG}
+cut -d" " -f 2 ${HTTP_FILTERED_LOG} \
| sort \
| uniq \
- > ${HTTP_FILTERED_LOG}
-cat ${HTTP_FILTERED_LOG} > ${NEW_BLOCKERS_FILE}
+ > ${NEW_BLOCKERS_FILE}
# SSH exploiters
SSH_FILTERED_LOG=$(mktemp ${TMP_DIR}/denyhost.ssh.log.XXXXXX)
- > ${SSH_FILTERED_LOG}
gsed -n " \
/Received disconnect/d; \
- s/${SSH_PATTERN}/\2/p \
- " ${SSH_LOG} \
+ s/${SSH_PATTERN}/&/p \
+ " ${SSH_LOG} \
+ > ${SSH_FILTERED_LOG}
+gsed -n "s/${SSH_PATTERN}/\2/p" ${SSH_FILTERED_LOG} \
| sort \
| uniq -c \
- | gsed "/^ *[1-${authtries}] */d;s/.* //" \
+ | gsed "/^ *[1-${AUTHTRIES}] */d;s/.* //" \
>> ${NEW_BLOCKERS_FILE}
for IP in $(cat ${NEW_BLOCKERS_FILE} | sort | uniq | grep -v -f ${BLOCKERS_FILE}); do