diff --git a/process.php b/process.php index 803adc3..f9d326e 100644 --- a/process.php +++ b/process.php @@ -3,6 +3,9 @@ header('Content-Type: application/json'); require_once __DIR__ . '/db/config.php'; $input = json_decode(file_get_contents('php://input'), true); +if (!$input) { + $input = json_decode(file_get_contents('php://stdin'), true); +} if (!$input || empty($input['code'])) { echo json_encode(['success' => false, 'error' => 'No code provided']); @@ -11,16 +14,20 @@ if (!$input || empty($input['code'])) { $code = $input['code']; -class LuartexExtremeVM { +class LuartexHyperionV5 { private $rawCode; - private $opcodes = []; private $constants = []; private $instructions = []; private $keys = []; + private $opMap = []; + private $vm_id; public function __construct($code) { $this->rawCode = $code; - $this->keys = [rand(128, 255), rand(128, 255), rand(128, 255), rand(128, 255)]; + $this->vm_id = bin2hex(random_bytes(4)); + for ($i = 0; $i < 32; $i++) { + $this->keys[] = rand(0, 255); + } $this->setupOpcodes(); } @@ -29,55 +36,22 @@ class LuartexExtremeVM { 'LOADK', 'GETGLOBAL', 'SETGLOBAL', 'CALL', 'MOVE', 'ADD', 'SUB', 'MUL', 'DIV', 'MOD', 'POW', 'JMP', 'EQ', 'LT', 'LE', 'RETURN', 'GETTABLE', 'SETTABLE', 'NEWTABLE', - 'CLOSURE', 'VARARG', 'FORPREP', 'FORLOOP' + 'CLOSURE', 'VARARG', 'FORPREP', 'FORLOOP', 'AND', 'OR', 'NOT', 'LEN', + 'TFORLOOP', 'SETLIST', 'CLOSE', 'JUNK1', 'JUNK2', 'JUNK3' ]; shuffle($ops); - foreach ($ops as $index => $op) { - $this->opcodes[$op] = $index + 100; + foreach ($ops as $op) { + $this->opMap[$op] = rand(1000, 99999); } } - private function genVar() { - $chars = 'iI1l'; - $res = '_'; - for($i=0; $i<16; $i++) $res .= $chars[rand(0, 3)]; + private function genVar($len = 16) { + $chars = 'l1Ii_'; + $res = 'L_'; + for($i=0; $i<$len; $i++) $res .= $chars[rand(0, 4)]; return $res; } - private function toLuaTable($data) { - if (is_array($data)) { - $isList = true; - $expectedKey = 0; - foreach ($data as $k => $v) { - if ($k !== $expectedKey++) { - $isList = false; - break; - } - } - if ($isList) { - $parts = []; - foreach ($data as $v) { - $parts[] = $this->toLuaTable($v); - } - return '{' . implode(',', $parts) . '}'; - } else { - $parts = []; - foreach ($data as $k => $v) { - $key = is_string($k) ? "['" . addslashes($k) . "']" : "[$k]"; - $parts[] = $key . '=' . $this->toLuaTable($v); - } - return '{' . implode(',', $parts) . '}'; - } - } elseif (is_string($data)) { - return json_encode($data); - } elseif (is_bool($data)) { - return $data ? 'true' : 'false'; - } elseif (is_null($data)) { - return 'nil'; - } - return $data; - } - private function addConst($val) { $idx = array_search($val, $this->constants); if ($idx === false) { @@ -87,11 +61,11 @@ class LuartexExtremeVM { return $idx; } - private function encrypt($data) { + private function encryptData($data) { if (is_string($data)) { $out = []; for ($i = 0; $i < strlen($data); $i++) { - $out[] = ord($data[$i]) ^ $this->keys[$i % 4]; + $out[] = ord($data[$i]) ^ $this->keys[$i % 32] ^ ($i % 255); } return $out; } @@ -99,123 +73,179 @@ class LuartexExtremeVM { } private function compile() { - $this->addConst("Luartex V3.5 Hardened VM"); - // Improved regex for Luau paths (dots and colons) - preg_match_all('/([a-zA-Z_]\w*(?:[\.:]\w*)*)\s*\((.*?)\)/', $this->rawCode, $matches); - if (isset($matches[1]) && !empty($matches[1])) { - foreach ($matches[1] as $idx => $funcName) { - $argString = isset($matches[2][$idx]) ? trim($matches[2][$idx]) : '' -; - $fIdx = $this->addConst($funcName); - $this->instructions[] = [$this->opcodes['GETGLOBAL'], 0, $fIdx]; - if (empty($argString)) { - $this->instructions[] = [$this->opcodes['CALL'], 0, 0]; - } elseif (preg_match('/^["\'](.*)["\']$/', $argString, $m)) { - $vIdx = $this->addConst($m[1]); - $this->instructions[] = [$this->opcodes['LOADK'], 1, $vIdx]; - $this->instructions[] = [$this->opcodes['CALL'], 0, 1]; - } elseif (is_numeric($argString)) { - $vIdx = $this->addConst((float)$argString); - $this->instructions[] = [$this->opcodes['LOADK'], 1, $vIdx]; - $this->instructions[] = [$this->opcodes['CALL'], 0, 1]; - } else { - // Fallback for non-literal args (still limited to 0 args for now to avoid crash) - $this->instructions[] = [$this->opcodes['CALL'], 0, 0]; - } + $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 { - $this->addConst("Luartex Protection Active"); + $vIdx = $this->addConst($val); + $this->instructions[] = [$this->opMap['GETGLOBAL'], 0, $vIdx]; } - // Junk opcodes - for ($i=0; $i<5; $i++) { - $this->instructions[] = [$this->opcodes['MOVE'], rand(0, 30), rand(0, 30)]; - } - $this->instructions[] = [$this->opcodes['RETURN'], 0, 0]; + + $sIdx = $this->addConst($var); + $this->instructions[] = [$this->opMap['SETGLOBAL'], 0, $sIdx]; } public function build() { $this->compile(); - $encryptedConsts = []; + + $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) { - $encryptedConsts[] = $this->encrypt($c); + $encConsts[] = "{" . implode(',', $this->encryptData($c)) . "}"; } - $encryptedInsts = []; + + $encInsts = []; foreach ($this->instructions as $inst) { - $encryptedInsts[] = [ - (int)$inst[0] ^ $this->keys[0], - (int)$inst[1] ^ $this->keys[1], - (int)$inst[2] ^ $this->keys[2] - ]; + $encInsts[] = "{" . + ((int)$inst[0] ^ $this->keys[0]) . "," . + ((int)$inst[1] ^ $this->keys[1]) . "," . + ((int)$inst[2] ^ $this->keys[2]) . "}"; } - - $v_v = $this->genVar(); - $v_k = $this->genVar(); - $v_i = $this->genVar(); - $v_o = $this->genVar(); - $v_g = $this->genVar(); - $v_x = $this->genVar(); - $v_e = $this->genVar(); - $v_p = $this->genVar(); - $v_r = $this->genVar(); - $v_l = $this->genVar(); - $v_a = $this->genVar(); - $v_b = $this->genVar(); - - $k_str = implode(',', $this->keys); - $consts_table = $this->toLuaTable($encryptedConsts); - $insts_table = $this->toLuaTable($encryptedInsts); - $opcodes_table = $this->toLuaTable($this->opcodes); - $lua = "-- ts was obfuscated by Luartex V3.2\n"; - $lua .= "local " . $v_v . " = {C = " . $consts_table . ", I = " . $insts_table . ", O = " . $opcodes_table . "}; "; - $lua .= "local " . $v_k . " = {" . $k_str . "}; "; - $lua .= "return (function(...) "; - // Robust environment resolution for Luau executors - $lua .= "local " . $v_e . " = (getgenv and getgenv()) or (getfenv and getfenv(0)) or (getfenv and getfenv()) or _G; "; - $lua .= "local " . $v_p . " = tick(); "; - $lua .= "local function " . $v_g . "(_f) "; - $lua .= "if debug and debug.info then "; - $lua .= "local _s, _l = debug.info(_f or print, 'sl'); if _s ~= '[C]' then while true do end end "; - $lua .= "end "; - $lua .= "if tick() - " . $v_p . " > 60 then while true do end end "; - $lua .= "end; "; - $lua .= "local function " . $v_x . "(_t) "; - $lua .= "if type(_t) == 'table' then "; - $lua .= "local _r = ''; for _j = 1, #_t do "; - $lua .= "local _idx = ((_j - 1) % 4) + 1; "; - $lua .= "_r = _r .. string.char(bit32.bxor(_t[_j], " . $v_k . "[_idx])) "; - $lua .= "end return _r "; - $lua .= "end return bit32.bxor(_t, " . $v_k . "[1]) "; - $lua .= "end; "; - $lua .= "local " . $v_r . " = {}; "; - $lua .= "local " . $v_l . " = 1; "; - $lua .= "while " . $v_l . " <= #" . $v_v . ".I do "; - $lua .= "local " . $v_i . " = " . $v_v . ".I[" . $v_l . "]; "; - $lua .= "local " . $v_o . " = bit32.bxor(" . $v_i . "[1], " . $v_k . "[1]); "; - $lua .= "local " . $v_a . " = bit32.bxor(" . $v_i . "[2], " . $v_k . "[2]); "; - $lua .= "local " . $v_b . " = bit32.bxor(" . $v_i . "[3], " . $v_k . "[3]); "; + $k_str = implode(',', $this->keys); - $lua .= "if " . $v_o . " == " . $this->opcodes['GETGLOBAL'] . " then "; - $lua .= "local _gn = " . $v_x . "(" . $v_v . ".C[" . $v_b . "+1]); "; - $lua .= "local _gv = " . $v_e . "; for _p in _gn:gmatch('[^.:]+') do if type(_gv) == 'table' then _gv = _gv[_p] else _gv = nil end end; "; - $lua .= $v_r . "[" . $v_a . "] = _gv; "; - $lua .= "elseif " . $v_o . " == " . $this->opcodes['LOADK'] . " then "; - $lua .= $v_r . "[" . $v_a . "] = " . $v_x . "(" . $v_v . ".C[" . $v_b . "+1]); "; - $lua .= "elseif " . $v_o . " == " . $this->opcodes['CALL'] . " then "; - $lua .= "local _f = " . $v_r . "[" . $v_a . "]; "; - $lua .= "if _f then "; - $lua .= $v_g . "(_f); "; - $lua .= "if " . $v_b . " == 0 then _f() else _f(" . $v_r . "[" . $v_a . "+1]) end; "; - $lua .= "else error('Luartex VM Error: Attempt to call a nil value'); end; "; - $lua .= "elseif " . $v_o . " == " . $this->opcodes['RETURN'] . " then "; - $lua .= "return; "; - $lua .= "elseif " . $v_o . " == " . $this->opcodes['MOVE'] . " then "; - $lua .= $v_r . "[" . $v_a . "] = " . $v_r . "[" . $v_b . "]; "; + $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 .= $v_l . " = " . $v_l . " + 1; "; - $lua .= "end; "; - $lua .= "end)(...)"; + $lua .= "pcall(_V); "; return [ 'success' => true, @@ -223,30 +253,28 @@ class LuartexExtremeVM { 'stats' => [ 'original_size' => strlen($this->rawCode), 'protected_size' => strlen($lua), - 'vm_version' => '3.5-delta-fixed', - 'protection_level' => 'extreme' + 'vm_version' => '5.2-hyperion-ultra', + 'isr' => 'dynamic_heavy', + 'obfuscation' => 'maximum' ] ]; } } try { - $vm = new LuartexExtremeVM($code); + $vm = new LuartexHyperionV5($code); $result = $vm->build(); - // Log obfuscation 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' => 'extreme']) + json_encode(['protection' => 'hyperion_ultra', 'v' => '5.2']) ]); - } catch (Exception $e) { - // Ignore DB errors - } + } catch (Exception $e) { } // Ignore DB errors echo json_encode($result); } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); -} \ No newline at end of file +}