substr($derivedBytes, 0, $keySize * 4), "iv" => substr($derivedBytes, $keySize * 4, $ivSize * 4) ); } // Decrypt function for CryptoJS AES function cryptoJs_aes_decrypt($data, $key) { $data = base64_decode($data); if (substr($data, 0, 8) != "Salted__") { return false; } $salt = substr($data, 8, 8); $keyAndIV = aes_evpKDF($key, $salt); $decrypt = openssl_decrypt( substr($data, 16), "aes-256-cbc", $keyAndIV["key"], OPENSSL_RAW_DATA, $keyAndIV["iv"] ); return $decrypt; } // Check if IP blocked if (isBlocked($client_ip)) { die('Access denied. Your IP has been blocked.'); } // Load and decrypt serials $decryptedSerials = []; $error = ''; if (file_exists('serials.json')) { $json = file_get_contents('serials.json'); $data = json_decode($json, true); if ($data && isset($data['serials'])) { foreach ($data['serials'] as $enc) { $dec = cryptoJs_aes_decrypt(trim($enc), $defaultPassword); if ($dec !== false && !empty($dec)) { $decryptedSerials[] = $dec; } } } else { $error = 'Invalid serials.json format.'; } } else { $error = 'serials.json not found.'; } $accessGranted = false; $message = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $inputSerial = trim($_POST['serial'] ?? ''); if (empty($inputSerial)) { $message = 'Serial number is required.'; } elseif (in_array($inputSerial, $decryptedSerials)) { // Success unset($_SESSION['login_attempts']); $accessGranted = true; } else { // Failed $_SESSION['login_attempts'] = ($_SESSION['login_attempts'] ?? 0) + 1; $attempts = $_SESSION['login_attempts']; $message = "Invalid serial number. Attempts: $attempts/$maxAttempts."; if ($attempts >= $maxAttempts) { blockIP($client_ip); die('Too many failed attempts. Your IP has been blocked.'); } } } ?>
Welcome! You have unlocked the encrypted tool.