-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
1125 lines (993 loc) · 38.8 KB
/
Copy pathscript.js
File metadata and controls
1125 lines (993 loc) · 38.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
document.addEventListener('DOMContentLoaded', function() {
// Initialize terminal
initTerminal();
// Initialize network visualization
initNetworkVisualization();
// Initialize system monitoring
initSystemMonitoring();
// Initialize clock
updateClock();
setInterval(updateClock, 1000);
// Initialize audio
initAudio();
// Add keyboard event listeners
document.addEventListener('keydown', handleKeyPress);
});
// Terminal variables
const commands = [
'nmap -sS -sV -O -p- 192.168.1.1/24',
'ssh -i ~/.ssh/id_rsa admin@192.168.1.45 -p 2222',
'sudo tcpdump -i eth0 -n -v',
'python3 exploit.py --target=192.168.1.45 --payload=reverse_shell --obfuscate',
'cat /etc/passwd | grep -v "nologin"',
'hashcat -m 1000 -a 0 hash.txt wordlist.txt --force',
'hydra -l admin -P passwords.txt 192.168.1.45 ssh',
'sqlmap -u "http://192.168.1.45/login.php" --forms --batch --dbs',
'john --wordlist=wordlist.txt --rules hashes.txt',
'dirb http://192.168.1.45/ /usr/share/wordlists/dirb/common.txt'
];
// Command fragment libraries
const commandFragments = {
// Network scanning and enumeration
network: [
'nmap -sS ',
'nmap -sV ',
'nmap -p- ',
'nmap -A ',
'masscan -p1-65535 ',
'traceroute ',
'dig ',
'whois ',
'netstat -tuln',
'tcpdump -i eth0',
'wireshark -k -i ',
'arp-scan --localnet',
'nbtscan -r 192.168.1.0/24',
'smbclient -L //192.168.1.45',
'enum4linux -a 192.168.1.45',
'snmpwalk -v2c -c public 192.168.1.45',
'onesixtyone -c community.txt 192.168.1.45',
'dnsrecon -d example.com -t axfr',
'theharvester -d example.com -b all',
'recon-ng -w workspace'
],
// System commands
system: [
'sudo ',
'cd ',
'ls -la ',
'cat ',
'grep ',
'chmod +x ',
'chown ',
'ps aux | grep ',
'kill -9 ',
'systemctl status ',
'journalctl -xe',
'dmesg | tail',
'top -b -n 1',
'free -h',
'df -h',
'netstat -tulpn',
'lsof -i',
'ifconfig',
'route -n',
'iptables -L -n -v'
],
// Security and exploitation
security: [
'hashcat -m 1000 ',
'john --wordlist=',
'hydra -l admin ',
'sqlmap -u ',
'metasploit ',
'msfvenom -p ',
'aircrack-ng ',
'nikto -h ',
'gobuster dir ',
'wpscan --url ',
'dirb http://192.168.1.45/',
'wfuzz -c -z file,wordlist.txt --hc 404 http://192.168.1.45/FUZZ',
'cewl -w wordlist.txt http://192.168.1.45',
'patator ssh_login host=192.168.1.45 user=admin password=FILE0 0=passwords.txt',
'medusa -h 192.168.1.45 -u admin -P passwords.txt -M ssh',
'ncrack -p 22 -U users.txt -P passwords.txt 192.168.1.45',
'crackmapexec smb 192.168.1.45 -u users.txt -p passwords.txt',
'responder -I eth0',
'bettercap -iface eth0',
'mitmproxy -T --host'
],
// Programming and scripting
programming: [
'python3 ',
'bash ',
'gcc -o output ',
'make ',
'git clone ',
'npm install ',
'docker run ',
'ssh -i ',
'scp ',
'curl -X POST ',
'wget ',
'pip install ',
'go build ',
'rustc ',
'javac ',
'mvn clean install',
'gradle build',
'composer install',
'yarn add ',
'gem install '
],
// File paths
paths: [
'/etc/passwd',
'/var/log/auth.log',
'/opt/tools/',
'~/.ssh/id_rsa',
'/usr/share/wordlists/',
'/tmp/exploit',
'/home/user/Documents/',
'/var/www/html/',
'/etc/shadow',
'/proc/cpuinfo',
],
// IP addresses and domains
targets: [
'192.168.1.1',
'192.168.1.45',
'10.0.0.1',
'172.16.0.100',
'localhost',
'example.com',
'target-server.local',
'8.8.8.8',
'203.0.113.42',
'api.target.com',
],
// Parameters and flags
params: [
'--help',
'-v',
'--verbose',
'-f',
'--force',
'-r',
'--recursive',
'-p 443',
'--output=results.txt',
'--timeout=30',
'--no-check-certificate',
],
// File extensions and types
fileTypes: [
'.txt',
'.py',
'.sh',
'.conf',
'.log',
'.json',
'.xml',
'.php',
'.html',
'.pcap',
]
};
// Context-aware command building
const commandContexts = {
'scan': {
prefixes: ['nmap', 'masscan', 'nikto', 'wpscan', 'gobuster'],
params: ['--ports=', '-p', '-sV', '-A', '-T4', '--open'],
targets: true
},
'exploit': {
prefixes: ['python3', 'msfvenom', 'metasploit', 'sqlmap', 'hydra'],
params: ['--target=', '--payload=', '-o', '--lhost=', '--lport='],
targets: true
},
'file': {
prefixes: ['cat', 'grep', 'nano', 'vim', 'less', 'tail'],
paths: true,
params: ['-n', '-A', '-B', '|', 'grep']
},
'system': {
prefixes: ['sudo', 'systemctl', 'ps', 'kill', 'chmod', 'chown'],
params: ['start', 'stop', 'status', 'restart', '-9', '+x']
},
'network': {
prefixes: ['ssh', 'scp', 'curl', 'wget', 'dig', 'whois'],
targets: true,
params: ['-i', '-L', '-v', '-o', '--output']
}
};
const responses = {
'nmap': [
'Starting Nmap 7.92 ( https://nmap.org ) at 2025-05-06 22:05 UTC',
'Scanning 256 hosts [65535 ports/host]',
'Discovered open port 22/tcp on 192.168.1.1',
'Discovered open port 80/tcp on 192.168.1.1',
'Discovered open port 443/tcp on 192.168.1.1',
'Discovered open port 22/tcp on 192.168.1.45',
'Discovered open port 80/tcp on 192.168.1.45',
'Discovered open port 443/tcp on 192.168.1.45',
'Discovered open port 445/tcp on 192.168.1.45',
'Discovered open port 3306/tcp on 192.168.1.45',
'OS detection performed. Please report any incorrect results at https://nmap.org/submit/',
'For 192.168.1.1: OS: Linux 4.15 - 5.6',
'For 192.168.1.45: OS: Linux 5.4.0-42',
'Service detection performed. Please report any incorrect results at https://nmap.org/submit/',
'Nmap done: 256 IP addresses (4 hosts up) scanned in 325.26 seconds'
],
'ssh': [
'OpenSSH_8.4p1, OpenSSL 1.1.1k 25 Mar 2021',
'debug1: Reading configuration data /etc/ssh/ssh_config',
'debug1: Connecting to 192.168.1.45 [192.168.1.45] port 2222.',
'debug1: Connection established.',
'debug1: identity file /home/user/.ssh/id_rsa type 0',
'debug1: Local version string SSH-2.0-OpenSSH_8.4',
'debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1',
'debug1: Authenticating to 192.168.1.45:2222 as \'admin\'',
'debug1: Authentication succeeded (publickey).',
'Last login: Tue May 6 21:42:17 2025 from 192.168.1.100',
'Welcome to srv-web-prod',
'admin@srv-web-prod:~$ '
],
'python3': [
'[+] Loading exploit module...',
'[+] Checking target availability...',
'[+] Target 192.168.1.45 is up and vulnerable',
'[+] Generating payload...',
'[+] Obfuscating payload...',
'[+] Establishing connection to target...',
'[+] Sending initial payload...',
'[+] Executing stage 1...',
'[+] Received callback from target',
'[+] Escalating privileges...',
'[+] Got root shell!',
'[+] Setting up persistence...',
'[+] Cleaning up traces...',
'[+] Exploit completed successfully!'
],
'default': [
'Command executed successfully.',
'Operation completed with status code 0.',
'Process finished.'
],
'compiling': [
'Compiling source files...',
'Linking object files...',
'Generating binary...',
'Optimizing code...',
'Stripping debug symbols...',
'Creating executable...',
'Build completed successfully.'
],
'scanning': [
'Initializing scan...',
'Probing target system...',
'Analyzing network topology...',
'Identifying open ports...',
'Detecting services...',
'Fingerprinting operating system...',
'Scanning for vulnerabilities...',
'Generating report...',
'Scan completed.'
],
'hacking': [
'Bypassing firewall...',
'Cracking encryption...',
'Injecting payload...',
'Exploiting vulnerability...',
'Escalating privileges...',
'Establishing persistence...',
'Covering tracks...',
'Access granted.'
]
};
let currentCommand = '';
let commandHistory = [];
let historyIndex = -1;
let terminalLocked = false;
// --- CONTEXT-AWARE COMMAND FRAGMENT GENERATION ---
// State for current command context
let currentCommandContext = null;
let commandFragmentsOrder = [];
// Helper: Detect context from current command
function detectCommandContext(cmd) {
for (const [ctx, ctxObj] of Object.entries(commandContexts)) {
for (const prefix of ctxObj.prefixes || []) {
if (cmd.startsWith(prefix)) return ctx;
}
}
// If empty, pick a random context
return null;
}
// Helper: Get next fragment type based on context and order
function getNextFragmentType(context, order) {
// Define plausible orderings for each context
const orders = {
scan: ['prefixes', 'params', 'targets'],
exploit: ['prefixes', 'params', 'targets'],
file: ['prefixes', 'paths', 'params'],
system: ['prefixes', 'params', 'paths'],
network: ['prefixes', 'targets', 'params']
};
if (!context || !orders[context]) return null;
// If order is empty, start from 0
return orders[context][order.length] || null;
}
// Helper: Get a random element from an array
function pick(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
// Main: Get next command fragment for a key
function getNextCommandFragment(key) {
// If no context, pick one based on key
if (!currentCommandContext) {
// Map key to context for variety
const keyMap = {
A: 'scan', B: 'exploit', C: 'file', D: 'system', E: 'network',
S: 'system', N: 'scan', P: 'programming', H: 'security',
X: 'exploit', F: 'file', W: 'network', Q: 'scan',
};
const upper = key.toUpperCase();
currentCommandContext = keyMap[upper] || pick(Object.keys(commandContexts));
commandFragmentsOrder = [];
}
// Get next fragment type
const fragType = getNextFragmentType(currentCommandContext, commandFragmentsOrder);
let fragment = '';
if (fragType && commandContexts[currentCommandContext][fragType]) {
// If context has specific options (prefixes, params, etc)
if (fragType === 'prefixes') {
fragment = pick(commandContexts[currentCommandContext][fragType]) + ' ';
} else if (fragType === 'targets' && commandContexts[currentCommandContext].targets) {
fragment = pick(commandFragments.targets) + ' ';
} else if (fragType === 'paths' && commandContexts[currentCommandContext].paths) {
fragment = pick(commandFragments.paths) + ' ';
} else if (fragType === 'params') {
fragment = pick(commandContexts[currentCommandContext][fragType]) + ' ';
}
} else {
// Fallback: pick from general fragments
fragment = pick(commandFragments[fragType] || commandFragments.params) + ' ';
}
commandFragmentsOrder.push(fragType);
return fragment;
}
// Reset context on Enter or clear
function resetCommandContext() {
currentCommandContext = null;
commandFragmentsOrder = [];
}
// Initialize terminal
function initTerminal() {
const mainTerminal = document.getElementById('main-terminal');
const prompt = document.querySelector('.prompt').textContent;
// Add some initial commands to history for realism
commandHistory = [
'cd /opt/tools',
'ls -la',
'clear',
'sudo systemctl status firewall',
'vim config.json'
];
}
// Handle key press events
function handleKeyPress(event) {
if (terminalLocked) return;
const mainTerminal = document.getElementById('main-terminal');
const promptLine = mainTerminal.querySelector('.terminal-line:last-child');
const cursor = promptLine.querySelector('.cursor');
// Play key sound
playSound('keypress');
switch(event.key) {
case 'Enter':
executeCommand();
resetCommandContext();
break;
case 'Escape':
triggerSecurityBreach();
break;
case ' ':
if (event.ctrlKey) {
toggleTerminalLock();
} else {
appendToCommand(' ');
}
break;
case 'Tab':
event.preventDefault();
cycleSubsystem();
break;
case 'Backspace':
if (currentCommand.length > 0) {
currentCommand = '';
updateCommandDisplay();
resetCommandContext();
}
break;
case 'ArrowUp':
navigateHistory(-1);
break;
case 'ArrowDown':
navigateHistory(1);
break;
default:
if (event.key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey) {
// Instead of literal key, append a context-aware fragment
const fragment = getNextCommandFragment(event.key);
appendToCommand(fragment);
}
break;
}
}
// Append character to current command
function appendToCommand(fragment) {
currentCommand += fragment;
updateCommandDisplay();
}
// Update the command display in the terminal
function updateCommandDisplay() {
const mainTerminal = document.getElementById('main-terminal');
const promptLine = mainTerminal.querySelector('.terminal-line:last-child');
const prompt = promptLine.querySelector('.prompt').textContent;
// Remove existing command text nodes
const childNodes = Array.from(promptLine.childNodes);
childNodes.forEach(node => {
if (node.nodeType === Node.TEXT_NODE) {
promptLine.removeChild(node);
}
});
// Add updated command text
const commandText = document.createTextNode(currentCommand);
promptLine.insertBefore(commandText, promptLine.querySelector('.cursor'));
}
// Execute the current command
function executeCommand() {
if (terminalLocked) return;
const mainTerminal = document.getElementById('main-terminal');
const promptLine = mainTerminal.querySelector('.terminal-line:last-child');
const command = currentCommand.trim();
if (command) {
// Add command to history
commandHistory.push(command);
historyIndex = commandHistory.length;
// Create loading bar
const loadingBar = document.createElement('div');
loadingBar.className = 'loading-bar';
mainTerminal.appendChild(loadingBar);
// Add command execution class
promptLine.classList.add('command-executing');
// Play enter sound
playSound('enter');
// Process command after delay
setTimeout(() => {
loadingBar.remove();
promptLine.classList.remove('command-executing');
processCommand(command);
// Reset command state
currentCommand = '';
currentCommandContext = null;
commandFragmentsOrder = [];
// Update command display
updateCommandDisplay();
}, Math.random() * 1000 + 500);
}
}
// Process and display response for a command
function processCommand(command) {
const mainTerminal = document.getElementById('main-terminal');
const prompt = document.querySelector('.prompt').textContent;
// Determine which response to use
let responseLines = [];
let responseType = 'default';
if (command.startsWith('nmap')) {
responseLines = responses['nmap'];
responseType = 'scanning';
updateNetworkData();
} else if (command.startsWith('ssh')) {
responseLines = responses['ssh'];
} else if (command.startsWith('python3')) {
responseLines = responses['python3'];
responseType = 'hacking';
setTimeout(() => {
triggerSecurityBreach();
}, 5000);
} else if (command.includes('gcc') || command.includes('make') || command.includes('javac')) {
responseLines = responses['compiling'];
responseType = 'compiling';
} else if (command.includes('scan') || command.includes('probe')) {
responseLines = responses['scanning'];
responseType = 'scanning';
} else if (command.includes('exploit') || command.includes('crack')) {
responseLines = responses['hacking'];
responseType = 'hacking';
} else {
responseLines = responses['default'];
}
// Lock terminal during command execution
terminalLocked = true;
// Remove any existing response lines
const oldResponses = mainTerminal.querySelectorAll('.terminal-line.response');
oldResponses.forEach(line => line.remove());
// Display response with typing effect
let lineIndex = 0;
let charIndex = 0;
function typeNextCharacter() {
if (lineIndex < responseLines.length) {
const currentLine = responseLines[lineIndex];
if (charIndex === 0) {
// Create new line element
const lineElement = document.createElement('div');
lineElement.className = 'terminal-line response';
lineElement.id = `response-line-${lineIndex}`;
// Add glitch effect randomly
if (Math.random() > 0.7) {
lineElement.classList.add('glitch');
lineElement.setAttribute('data-text', currentLine);
}
mainTerminal.appendChild(lineElement);
}
const lineElement = document.getElementById(`response-line-${lineIndex}`);
if (charIndex < currentLine.length) {
// Add next character
lineElement.textContent = currentLine.substring(0, charIndex + 1);
charIndex++;
// Schedule next character
const delay = Math.random() * 10 + 5;
setTimeout(typeNextCharacter, delay);
} else {
// Line complete, move to next line
lineIndex++;
charIndex = 0;
// Schedule next line
const delay = Math.random() * 200 + 100;
setTimeout(typeNextCharacter, delay);
}
} else {
// All lines complete, add new prompt
setTimeout(() => {
const newPromptLine = document.createElement('div');
newPromptLine.className = 'terminal-line';
const promptSpan = document.createElement('span');
promptSpan.className = 'prompt';
promptSpan.textContent = prompt;
const cursorSpan = document.createElement('span');
cursorSpan.className = 'cursor blink';
cursorSpan.textContent = '█';
newPromptLine.appendChild(promptSpan);
newPromptLine.appendChild(cursorSpan);
mainTerminal.appendChild(newPromptLine);
// Scroll to bottom
mainTerminal.scrollTop = mainTerminal.scrollHeight;
// Unlock terminal
terminalLocked = false;
}, 500);
}
// Scroll to bottom
mainTerminal.scrollTop = mainTerminal.scrollHeight;
}
// Start typing effect
typeNextCharacter();
}
// Generate file output for cat/grep commands
function generateFileOutput(command) {
const fileOutputs = {
'passwd': [
'root:x:0:0:root:/root:/bin/bash',
'daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin',
'bin:x:2:2:bin:/bin:/usr/sbin/nologin',
'sys:x:3:3:sys:/dev:/usr/sbin/nologin',
'sync:x:4:65534:sync:/bin:/bin/sync',
'games:x:5:60:games:/usr/games:/usr/sbin/nologin',
'man:x:6:12:man:/var/cache/man:/usr/sbin/nologin',
'lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin',
'mail:x:8:8:mail:/var/mail:/usr/sbin/nologin',
'news:x:9:9:news:/var/spool/news:/usr/sbin/nologin',
'uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin',
'proxy:x:13:13:proxy:/bin:/usr/sbin/nologin',
'www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin',
'backup:x:34:34:backup:/var/backups:/usr/sbin/nologin',
'list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin',
'irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin',
'gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin',
'nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin',
'systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin',
'systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin',
'systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin',
'messagebus:x:103:106::/nonexistent:/usr/sbin/nologin',
'sshd:x:104:65534::/run/sshd:/usr/sbin/nologin',
'mysql:x:105:113:MySQL Server,,,:/var/lib/mysql:/bin/false',
'admin:x:1000:1000:System Administrator:/home/admin:/bin/bash',
'user:x:1001:1001:Regular User:/home/user:/bin/bash'
],
'config': [
'{',
' "server": {',
' "host": "0.0.0.0",',
' "port": 8080,',
' "debug": false,',
' "timeout": 30,',
' "max_connections": 100',
' },',
' "database": {',
' "host": "localhost",',
' "port": 3306,',
' "user": "dbuser",',
' "password": "dbp@ssw0rd",',
' "name": "webapp_db",',
' "pool_size": 10',
' },',
' "security": {',
' "enable_ssl": true,',
' "cert_file": "/etc/ssl/certs/server.crt",',
' "key_file": "/etc/ssl/private/server.key",',
' "allowed_origins": ["https://example.com", "https://api.example.com"],',
' "rate_limit": 100',
' },',
' "logging": {',
' "level": "info",',
' "file": "/var/log/app.log",',
' "max_size": 10485760,',
' "backup_count": 5',
' }',
'}'
],
'log': [
'[2025-05-06 21:42:17] [INFO] Server started on port 8080',
'[2025-05-06 21:43:05] [INFO] Connection from 192.168.1.100 established',
'[2025-05-06 21:43:12] [INFO] User admin logged in from 192.168.1.100',
'[2025-05-06 21:44:30] [INFO] Database query executed: SELECT * FROM users WHERE active=1',
'[2025-05-06 21:45:17] [WARNING] High CPU usage detected: 87%',
'[2025-05-06 21:46:03] [INFO] User admin executed command: UPDATE system_settings',
'[2025-05-06 21:47:22] [ERROR] Failed to connect to backup server: Connection timed out',
'[2025-05-06 21:48:45] [INFO] Scheduled backup started',
'[2025-05-06 21:49:10] [WARNING] Disk space low: 92% used',
'[2025-05-06 21:50:33] [INFO] User admin logged out',
'[2025-05-06 21:51:17] [INFO] Connection from 192.168.1.100 closed',
'[2025-05-06 21:55:02] [WARNING] Failed login attempt for user root from 203.0.113.42',
'[2025-05-06 21:55:10] [WARNING] Failed login attempt for user admin from 203.0.113.42',
'[2025-05-06 21:55:15] [WARNING] Failed login attempt for user admin from 203.0.113.42',
'[2025-05-06 21:55:20] [WARNING] Failed login attempt for user admin from 203.0.113.42',
'[2025-05-06 21:55:25] [WARNING] Failed login attempt for user admin from 203.0.113.42',
'[2025-05-06 21:55:30] [CRITICAL] Possible brute force attack detected from 203.0.113.42',
'[2025-05-06 21:55:31] [INFO] IP 203.0.113.42 automatically blocked for 30 minutes',
'[2025-05-06 22:00:17] [INFO] Connection from 192.168.1.45 established',
'[2025-05-06 22:01:05] [INFO] User user logged in from 192.168.1.45'
]
};
// Determine which file content to show based on the command
let output = [];
if (command.includes('passwd')) {
output = fileOutputs['passwd'];
} else if (command.includes('config') || command.includes('json')) {
output = fileOutputs['config'];
} else if (command.includes('log')) {
output = fileOutputs['log'];
} else {
// Default to a random file
const fileTypes = Object.keys(fileOutputs);
output = fileOutputs[fileTypes[Math.floor(Math.random() * fileTypes.length)]];
}
// If grep is used, filter the output
if (command.includes('grep')) {
const grepTerm = command.split('grep')[1].trim().replace(/['"]/g, '');
if (grepTerm) {
output = output.filter(line => line.includes(grepTerm));
}
}
return output;
}
// Generate directory listing
function generateDirectoryListing() {
return [
'total 56',
'drwxr-xr-x 2 admin admin 4096 May 6 21:30 .',
'drwxr-xr-x 18 admin admin 4096 May 6 20:15 ..',
'-rw-r--r-- 1 admin admin 220 May 6 20:15 .bash_logout',
'-rw-r--r-- 1 admin admin 3771 May 6 20:15 .bashrc',
'-rw-r--r-- 1 admin admin 807 May 6 20:15 .profile',
'drwxr-xr-x 3 admin admin 4096 May 6 21:10 .ssh',
'-rwxr-xr-x 1 admin admin 8744 May 6 21:25 exploit.py',
'-rw-r--r-- 1 admin admin 2210 May 6 21:20 config.json',
'-rw-r--r-- 1 admin admin 5733 May 6 21:15 data.db',
'drwxr-xr-x 2 admin admin 4096 May 6 21:05 logs',
'-rw-r--r-- 1 admin admin 845 May 6 21:00 README.md',
'drwxr-xr-x 3 admin admin 4096 May 6 20:55 scripts',
'-rwxr-xr-x 1 admin admin 3672 May 6 20:50 setup.sh'
];
}
// Navigate command history
function navigateHistory(direction) {
if (commandHistory.length === 0) return;
historyIndex += direction;
if (historyIndex < 0) {
historyIndex = 0;
} else if (historyIndex >= commandHistory.length) {
historyIndex = commandHistory.length;
currentCommand = '';
} else {
currentCommand = commandHistory[historyIndex];
}
updateCommandDisplay();
}
// Toggle terminal lock (pause/resume)
function toggleTerminalLock() {
terminalLocked = !terminalLocked;
const mainTerminal = document.getElementById('main-terminal');
const cursor = mainTerminal.querySelector('.cursor');
if (cursor) {
if (terminalLocked) {
cursor.classList.remove('blink');
} else {
cursor.classList.add('blink');
}
}
// Add status message
const statusLine = document.createElement('div');
statusLine.className = 'terminal-line info';
statusLine.textContent = terminalLocked ? 'Terminal paused. Press Ctrl+Space to resume.' : 'Terminal resumed.';
mainTerminal.insertBefore(statusLine, mainTerminal.querySelector('.terminal-line:last-child'));
}
// Cycle between subsystems
function cycleSubsystem() {
const windows = [
'main-terminal',
'network-monitor',
'system-status'
];
// Find active window
let activeIndex = 0;
windows.forEach((id, index) => {
const window = document.getElementById(id);
if (window.classList.contains('active')) {
activeIndex = index;
}
window.classList.remove('active');
});
// Activate next window
const nextIndex = (activeIndex + 1) % windows.length;
document.getElementById(windows[nextIndex]).classList.add('active');
// Add status message
const mainTerminal = document.getElementById('main-terminal');
const statusLine = document.createElement('div');
statusLine.className = 'terminal-line info';
statusLine.textContent = `Switched to ${windows[nextIndex].replace('-', ' ').toUpperCase()}`;
mainTerminal.insertBefore(statusLine, mainTerminal.querySelector('.terminal-line:last-child'));
}
// Initialize network visualization
function initNetworkVisualization() {
const canvas = document.getElementById('network-canvas');
const ctx = canvas.getContext('2d');
// Set canvas dimensions
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
// Network nodes
const nodes = [
{ id: 'gateway', x: canvas.width * 0.5, y: canvas.height * 0.3, radius: 8, color: '#ffb000' },
{ id: '192.168.1.1', x: canvas.width * 0.2, y: canvas.height * 0.5, radius: 6, color: '#33ff33' },
{ id: '192.168.1.45', x: canvas.width * 0.8, y: canvas.height * 0.5, radius: 6, color: '#33ff33' },
{ id: '192.168.1.72', x: canvas.width * 0.3, y: canvas.height * 0.7, radius: 6, color: '#ff3333' },
{ id: '192.168.1.103', x: canvas.width * 0.7, y: canvas.height * 0.7, radius: 6, color: '#33ff33' }
];
// Network connections
const connections = [
{ from: 'gateway', to: '192.168.1.1', active: true },
{ from: 'gateway', to: '192.168.1.45', active: true },
{ from: 'gateway', to: '192.168.1.72', active: false },
{ from: 'gateway', to: '192.168.1.103', active: true }
];
// Draw network
function drawNetwork() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Draw connections
connections.forEach(conn => {
const fromNode = nodes.find(n => n.id === conn.from);
const toNode = nodes.find(n => n.id === conn.to);
if (fromNode && toNode) {
ctx.beginPath();
ctx.moveTo(fromNode.x, fromNode.y);
ctx.lineTo(toNode.x, toNode.y);
if (conn.active) {
ctx.strokeStyle = 'rgba(51, 255, 51, 0.3)';
// Draw data packets
const packetPos = (Date.now() % 2000) / 2000;
const x = fromNode.x + (toNode.x - fromNode.x) * packetPos;
const y = fromNode.y + (toNode.y - fromNode.y) * packetPos;
ctx.fillStyle = '#33ff33';
ctx.arc(x, y, 3, 0, Math.PI * 2);
ctx.fill();
} else {
ctx.strokeStyle = 'rgba(255, 51, 51, 0.3)';
}
ctx.lineWidth = 2;
ctx.stroke();
}
});
// Draw nodes
nodes.forEach(node => {
ctx.beginPath();
ctx.arc(node.x, node.y, node.radius, 0, Math.PI * 2);
ctx.fillStyle = node.color;
ctx.fill();
// Node glow
ctx.beginPath();
ctx.arc(node.x, node.y, node.radius + 3, 0, Math.PI * 2);
ctx.fillStyle = `rgba(${node.color.replace(/[^\d,]/g, '')}, 0.3)`;
ctx.fill();
// Node label
ctx.fillStyle = '#ffffff';
ctx.font = '8px monospace';
ctx.textAlign = 'center';
ctx.fillText(node.id, node.x, node.y + node.radius + 12);
});
requestAnimationFrame(drawNetwork);
}
// Start animation
drawNetwork();
}
// Update network data
function updateNetworkData() {
document.getElementById('active-connections').textContent = Math.floor(Math.random() * 5) + 5;
const packetsAnalyzed = parseInt(document.getElementById('packets-analyzed').textContent.replace(/,/g, ''));
document.getElementById('packets-analyzed').textContent = (packetsAnalyzed + Math.floor(Math.random() * 500) + 100).toLocaleString();
const intrusionAttempts = parseInt(document.getElementById('intrusion-attempts').textContent);
if (Math.random() > 0.7) {
document.getElementById('intrusion-attempts').textContent = intrusionAttempts + 1;
}
}
// Initialize system monitoring
function initSystemMonitoring() {
// Update system stats periodically
setInterval(() => {
updateSystemStats();
addLogEntry();
}, 3000);
}
// Update system stats
function updateSystemStats() {
// CPU load
let cpuLoad = Math.floor(Math.random() * 30) + 30;
document.getElementById('cpu-load').style.width = `${cpuLoad}%`;
document.getElementById('cpu-load').parentElement.nextElementSibling.textContent = `${cpuLoad}%`;
// Memory usage
let memoryUsage = Math.floor(Math.random() * 20) + 60;
document.getElementById('memory-usage').style.width = `${memoryUsage}%`;
document.getElementById('memory-usage').parentElement.nextElementSibling.textContent = `${memoryUsage}%`;
// Disk I/O
let diskIO = Math.floor(Math.random() * 30) + 10;
document.getElementById('disk-io').style.width = `${diskIO}%`;
document.getElementById('disk-io').parentElement.nextElementSibling.textContent = `${diskIO}%`;
// Network usage
let networkUsage = Math.floor(Math.random() * 40) + 30;
document.getElementById('network-usage').style.width = `${networkUsage}%`;
document.getElementById('network-usage').parentElement.nextElementSibling.textContent = `${networkUsage}%`;
}
// Add log entry
function addLogEntry() {
const logContent = document.getElementById('system-log-content');
const now = new Date();
const timeString = now.toTimeString().substring(0, 8);
const logEntries = [
`[${timeString}] System scan complete - No threats detected`,
`[${timeString}] Firewall rules updated`,
`[${timeString}] Automatic security update applied`,
`[${timeString}] User authentication successful`,
`[${timeString}] Database backup completed`,
`[${timeString}] Unusual traffic pattern detected from 192.168.1.45`,
`[${timeString}] Failed login attempt from 203.0.113.42`,
`[${timeString}] CPU temperature threshold warning`,
`[${timeString}] Network interface eth0 status changed`
];
const randomEntry = logEntries[Math.floor(Math.random() * logEntries.length)];
const logEntry = document.createElement('div');
logEntry.className = 'log-entry';
// Add warning class for certain entries