document.addEventListener('DOMContentLoaded', () => { const inputArea = document.getElementById('input-code'); const outputArea = document.getElementById('output-code'); const protectBtn = document.getElementById('protect-btn'); const terminal = document.getElementById('terminal'); const copyBtn = document.getElementById('copy-btn'); function log(message, type = 'info') { const entry = document.createElement('div'); entry.className = `log-entry log-${type}`; const time = new Date().toLocaleTimeString([], { hour12: false, fractionalSecondDigits: 3 }); entry.textContent = `[${time}] ${message}`; terminal.appendChild(entry); terminal.scrollTop = terminal.scrollHeight; } async function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } protectBtn.addEventListener('click', async () => { const code = inputArea.value.trim(); if (!code) { log('FAILED: No source input detected.', 'warn'); return; } const preset = document.getElementById('vm-preset').value; const junk = document.getElementById('junk-code').value; protectBtn.disabled = true; protectBtn.style.opacity = '0.5'; terminal.innerHTML = ''; log(`INITIALIZING LUARTEX HARDENED KERNEL v3.0.0-PRO`, 'info'); await sleep(300); log(`MODE: ${preset.toUpperCase()} | VIRTUALIZATION: MAX`, 'info'); await sleep(400); log(`Generating Randomized Opcode Table...`, 'info'); await sleep(500); log(`Encrypting Constant Table with Multi-Key Rotation...`, 'info'); await sleep(600); if (preset === 'obsidian') { log(`STRENGTHENING: Control Flow Flattening...`, 'info'); await sleep(400); log(`STRENGTHENING: Virtualizing IP & Registers...`, 'info'); await sleep(400); log(`SECURITY: Deploying Anti-Hook & Integrity Guards...`, 'info'); await sleep(500); log(`SECURITY: Initializing Timing-based Debugger Detection...`, 'info'); await sleep(300); log(`SECURITY: Injecting Anti-Dump Infinite Loops...`, 'info'); await sleep(200); } log(`Compiling source to custom bytecode stream...`, 'info'); try { const response = await fetch('process.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ code, preset, junk }) }); const data = await response.json(); if (data.success) { await sleep(500); outputArea.value = data.protected_code; log(`SUCCESS: Bytecode locked. Final Size: ${data.stats.protected_size}b`, 'success'); log(`VM Status: SECURE | Entropy: 9.99`, 'success'); } else { log(`CRITICAL ERROR: ${data.error}`, 'warn'); } } catch (err) { log(`ENGINE FAILURE: ${err.message}`, 'warn'); } finally { protectBtn.disabled = false; protectBtn.style.opacity = '1'; } }); copyBtn.addEventListener('click', () => { if (!outputArea.value) return; navigator.clipboard.writeText(outputArea.value); const originalText = copyBtn.textContent; copyBtn.textContent = 'LOCKED & COPIED'; setTimeout(() => copyBtn.textContent = originalText, 2000); }); });