Results 1 to 6 of 6

Thread: ban ips from txt file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Private First Class
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    37
    Thanked 14 Times in 14 Posts
    PHP Code:
    #!/usr/bin/php -q
    <?php
     
    $TxtDosyaYol
    ="/pathto/ip.txt";
     
    while(
    1)
    {  
      echo 
    "working";
      
    $IpListe=file_get_contents($TxtDosyaYol);
      
    $IpArray=explode("\n"$IpListe);
      for(
    $i=0;$i<count($IpArray);$i++)
      {
        if(
    strlen($IpArray[$i])>5)
        { 
          
    $Komut="/sbin/iptables -A INPUT -s ".$IpArray[$i]." -j DROP";
          
    shell_exec($Komut);
        }  
      } 
      
    unlink($TxtDosyaYol);
      
    sleep(20); // wait 20 seconds
    }  
     
    ?>
    it deletes ip.txt file when banned all ips , it works for me
    Last edited by feanor; 2nd September 2017 at 00:52.

  2. The Following User Says Thank You to feanor For This Useful Post:

    kung foo man (2nd September 2017)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •