Skip to content

Instantly share code, notes, and snippets.

@gerhard
Created May 28, 2012 23:17
Show Gist options
  • Save gerhard/2821619 to your computer and use it in GitHub Desktop.
Save gerhard/2821619 to your computer and use it in GitHub Desktop.
How to stop a botnet attack exploiting Apache ProxyRequests
#!/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