Advertisement
MartyniP

fail2ban log scanner

Apr 23rd, 2011
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement