hacknet / index.html
xiaole0920's picture
点击中文按钮后并没有切换页面语言的效果 - Initial Deployment
0e13845 verified
Raw History Blame Contribute Delete
26.7 kB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cyber Warfare Simulator</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');
* {
font-family: 'Orbitron', monospace;
}
.matrix-rain {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: -1;
}
.glow {
box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}
.glow-red {
box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}
.terminal-cursor {
animation: blink 1s infinite;
}
@keyframes blink {
0%, 50% { opacity: 1; }
51%, 100% { opacity: 0; }
}
.scan-line {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 2px;
background: linear-gradient(to right, transparent, #00ff00, transparent);
animation: scan 2s linear infinite;
}
@keyframes scan {
0% { top: 0; }
100% { top: 100%; }
}
.glitch {
animation: glitch 0.3s infinite;
}
@keyframes glitch {
0% { transform: translateX(0); }
20% { transform: translateX(-2px); }
40% { transform: translateX(2px); }
60% { transform: translateX(-1px); }
80% { transform: translateX(1px); }
100% { transform: translateX(0); }
}
.hacker-grid {
background-image:
linear-gradient(rgba(0, 255, 255, 0.1) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 255, 255, 0.1) 1px, transparent 1px);
background-size: 20px 20px;
}
.firewall-pulse {
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.05); opacity: 0.8; }
100% { transform: scale(1); opacity: 1; }
}
</style>
</head>
<body class="bg-black text-green-400 overflow-hidden">
<!-- Matrix Rain Background -->
<canvas class="matrix-rain"></canvas>
<!-- Main Container -->
<div class="min-h-screen flex flex-col">
<!-- Header -->
<header class="bg-gray-900 border-b border-cyan-500/30 p-4">
<div class="flex justify-between items-center">
<h1 class="text-2xl md:text-4xl font-bold text-cyan-400 glow">
<i class="fas fa-skull"></i> <span id="title" data-trans="title">CYBER WARFARE SIMULATOR</span>
</h1>
<button id="lang-switch" class="bg-cyan-800 hover:bg-cyan-700 text-white px-3 py-1 rounded text-sm ml-4">
<i class="fas fa-language"></i> 中文
</button>
<div class="text-sm md:text-base">
<span class="text-red-400" data-trans="status">STATUS:</span>
<span id="status" class="text-green-400" data-trans="online">ONLINE</span>
<span class="terminal-cursor">_</span>
</div>
</div>
</header>
<!-- Main Content -->
<div class="flex-1 flex flex-col md:flex-row">
<!-- Left Panel - Terminal -->
<div class="w-full md:w-1/3 bg-gray-900 border-r border-cyan-500/30 p-4">
<div class="border border-cyan-500/50 rounded-lg p-4 h-full">
<div class="flex justify-between items-center mb-4">
<h2 class="text-cyan-400 text-lg font-bold" data-trans="terminal">TERMINAL</h2>
<div class="flex space-x-2">
<div class="w-3 h-3 bg-red-500 rounded-full"></div>
<div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
<div class="w-3 h-3 bg-green-500 rounded-full"></div>
</div>
</div>
<div id="terminal-output" class="text-sm font-mono h-64 overflow-y-auto">
> Initializing cyber warfare protocols...<br>
> Loading attack vectors...<br>
> System ready for penetration testing<br>
> <span class="terminal-cursor">_</span>
</div>
<div class="mt-4">
<input
id="terminal-input"
type="text"
class="w-full bg-black border border-cyan-500/50 rounded px-3 py-2 text-green-400 placeholder-green-600"
placeholder="Enter command..."
>
</div>
</div>
</div>
<!-- Center Panel - Network Map -->
<div class="flex-1 bg-gray-900 p-4">
<div class="border border-cyan-500/50 rounded-lg p-4 h-full relative">
<div class="scan-line"></div>
<h2 class="text-cyan-400 text-lg font-bold mb-4" data-trans="networkMap">NETWORK MAP</h2>
<div id="network-canvas" class="h-96 bg-black rounded-lg relative overflow-hidden">
<!-- Network nodes will be generated here -->
</div>
<div class="mt-4 grid grid-cols-2 gap-4">
<button
id="scan-btn"
class="bg-cyan-600 hover:bg-cyan-500 text-black font-bold py-2 px-4 rounded glow"
>
<i class="fas fa-search"></i> SCAN
</button>
<button
id="attack-btn"
class="bg-red-600 hover:bg-red-500 text-white font-bold py-2 px-4 rounded glow-red"
>
<i class="fas fa-bolt"></i> ATTACK
</button>
</div>
</div>
</div>
<!-- Right Panel - System Info -->
<div class="w-full md:w-1/3 bg-gray-900 border-l border-cyan-500/30 p-4">
<div class="border border-cyan-500/50 rounded-lg p-4 h-full">
<h2 class="text-cyan-400 text-lg font-bold mb-4" data-trans="systemInfo">SYSTEM INFO</h2>
<!-- Firewall Status -->
<div class="mb-4">
<h3 class="text-yellow-400 mb-2" data-trans="firewall">FIREWALL</h3>
<div class="w-full bg-gray-700 rounded-full h-4">
<div id="firewall-bar" class="bg-green-400 h-4 rounded-full firewall-pulse" style="width: 85%"></div>
</div>
<p class="text-xs mt-1"><span data-trans="protectionLevel">Protection Level:</span> <span id="firewall-level">85%</span></p>
</div>
<!-- Attack Log -->
<div class="mb-4">
<h3 class="text-red-400 mb-2" data-trans="attackLog">ATTACK LOG</h3>
<div id="attack-log" class="text-xs h-32 overflow-y-auto bg-black p-2 rounded">
<div class="text-gray-400" data-trans="noAttacks">No attacks detected</div>
</div>
</div>
<!-- System Resources -->
<div class="mb-4">
<h3 class="text-purple-400 mb-2" data-trans="resources">RESOURCES</h3>
<div class="text-xs space-y-1">
<div>CPU: <span id="cpu-usage">34%</span></div>
<div>RAM: <span id="ram-usage">67%</span></div>
<div>DISK: <span id="disk-usage">45%</span></div>
</div>
</div>
<!-- Quick Actions -->
<div>
<h3 class="text-cyan-400 mb-2" data-trans="quickActions">QUICK ACTIONS</h3>
<div class="grid grid-cols-2 gap-2">
<button class="bg-gray-700 hover:bg-gray-600 text-xs py-1 px-2 rounded">
<i class="fas fa-shield-alt"></i> DEFEND
</button>
<button class="bg-gray-700 hover:bg-gray-600 text-xs py-1 px-2 rounded">
<i class="fas fa-eye"></i> MONITOR
</button>
<button class="bg-gray-700 hover:bg-gray-600 text-xs py-1 px-2 rounded">
<i class="fas fa-bug"></i> EXPLOIT
</button>
<button class="bg-gray-700 hover:bg-gray-600 text-xs py-1 px-2 rounded">
<i class="fas fa-ghost"></i> HIDE
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Notification Popup -->
<div id="notification" class="fixed top-4 right-4 bg-red-600 text-white p-4 rounded-lg shadow-lg hidden">
<div class="flex items-center">
<i class="fas fa-exclamation-triangle mr-2"></i>
<span id="notification-text">Security breach detected!</span>
</div>
</div>
<script>
// Matrix Rain Effect
function setupMatrixRain() {
const canvas = document.querySelector('.matrix-rain');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const drops = [];
for (let i = 0; i < canvas.width / 10; i++) {
drops[i] = 0;
}
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#0F0';
ctx.font = '10px monospace';
for (let i = 0; i < drops.length; i++) {
const char = chars[Math.floor(Math.random() * chars.length)];
ctx.fillText(char, i * 10, drops[i] * 10);
if (drops[i] * 10 > canvas.height && Math.random() > 0.975) {
drops[i] = 0;
}
drops[i]++;
}
}
setInterval(draw, 33);
}
// Network Visualization
function createNetwork() {
const canvas = document.getElementById('network-canvas');
const nodes = [];
const connections = [];
// Generate nodes
for (let i = 0; i < 8; i++) {
nodes.push({
x: Math.random() * (canvas.offsetWidth - 50) + 25,
y: Math.random() * (canvas.offsetHeight - 50) + 25,
type: Math.random() > 0.7 ? 'target' : 'normal',
id: i
});
}
// Generate connections
for (let i = 0; i < nodes.length; i++) {
const connectionsCount = Math.floor(Math.random() * 3) + 1;
for (let j = 0; j < connectionsCount; j++) {
const target = Math.floor(Math.random() * nodes.length);
if (target !== i) {
connections.push({ from: i, to: target });
}
}
}
// Render
function render() {
canvas.innerHTML = '';
// Draw connections
connections.forEach(conn => {
const line = document.createElement('div');
const from = nodes[conn.from];
const to = nodes[conn.to];
const length = Math.sqrt(Math.pow(to.x - from.x, 2) + Math.pow(to.y - from.y, 2));
const angle = Math.atan2(to.y - from.y, to.x - from.x) * 180 / Math.PI;
line.style.position = 'absolute';
line.style.left = from.x + 'px';
line.style.top = from.y + 'px';
line.style.width = length + 'px';
line.style.height = '1px';
line.style.backgroundColor = 'rgba(0, 255, 255, 0.3)';
line.style.transformOrigin = '0 50%';
line.style.transform = `rotate(${angle}deg)`;
canvas.appendChild(line);
});
// Draw nodes
nodes.forEach(node => {
const nodeEl = document.createElement('div');
nodeEl.style.position = 'absolute';
nodeEl.style.left = (node.x - 10) + 'px';
nodeEl.style.top = (node.y - 10) + 'px';
nodeEl.style.width = '20px';
nodeEl.style.height = '20px';
nodeEl.style.borderRadius = '50%';
nodeEl.style.backgroundColor = node.type === 'target' ? '#ff0000' : '#00ffff';
nodeEl.style.boxShadow = `0 0 10px ${node.type === 'target' ? '#ff0000' : '#00ffff'}`;
nodeEl.className = 'firewall-pulse cursor-pointer';
nodeEl.addEventListener('click', () => {
showNodeInfo(node);
});
canvas.appendChild(nodeEl);
});
}
render();
}
// Terminal Commands
const commands = {
help: 'Available commands: scan, attack, defend, status, clear',
scan: 'Scanning network for vulnerabilities...',
attack: 'Initiating attack sequence...',
defend: 'Activating defense protocols...',
status: 'System status: OPERATIONAL',
clear: ''
};
// Event Listeners
document.getElementById('terminal-input').addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
const input = e.target.value.toLowerCase();
const output = document.getElementById('terminal-output');
output.innerHTML += `<br>> ${input}`;
if (commands[input]) {
if (input === 'clear') {
output.innerHTML = '> ';
} else {
output.innerHTML += `<br>> ${commands[input]}`;
// Trigger actual actions
if (input === 'scan') {
performScan();
} else if (input === 'attack') {
performAttack();
}
}
} else {
output.innerHTML += '<br>> Command not found';
}
output.innerHTML += '<br>> <span class="terminal-cursor">_</span>';
output.scrollTop = output.scrollHeight;
e.target.value = '';
}
});
// Scan Function
function performScan() {
const notification = document.getElementById('notification');
const notificationText = document.getElementById('notification-text');
notificationText.textContent = 'Network scan completed. 3 vulnerabilities found!';
notification.className = notification.className.replace('hidden', '');
setTimeout(() => {
notification.className += ' hidden';
}, 3000);
// Update network
createNetwork();
}
// Attack Function
function performAttack() {
const firewallBar = document.getElementById('firewall-bar');
const firewallLevel = document.getElementById('firewall-level');
const attackLog = document.getElementById('attack-log');
// Decrease firewall
let currentLevel = parseInt(firewallLevel.textContent);
currentLevel = Math.max(0, currentLevel - 15);
firewallBar.style.width = currentLevel + '%';
firewallLevel.textContent = currentLevel + '%';
// Add to attack log
const timestamp = new Date().toLocaleTimeString();
attackLog.innerHTML = `
<div class="text-red-400">${timestamp} - Attack initiated</div>
<div class="text-yellow-400">${timestamp} - Firewall breach attempt</div>
` + attackLog.innerHTML;
// Visual effect
document.body.classList.add('glitch');
setTimeout(() => {
document.body.classList.remove('glitch');
}, 500);
}
// Button Listeners
document.getElementById('scan-btn').addEventListener('click', () => {
performScan();
});
document.getElementById('attack-btn').addEventListener('click', () => {
performAttack();
});
// Update system resources
function updateResources() {
const cpu = document.getElementById('cpu-usage');
const ram = document.getElementById('ram-usage');
const disk = document.getElementById('disk-usage');
setInterval(() => {
cpu.textContent = Math.floor(Math.random() * 30) + 20 + '%';
ram.textContent = Math.floor(Math.random() * 30) + 50 + '%';
disk.textContent = Math.floor(Math.random() * 30) + 30 + '%';
}, 2000);
}
// Translation data
const translations = {
en: {
title: "CYBER WARFARE SIMULATOR",
status: "STATUS:",
online: "ONLINE",
terminal: "TERMINAL",
networkMap: "NETWORK MAP",
systemInfo: "SYSTEM INFO",
firewall: "FIREWALL",
protectionLevel: "Protection Level:",
attackLog: "ATTACK LOG",
noAttacks: "No attacks detected",
resources: "RESOURCES",
quickActions: "QUICK ACTIONS",
scan: "SCAN",
attack: "ATTACK",
defend: "DEFEND",
monitor: "MONITOR",
exploit: "EXPLOIT",
hide: "HIDE",
placeholder: "Enter command...",
initialTerminal: [
"> Initializing cyber warfare protocols...",
"> Loading attack vectors...",
"> System ready for penetration testing"
]
},
zh: {
title: "网络攻防模拟器",
status: "状态:",
online: "在线",
terminal: "终端",
networkMap: "网络地图",
systemInfo: "系统信息",
firewall: "防火墙",
protectionLevel: "防护等级:",
attackLog: "攻击日志",
noAttacks: "未检测到攻击",
resources: "资源",
quickActions: "快速操作",
scan: "扫描",
attack: "攻击",
defend: "防御",
monitor: "监控",
exploit: "漏洞利用",
hide: "隐藏",
placeholder: "输入命令...",
initialTerminal: [
"> 正在初始化网络战协议...",
"> 正在加载攻击向量...",
"> 系统准备就绪,可进行渗透测试"
]
}
};
let currentLang = 'en';
// Language switching function
function switchLanguage() {
currentLang = currentLang === 'en' ? 'zh' : 'en';
document.getElementById('lang-switch').innerHTML =
`<i class="fas fa-language"></i> ${currentLang === 'en' ? '中文' : 'English'}`;
// Update all text elements with data-trans attribute
const t = translations[currentLang];
document.querySelectorAll('[data-trans]').forEach(el => {
const key = el.getAttribute('data-trans');
if (t[key]) {
el.textContent = t[key];
}
});
// Update input placeholder
document.getElementById('terminal-input').placeholder = t.placeholder;
// Update terminal initial text
const terminal = document.getElementById('terminal-output');
terminal.innerHTML = t.initialTerminal.join('<br>') + '<br>> <span class="terminal-cursor">_</span>';
// Update buttons
document.getElementById('scan-btn').innerHTML = `<i class="fas fa-search"></i> ${t.scan}`;
document.getElementById('attack-btn').innerHTML = `<i class="fas fa-bolt"></i> ${t.attack}`;
document.querySelectorAll('.quick-action-btn').forEach((btn, i) => {
btn.innerHTML = `<i class="fas ${i === 0 ? 'fa-shield-alt' :
i === 1 ? 'fa-eye' :
i === 2 ? 'fa-bug' : 'fa-ghost'}"></i> ${[t.defend, t.monitor, t.exploit, t.hide][i]}`;
});
}
// Initialize
setupMatrixRain();
createNetwork();
updateResources();
// Set initial language
switchLanguage();
// Add data-trans attributes to elements
document.addEventListener('DOMContentLoaded', () => {
document.querySelector('span[data-trans="status"]') ||
document.querySelector('#status').previousElementSibling.setAttribute('data-trans', 'status');
document.querySelector('span[data-trans="online"]') ||
document.getElementById('status').setAttribute('data-trans', 'online');
document.querySelector('h2[data-trans="terminal"]') ||
document.querySelector('#terminal-output').parentElement.querySelector('h2').setAttribute('data-trans', 'terminal');
document.querySelector('h2[data-trans="networkMap"]') ||
document.querySelector('#network-canvas').parentElement.querySelector('h2').setAttribute('data-trans', 'networkMap');
document.querySelector('h2[data-trans="systemInfo"]') ||
document.querySelector('.border-l h2').setAttribute('data-trans', 'systemInfo');
document.querySelector('h3[data-trans="firewall"]') ||
document.querySelector('#firewall-bar').parentElement.querySelector('h3').setAttribute('data-trans', 'firewall');
document.querySelector('span[data-trans="protectionLevel"]') ||
document.querySelector('#firewall-level').previousElementSibling.setAttribute('data-trans', 'protectionLevel');
document.querySelector('h3[data-trans="attackLog"]') ||
document.querySelector('#attack-log').previousElementSibling.setAttribute('data-trans', 'attackLog');
document.querySelector('div[data-trans="noAttacks"]') ||
document.querySelector('#attack-log div').setAttribute('data-trans', 'noAttacks');
document.querySelector('h3[data-trans="resources"]') ||
document.querySelector('#cpu-usage').parentElement.parentElement.querySelector('h3').setAttribute('data-trans', 'resources');
document.querySelector('h3[data-trans="quickActions"]') ||
document.querySelector('.grid.grid-cols-2').previousElementSibling.setAttribute('data-trans', 'quickActions');
// Add quick-action-btn class to action buttons
document.querySelectorAll('.grid.grid-cols-2 button').forEach(btn => {
btn.classList.add('quick-action-btn');
});
// Add language switch event
document.getElementById('lang-switch').addEventListener('click', switchLanguage);
});
// Responsive canvas resize
window.addEventListener('resize', () => {
createNetwork();
});
// Show node info
function showNodeInfo(node) {
const terminal = document.getElementById('terminal-output');
terminal.innerHTML += `<br>> Node ${node.id} - Type: ${node.type === 'target' ? 'HIGH VALUE TARGET' : 'NORMAL NODE'}`;
terminal.scrollTop = terminal.scrollHeight;
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=xiaole0920/hacknet" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>