Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- $file = file_get_contents('/var/log/auth.log');
- $file = explode("
- ",$file);
- $i = 0;
- foreach ($file as $k => $v) {
- $mystring = $v;
- $findme = 'Failed password for ';
- $pos = strpos($mystring, $findme);
- if ($pos === false) {
- } else {
- $v2 = explode($findme, $v);
- $ex = explode(" ",$v2[1]);
- if ($ex[0] == "invalid") {
- if ($ex[5] != "port") {
- $ips[$ex[5]] = $ex[5];
- }
- } else {
- if ($ex[2] != "port") {
- $ips[$ex[2]] = $ex[2];
- }
- }
- }
- }
- foreach ($ips as $k => $v) {
- echo "ip route add blackhole ".$v."
- ";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement