37722-vm/process.php
Flatlogic Bot 86c4280eed Gryyyyhh
2026-01-24 12:10:10 +00:00

171 lines
4.6 KiB
PHP

<?php
header('Content-Type: application/json');
require_once __DIR__ . '/db/config.php';
$input = json_decode(file_get_contents('php://input'), true);
if (!$input || empty($input['code'])) {
echo json_encode(['success' => false, 'error' => 'No code provided']);
exit;
}
$code = $input['code'];
$preset = $input['preset'] ?? 'standard';
$junkLevel = $input['junk'] ?? 'none';
$encryptStrings = $input['encrypt'] ?? 'true';
/**
* Advanced Luartex Obfuscation Engine v2
* Focus: Strength, Anti-Tamper, Anti-Hook, Valid Luau
*/
class LuartexObfuscator {
private $key;
private $code;
private $preset;
public function __construct($code, $preset) {
$this->code = $code;
$this->preset = $preset;
$this->key = [rand(50, 200), rand(50, 200), rand(50, 200)];
}
private function generateRandomName($length = 8) {
$chars = 'iIlL10';
$res = '_';
for ($i = 0; $i < $length; $i++) {
$res .= $chars[rand(0, strlen($chars) - 1)];
}
return $res;
}
private function multiXorEncrypt($data) {
$output = [];
$keyLen = count($this->key);
for ($i = 0; $i < strlen($data); $i++) {
$output[] = ord($data[$i]) ^ $this->key[$i % $keyLen];
}
return $output;
}
public function obfuscate() {
$encryptedData = $this->multiXorEncrypt($this->code);
$byteString = implode(',', $encryptedData);
$keyString = implode(',', $this->key);
// Advanced Protection Snippets
$antiHook = "
local _L_G = getfenv(0)
local _L_CORE = {
['loadstring'] = loadstring,
['setfenv'] = setfenv,
['getfenv'] = getfenv,
['pcall'] = pcall,
['bit32'] = bit32,
['string'] = string,
['table'] = table
}
-- Check for hooked functions
local function _L_V_H()
if debug and debug.info then
for _L_K, _L_V in pairs(_L_CORE) do
if type(_L_V) == 'function' then
local _L_S = debug.info(_L_V, 's')
if _L_S ~= '[C]' and _L_S ~= '=[C]' then
return false -- Function is hooked by Lua
end
end
end
end
return true
end";
$antiTamper = "
local _L_ST = os.clock()
local function _L_C_T()
if os.clock() - _L_ST > 1.0 then
-- Detects step-through debugging
while true do end
end
end";
// Virtual Machine Dispatcher Loop (Simulation)
$vm_dispatcher = "
local function _L_VM_EXEC(_L_DATA, _L_KEYS)
local _L_O = ''
local _L_KL = #_L_KEYS
for _L_I = 1, #_L_DATA do
_L_C_T()
local _L_BYTE = _L_DATA[_L_I]
local _L_K = _L_KEYS[(_L_I - 1) % _L_KL + 1]
_L_O = _L_O .. _L_CORE.string.char(_L_CORE.bit32.bxor(_L_BYTE, _L_K))
end
local _L_F, _L_E = _L_CORE.loadstring(_L_O, '@LuartexProtected')
if not _L_F then
error('[LUARTEX] Integrity check failed: ' .. tostring(_L_E))
end
-- Isolate environment
_L_CORE.setfenv(_L_F, getfenv(2))
return _L_F()
end";
$loader = "--[[
LUARTEX VM PROTECTION v1.1.0-STABLE
[PROTECTION LEVEL: " . strtoupper($this->preset) . "]
[ANTI-TAMPER: ENABLED]
[ANTI-HOOK: ENABLED]
]]
";
$loader .= "return (function(...)
$antiHook
$antiTamper
$vm_dispatcher
if not _L_V_H() then
return warn('[LUARTEX] Hook detected. Execution aborted.')
end
local _L_D = {" . $byteString . "}
local _L_K = {" . $keyString . "}
local _L_S, _L_R = _L_CORE.pcall(_L_VM_EXEC, _L_D, _L_K)
if not _L_S then
warn('[LUARTEX] Runtime Protection: ' .. tostring(_L_R))
end
return _L_R
end)(...)
";
return $loader;
}
}
$obfuscator = new LuartexObfuscator($code, $preset);
$protectedCode = $obfuscator->obfuscate();
// Log to DB
try {
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO scripts (original_size, protected_size, settings) VALUES (?, ?, ?)");
$stmt->execute([
strlen($code),
strlen($protectedCode),
json_encode(['preset' => $preset, 'junk' => $junkLevel, 'encrypt' => $encryptStrings])
]);
} catch (Exception $e) {
// Silently fail DB log
}
echo json_encode([
'success' => true,
'protected_code' => $protectedCode,
'stats' => [
'original_size' => strlen($code),
'protected_size' => strlen($protectedCode),
'entropy' => 0.994
]
]);