%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 49.231.201.246  /  Your IP : 216.73.216.149
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : root ( 0)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/11585/root/usr/share/doc/libio-pty-perl/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/11585/root/usr/share/doc/libio-pty-perl/examples/try
#!/usr/bin/perl

use blib;
use IO::Pty;
require POSIX;
$^W = 1;

my $pty = new IO::Pty;
my $pid;

unless (@ARGV) {
  { 
    my $slave  = $pty->slave;
    print %{*$pty},"\n";
    print "master $pty $$pty ",$pty->ttyname,"\n";
    print "slave  $slave $$slave ",$slave->ttyname,"\n";

    foreach $val (1..10) {
      print $pty "$val\n";
      $_ = <$slave>;
      print "$_";
    }
  }
  close $pty;
  print "Done.\n";
  exit 0;
} else {
  pipe(STAT_RDR, STAT_WTR)
    or die "Cannot open pipe: $!";
  STAT_WTR->autoflush(1);
  $pid = fork();
  die "Cannot fork" if not defined $pid;
  unless ($pid) {
    close STAT_RDR;
    $pty->make_slave_controlling_terminal();
    my $slave = $pty->slave();
    close $pty;
    $slave->clone_winsize_from(\*STDIN);
    $slave->set_raw();

    open(STDIN,"<&". $slave->fileno())
      or die "Couldn't reopen STDIN for reading, $!\n";
    open(STDOUT,">&". $slave->fileno())
      or die "Couldn't reopen STDOUT for writing, $!\n";
    open(STDERR,">&". $slave->fileno())
      or die "Couldn't reopen STDERR for writing, $!\n";

    close $slave;

    { exec(@ARGV) };
    print STAT_WTR $!+0;
    die "Cannot exec(@ARGV): $!";
  }
  close STAT_WTR;
  $pty->close_slave();
  $pty->set_raw();
  # now wait for child exec (eof due to close-on-exit) or exec error
  my $errstatus = sysread(STAT_RDR, $errno, 256);
  die "Cannot sync with child: $!" if not defined $errstatus;
  close STAT_RDR;
  if ($errstatus) {
    $! = $errno+0;
    die "Cannot exec(@ARGV): $!";
  }
  $SIG{WINCH} = \&winch;
  parent($pty);
}

sub winch {
  $pty->slave->clone_winsize_from(\*STDIN);
  kill WINCH => $pid if $pid;
  print "STDIN terminal size changed.\n";
  $SIG{WINCH} = \&winch;
}

sub process
{
 my ($rin,$src,$dst) = @_;
 my $buf = '';
 my $read = sysread($src, $buf, 1);
 if (defined $read && $read)
  {
   syswrite($dst,$buf,$read);
   syswrite(LOG,$buf,$read);
  }
 else
  {
#   print STDERR "Nothing for $src i.e. $read\n";
   vec($rin, fileno($src), 1) = 0;
  }
 return $rin;
}

sub parent
{
 open(LOG,">log") || die;
 my ($pty) = @_;
 my $tty = $pty;
 my ($rin,$win,$ein) = ('','','');
 vec($rin, fileno(STDIN), 1) = 1;
 vec($rin, fileno($tty), 1) = 1;
 vec($win, fileno($tty), 1) = 1;
 vec($ein, fileno($tty), 1) = 1;
 select($tty);
 $| = 1;
 select(STDOUT);
 $| = 1;
 while (1)
  {
   my ($rout,$wout,$eout,$timeleft);
   ($nfound,$timeleft) = select($rout=$rin,$wout=$win,$eout=$ein,3600);
   die "select failed:$!" if ($nfound < 0);
   if ($nfound > 0)
    {
     if (vec($eout, fileno($tty), 1))
      {
#       print STDERR "Exception on $tty\n";
      }
     if (vec($rout, fileno($tty), 1))
      {
       $rin = process($rin,$tty,STDOUT);
       last unless (vec($rin, fileno($tty), 1));
      }
     elsif (vec($rout, fileno(STDIN), 1) && vec($wout, fileno($tty), 1))
      {
       $rin = process($rin,STDIN,$tty);
      }
    }
  }
 close(LOG);
}



Anon7 - 2022
AnonSec Team