Advertisement
Snuggledash

talk_to_yourself.pl

Apr 11th, 2018
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.50 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4.  
  5. use Socket;
  6. use POSIX qw(dup2);
  7.  
  8. #my $program = "/usr/sbin/telnetd";
  9. #my @progargs = qw(-h -E /usr/bin/yes);
  10. my $program = "/usr/sbin/sshd";
  11. my @progargs = qw(-i);
  12.  
  13. socketpair(my $rdr, my $wtr, AF_UNIX, SOCK_STREAM, PF_UNSPEC)
  14.         or die("socketpair");
  15. close(STDIN);
  16. close(STDOUT);
  17. if (dup2(fileno($rdr), 0) == -1) { die("dup2"); }
  18. if (dup2(fileno($wtr), 1) == -1) { die("dup2"); }
  19. close($rdr);
  20. close($wtr);
  21.  
  22. exec $program, @progargs or die("exec");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement