Created
January 15, 2012 14:26
-
-
Save yatt/1616009 to your computer and use it in GitHub Desktop.
lazy script for blocking against ssh attack
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 | |
| tbl=deny.sqlite3 | |
| log=/var/log/auth.log | |
| sqlite3 $tbl 'create table if not exists hosts (ipaddr varchar(255) primary key);' | |
| for addr in $(grep Invalid $log | awk '{print $10}' | sort | uniq) | |
| do | |
| sqlite3 deny.sqlite3 "insert or ignore into hosts values ('$addr')" | |
| done | |
| sqlite3 deny.sqlite3 "select 'sshd: ' || ipaddr from hosts" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment