false, 'error' => 'No code provided']); exit; } $code = $input['code']; class LuartexHyperionV5 { private $rawCode; private $constants = []; private $instructions = []; private $keys = []; private $opMap = []; private $vm_id; public function __construct($code) { $this->rawCode = $code; $this->vm_id = bin2hex(random_bytes(4)); for ($i = 0; $i < 32; $i++) { $this->keys[] = rand(0, 255); } $this->setupOpcodes(); } private function setupOpcodes() { $ops = [ 'LOADK', 'GETGLOBAL', 'SETGLOBAL', 'CALL', 'MOVE', 'ADD', 'SUB', 'MUL', 'DIV', 'MOD', 'POW', 'JMP', 'EQ', 'LT', 'LE', 'RETURN', 'GETTABLE', 'SETTABLE', 'NEWTABLE', 'CLOSURE', 'VARARG', 'FORPREP', 'FORLOOP', 'AND', 'OR', 'NOT', 'LEN', 'TFORLOOP', 'SETLIST', 'CLOSE', 'JUNK1', 'JUNK2', 'JUNK3' ]; shuffle($ops); foreach ($ops as $op) { $this->opMap[$op] = rand(1000, 99999); } } private function genVar($len = 16) { $chars = 'l1Ii_'; $res = 'L_'; for($i=0; $i<$len; $i++) $res .= $chars[rand(0, 4)]; return $res; } private function addConst($val) { $idx = array_search($val, $this->constants); if ($idx === false) { $this->constants[] = $val; $idx = count($this->constants) - 1; } return $idx; } private function encryptData($data) { if (is_string($data)) { $out = []; for ($i = 0; $i < strlen($data); $i++) { $out[] = ord($data[$i]) ^ $this->keys[$i % 32] ^ ($i % 255); } return $out; } return (int)$data ^ $this->keys[0]; } private function compile() { $this->addConst("Hyperion V5.2 - LPH HARDENED"); $cleanCode = preg_replace('/--[[]*.*?[]]*--/s', '', $this->rawCode); $cleanCode = preg_replace('/--.*$/m', '', $cleanCode); // Splitting by semicolon or newline $tokens = preg_split('/[; ]+/', $cleanCode); foreach ($tokens as $token) { $token = trim($token); if (empty($token)) continue; // Opcode JUNK generation if (rand(1, 10) > 7) { $this->instructions[] = [$this->opMap['JUNK1'], rand(0, 255), rand(0, 255)]; } // Function Call Pattern: game:GetService("LogService") if (preg_match('/^([a-zA-Z_]\w*(?:[.:]\w*)*)\s*\((.*?)\)$/', $token, $m)) { $this->emitCall($m[1], $m[2]); } // Assignment Pattern: local x = 10 elseif (preg_match('/^(?:local\s+)?([a-zA-Z_]\w*)\s*=\s*(.*)$/', $token, $m)) { $this->emitAssignment($m[1], $m[2]); } } $this->instructions[] = [$this->opMap['RETURN'], 0, 0]; } private function emitCall($funcName, $argStr) { $fIdx = $this->addConst($funcName); $this->instructions[] = [$this->opMap['GETGLOBAL'], 0, $fIdx]; $args = []; if (!empty(trim($argStr))) { // Very basic comma split (doesn't handle commas in strings, but good enough for this demo) $rawArgs = explode(',', $argStr); foreach ($rawArgs as $idx => $arg) { $arg = trim($arg); if (preg_match('/^["\'](.*)["\']$/s', $arg, $m)) { $vIdx = $this->addConst($m[1]); $this->instructions[] = [$this->opMap['LOADK'], $idx + 1, $vIdx]; } elseif (is_numeric($arg)) { $vIdx = $this->addConst((float)$arg); $this->instructions[] = [$this->opMap['LOADK'], $idx + 1, $vIdx]; } else { $vIdx = $this->addConst($arg); $this->instructions[] = [$this->opMap['GETGLOBAL'], $idx + 1, $vIdx]; } $args[] = $idx + 1; } } $this->instructions[] = [$this->opMap['CALL'], 0, count($args)]; } private function emitAssignment($var, $val) { $val = trim($val); if (preg_match('/^["\'](.*)["\']$/s', $val, $m)) { $vIdx = $this->addConst($m[1]); $this->instructions[] = [$this->opMap['LOADK'], 0, $vIdx]; } elseif (is_numeric($val)) { $vIdx = $this->addConst((float)$val); $this->instructions[] = [$this->opMap['LOADK'], 0, $vIdx]; } else { $vIdx = $this->addConst($val); $this->instructions[] = [$this->opMap['GETGLOBAL'], 0, $vIdx]; } $sIdx = $this->addConst($var); $this->instructions[] = [$this->opMap['SETGLOBAL'], 0, $sIdx]; } public function build() { $this->compile(); $k_v = $this->genVar(12); // Keys $c_v = $this->genVar(12); // Constants $i_v = $this->genVar(12); // Instructions $s_v = $this->genVar(12); // Stack $pc_v = $this->genVar(12); // PC $e_v = $this->genVar(12); // Env $d_v = $this->genVar(12); // Decryptor $encConsts = []; foreach ($this->constants as $c) { $encConsts[] = "{" . implode(',', $this->encryptData($c)) . "}"; } $encInsts = []; foreach ($this->instructions as $inst) { $encInsts[] = "{" . ((int)$inst[0] ^ $this->keys[0]) . "," . ((int)$inst[1] ^ $this->keys[1]) . "," . ((int)$inst[2] ^ $this->keys[2]) . "}"; } $k_str = implode(',', $this->keys); $lua = "-- [[ Hyperion Engine V5.2 - Licensed for " . $this->vm_id . " ]] --\n"; $lua .= "local _LPH_ = {}; "; // Luraph compatible header $lua .= "local " . $k_v . " = {" . $k_str . "}; "; $lua .= "local " . $c_v . " = {" . implode(',', $encConsts) . "}; "; $lua .= "local " . $i_v . " = {" . implode(',', $encInsts) . "}; "; $lua .= "local " . $e_v . " = (getgenv and getgenv()) or (getfenv and getfenv(0)) or _G; "; // Advanced Decryptor with salt $lua .= "local function " . $d_v . "(_b, _idx) "; $lua .= "if type(_b) ~= 'table' then return _b end; "; $lua .= "local _o = ''; for _p = 1, #_b do "; $lua .= "local _kidx = ((_p - 1) % 32) + 1; "; $lua .= "_o = _o .. string.char(bit32.bxor(_b[_p], " . $k_v . "[_kidx], (_p - 1) % 255)) "; $lua .= "end return _o; "; $lua .= "end; "; // VM Body $lua .= "local function _V() "; $lua .= "local " . $s_v . " = {}; "; $lua .= "local " . $pc_v . " = 1; "; // Control Flow Flattening Dispatcher $lua .= "while true do "; $lua .= "local _data = " . $i_v . "[" . $pc_v . "] ; "; $lua .= "if not _data then break end; "; $lua .= "local _op = bit32.bxor(_data[1], " . $k_v . "[1]); "; $lua .= "local _a = bit32.bxor(_data[2], " . $k_v . "[2]); "; $lua .= "local _b = bit32.bxor(_data[3], " . $k_v . "[3]); "; $cases = []; // GETGLOBAL $cases[] = "if _op == " . $this->opMap['GETGLOBAL'] . " then " . "local _n = " . $d_v . "(" . $c_v . "[_b + 1]); " . "local _target = " . $e_v . "; for _part in _n:gmatch('[^.:]+') do _target = _target[_part] end; " . $s_v . "[_a] = _target; "; // LOADK $cases[] = "elseif _op == " . $this->opMap['LOADK'] . " then " . $s_v . "[_a] = " . $d_v . "(" . $c_v . "[_b + 1]); "; // CALL $cases[] = "elseif _op == " . $this->opMap['CALL'] . " then " . "local _f = " . $s_v . "[_a]; " . "local _args = {}; for _m = 1, _b do _args[_m] = " . $s_v . "[_a + _m] end; " . "local _ok, _err = pcall(_f, unpack(_args)); if not _ok then error('LPH VM ERROR: ' .. tostring(_err)) end; "; // SETGLOBAL $cases[] = "elseif _op == " . $this->opMap['SETGLOBAL'] . " then " . "local _n = " . $d_v . "(" . $c_v . "[_b + 1]); " . $e_v . "[_n] = " . $s_v . "[_a]; "; // MOVE $cases[] = "elseif _op == " . $this->opMap['MOVE'] . " then " . $s_v . "[_a] = " . $s_v . "[_b]; "; // RETURN $cases[] = "elseif _op == " . $this->opMap['RETURN'] . " then return; "; // JUNK Opcodes (Opaque Predicates) $cases[] = "elseif _op == " . $this->opMap['JUNK1'] . " then " . "local _x = " . rand(1, 1000) . "; if _x < 0 then " . $pc_v . " = -1 end; "; shuffle($cases); $lua .= implode("", $cases); $lua .= " end; "; $lua .= $pc_v . " = " . $pc_v . " + 1; "; $lua .= "end; "; $lua .= "end; "; $lua .= "pcall(_V); "; return [ 'success' => true, 'protected_code' => $lua, 'stats' => [ 'original_size' => strlen($this->rawCode), 'protected_size' => strlen($lua), 'vm_version' => '5.2-hyperion-ultra', 'isr' => 'dynamic_heavy', 'obfuscation' => 'maximum' ] ]; } } try { $vm = new LuartexHyperionV5($code); $result = $vm->build(); try { $stmt = db()->prepare("INSERT INTO scripts (original_size, protected_size, settings) VALUES (?, ?, ?)"); $stmt->execute([ $result['stats']['original_size'], $result['stats']['protected_size'], json_encode(['protection' => 'hyperion_ultra', 'v' => '5.2']) ]); } catch (Exception $e) { } // Ignore DB errors echo json_encode($result); } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); }