SHARE
TWEET

fail2ban log scanner

MartyniP Apr 23rd, 2011 267 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $file = file_get_contents("/var/log/fail2ban.log");
  4.  
  5. $file = explode("\n", $file);
  6.  
  7. foreach ($file as $k => $v) {
  8.         $v = explode("WARNING [ssh]", $v);
  9.         $v = explode(" ", $v[1]);
  10.         $v = trim($v[2]);
  11.         if ($v) {
  12.                 $ips[$v] = $v;
  13.         }
  14. }
  15. foreach ($ips as $k => $v) {
  16.         echo $v."<br>\n";
  17.         $i++;
  18. }
  19.  
  20. echo "\n\n";
  21. echo $i." ips.";
  22.  
  23. ?>
RAW Paste Data
Top