Skip to content

Instantly share code, notes, and snippets.

@dlangille
Created June 29, 2015 18:21
Show Gist options
  • Save dlangille/b42209ea16da256d8578 to your computer and use it in GitHub Desktop.
Save dlangille/b42209ea16da256d8578 to your computer and use it in GitHub Desktop.
When FreshPorts gets hit by torrent seekers
rm garbage
grep '"-" 408 - "-" "-"' /usr/websites/log/freshports.org-access.log | cut -f 1 -d ' ' > garbage
grep Bittorrent /usr/websites/log/freshports.org-access.log | cut -f 1 -d ' ' >> garbage
grep microsoftupdate /usr/websites/log/freshports.org-access.log | cut -f 1 -d ' ' >> garbage
grep 'GET /announce?info_hash=' /usr/websites/log/freshports.org-access.log | cut -f 1 -d ' ' >> garbage
sort garbage | uniq > allbad
sudo mv allbad /usr/local/etc/bittorent-clients
sudo pfctl -t bittorent-clients -T replace -f /usr/local/etc/bittorent-clients
egrep '"-" 408 - "-" "-"|Bittorrent|microsoftupdate|info_hash|GET /iframe.php|GET /feeds/page.php|GET /banners' /usr/websites/log/freshports.org-access.log | cut -f 1 -d ' ' >> garbage
sort garbage | uniq | grep -v 96.245.100.201 > allbad
sudo mv allbad /usr/local/etc/bittorent-clients
sudo pfctl -t bittorent-clients -T replace -f /usr/local/etc/bittorent-clients
tail -F freshports.org-access.log | egrep '"-" 408 - "-" "-"|Bittorrent|microsoftupdate|info_hash|GET /iframe.php|GET /feeds/page.php|GET /banners'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment