Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ariscop
Created July 6, 2014 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariscop/4744a3da2fa93a055798 to your computer and use it in GitHub Desktop.
Save ariscop/4744a3da2fa93a055798 to your computer and use it in GitHub Desktop.
Apply blocklist.de to shorewall, intended for use as a cron script
<?php
$url = 'http://api.blocklist.de/getlast.php?time=';
$cachefile = '/tmp/blocklist.de.cache';
$cachetime = 0 + @filemtime($cachefile);
$url = $url . $cachetime;
$result = file_get_contents($url);
if (is_string($result)) {
file_put_contents($cachefile, $result, FILE_APPEND);
$arr = explode("\n", $result);
foreach ($arr as $ip) {
if(strlen($ip)) {
echo "Blocking ${ip}\n";
shell_exec("shorewall drop ".escapeshellarg($ip));
}
}
} else {
echo "Failed to update blocklist";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment