Created
May 28, 2012 23:17
-
-
Save gerhard/2821619 to your computer and use it in GitHub Desktop.
How to stop a botnet attack exploiting Apache ProxyRequests
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
#!/usr/bin/env sh | |
tail -f /var/log/apache2/gosquared*access.log | awk ' | |
BEGIN { blocked_ips="" } | |
/ http/ { | |
if (! index(blocked_ips, $1)) { | |
// append this ip to our internal blocked_ips list | |
blocked_ips = blocked_ips " " $1 | |
"date" | getline current_time | |
close("date") | |
print current_time " :: blocking " $1 | |
ufw_block = "ufw insert 1 deny from "$1 | |
system(ufw_block) | |
close(ufw_block) | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment