Advertisement
Kurobeats

filter.pl

Oct 16th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.90 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use Net::SSH2;
  3. use Parallel::ForkManager;
  4.  
  5. $file = shift @ARGV;
  6. open(fh, '<',$file) or die "Can't read file '$file' [$!]\n"; @newarray; while (<fh>){ @array = split(':',$_);
  7. push(@newarray,@array);
  8. }
  9. my $pm = new Parallel::ForkManager(500); for (my $i=0; $i <
  10. scalar(@newarray); $i+=3) {
  11.         $pm->start and next;
  12.         $a = $i;
  13.         $b = $i+1;
  14.         $c = $i+2;
  15.         $ssh = Net::SSH2->new();
  16.         @cmd = "$newarray[$a]:$newarray[$b]:$newarray[$c]";
  17.         $newcmd = chomp @cmd;
  18.         if ($ssh->connect($newarray[$c])) {
  19.                 if ($ssh->auth_password($newarray[$a],$newarray[$b])) {
  20.                         print "\e[32;1mAdding Server IP: ".$newarray[$c]."\n";
  21.                         goto add;
  22.                 }
  23.                 else {
  24.                         print "\e[1;31;1mINVALID LOGIN: ".$newarray[$c]."\n";
  25.                 }
  26.         }
  27.         else {
  28.                 print "\e[0;34mDEAD IP: ".$newarray[$c]."\n";
  29.         }
  30.         $pm->finish;
  31. }
  32. $pm->wait_all_children;
  33. add:
  34.     system("echo -e '@cmd' >> active.txt");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement