Become a hacker — complete missions, earn points, and rise to the top!
💡 Hint: Try admin' OR 1=1 -- -
💡 Hint: ' + mission.hint + '
'; levelTag.textContent = '🟢 Level ' + (currentMission + 1); // Reset terminal terminalOutput.innerHTML = ''; addLine('info', '🖥️ Mission ' + (currentMission + 1) + ': ' + mission.title); addLine('info', '📌 Type help for commands'); addLine('info', '💡 Command to use: ' + mission.command + ''); addLine('', ''); cmdInput.value = ''; cmdInput.focus(); // Reset hack button hackBtn.textContent = '💻 HACK'; hackBtn.className = 'hack-btn'; hackBtn.disabled = false; updateUI(); saveProgress(); } function showGameOver() { document.getElementById('missionArea').style.display = 'none'; terminalOutput.innerHTML = ''; addLine('success', '🏆 All missions completed!'); addLine('success', 'You are a true CyberSume hacker!'); gameOver.style.display = 'block'; finalScore.textContent = 'Score: ' + score; hackBtn.disabled = true; hackBtn.style.display = 'none'; saveProgress(); } // ===================================================== // TERMINAL // ===================================================== function addLine(type, text) { var div = document.createElement('div'); div.className = type || ''; div.innerHTML = text; terminalOutput.appendChild(div); var terminal = document.getElementById('terminal'); terminal.scrollTop = terminal.scrollHeight; } function processCommand(cmd) { if (gameCompleted) { addLine('info', '🏆 Game completed! Click "Play Again" to restart.'); return; } var mission = missions[currentMission]; var trimmed = cmd.trim().toLowerCase(); // Help if (trimmed === 'help') { addLine('output', '📋 Commands: help, ' + mission.command + ', flag, clear'); return; } // Clear if (trimmed === 'clear') { terminalOutput.innerHTML = ''; addLine('info', '🖥️ Terminal cleared'); return; } // Flag if (trimmed === 'flag') { addLine('output', '🏁 FLAG{MISSION_' + (currentMission + 1) + '_COMPLETE}'); return; } // Check if it's the mission command if (trimmed === mission.command) { addLine('output', '💻 Executing ' + mission.command + '...'); // Check if the user typed the command - they need to type the answer addLine('info', '📝 Now type the payload/answer for this mission.'); return; } // Check if it's the answer if (trimmed === mission.answer.toLowerCase()) { addLine('success', mission.successMsg); // Mission complete! score += 100; totalHacks++; currentMission++; updateUI(); saveProgress(); showToast('🎉 Mission complete! +100 points', 'success'); setTimeout(function() { loadMission(); }, 1500); return; } // Check if answer is close if (mission.answer && trimmed.indexOf(mission.answer.toLowerCase()) !== -1) { addLine('output', '⚠️ Almost! Try exactly: ' + mission.answer); return; } addLine('error', '❌ Invalid command or answer.'); addLine('info', '💡 Try: ' + mission.command + ' then type the payload'); } // ===================================================== // HACK BUTTON // ===================================================== function executeHack() { if (gameCompleted) { showToast('🏆 Game completed! Click "Play Again" to restart.', 'info'); return; } var mission = missions[currentMission]; addLine('prompt', '$> ' + mission.command); addLine('output', '💻 Hacking ' + mission.title + '...'); // Simulate hacking animation hackBtn.disabled = true; hackBtn.textContent = '⏳ Hacking...'; var steps = [ '🔍 Scanning target...', '📡 Finding vulnerabilities...', '💥 Exploiting ' + mission.title + '...', '🔓 Access granted!' ]; var stepIndex = 0; var interval = setInterval(function() { if (stepIndex < steps.length) { addLine('output', steps[stepIndex]); stepIndex++; } else { clearInterval(interval); addLine('info', '📝 Now type the payload/answer for this mission.'); hackBtn.textContent = '💻 HACK'; hackBtn.disabled = false; cmdInput.focus(); } }, 800); } // ===================================================== // GAME OVER - RESET // ===================================================== function resetGame() { currentMission = 0; score = 0; totalHacks = 0; gameCompleted = false; gameOver.style.display = 'none'; document.getElementById('missionArea').style.display = 'block'; hackBtn.style.display = 'block'; hackBtn.disabled = false; hackBtn.textContent = '💻 HACK'; hackBtn.className = 'hack-btn'; saveProgress(); loadMission(); showToast('🔄 Game reset! Good luck, hacker!', 'info'); } // ===================================================== // TOAST // ===================================================== function showToast(msg, type) { toast.textContent = msg; toast.className = 'toast ' + (type || 'success'); toast.classList.add('show'); clearTimeout(toast._timer); toast._timer = setTimeout(function() { toast.classList.remove('show'); }, 3000); } // ===================================================== // EVENTS // ===================================================== cmdInput.addEventListener('keydown', function(e) { if (e.key === 'Enter') { e.preventDefault(); var cmd = this.value; if (cmd.trim()) { addLine('prompt', '$> ' + cmd); processCommand(cmd); } this.value = ''; setTimeout(function() { cmdInput.focus(); }, 10); } }); document.getElementById('terminal').addEventListener('click', function() { cmdInput.focus(); }); // ===================================================== // KEYBOARD SHORTCUTS // ===================================================== document.addEventListener('keydown', function(e) { if (e.key === 'Escape') { cmdInput.value = ''; cmdInput.focus(); } if (e.key === 'Enter' && document.activeElement === cmdInput) { // Already handled } }); // ===================================================== // MAKE FUNCTIONS GLOBAL // ===================================================== window.executeHack = executeHack; window.resetGame = resetGame; // ===================================================== // INIT // ===================================================== loadProgress(); console.log('🎮 CyberSume Hacking Game loaded!'); console.log('📚 Total missions: ' + missions.length); })();