Created
May 15, 2020 14:21
-
-
Save x86demon/be8fd8f8f3358254c70713c4d7469348 to your computer and use it in GitHub Desktop.
Block asterisk password brute force in Asus RT-n66u
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| IPS=$(cat /opt/var/log/asterisk/messages | grep -oE "failed for '([^:]*)" | grep -oE '[0-9]+\.[0-9]+\.[0-9+]+\.[0-9]+' | sort | uniq) | |
| [ -z "$IPS" ] && exit 0 | |
| for ip in ${IPS} | |
| do | |
| echo "Blocking IP: ${ip}" | |
| iptables -I INPUT -s ${ip} -j DROP | |
| echo "iptables -I INPUT -s ${ip} -j DROP" >> /jffs/scripts/firewall-start | |
| done | |
| # Send notification | |
| python /opt/bin/telegram_send "Asterisk blocked IPs ${IPS}" | |
| # Clear messages to prevent double blocking | |
| echo "" > /opt/var/log/asterisk/messages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment