-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
2755 lines (2488 loc) · 75.8 KB
/
index.html
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
<doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Enmeshed</title>
<style>
* {
font-family: monospace;
box-sizing: border-box;
user-select: none;
-webkit-user-select: none;
}
body {
background-image: -webkit-radial-gradient(top, circle cover, #094781 0%, #07345E 80%);
padding: 20px;
margin: 20px;
min-width: 1200px;
}
.display {
position: absolute;
left: 50%;
transform: translateX(-50%);
background-color: #222;
border: 10px solid #222;
border-top:20px solid #222;
border-radius: 12px 12px 4px 4px;
box-shadow:0 0 0 1px #777;
width: 1000px;
height: 660px;
}
.display::before {
content:'';
position: absolute;
top: -11px;
left: 494px;
border: 6px solid #333;
border-radius: 10px;
}
.display:after {
content:'';
position: absolute;
top: -9px;
left: 496px;
border: 4px solid #2C2C2C;
border-radius: 10px;
}
#screen {
position: absolute;
top: 10px;
left: 10px;
background-color: #181818;
width: 960px;
height: 600px;
padding: 8px;
font-size: 11px;
color: white;
}
#terminal {
position: absolute;
top: 2px;
left: 10px;
background-color: #181818;
width: 960px;
height: 595px;
padding: 8px;
font-size: 11px;
line-height: 15px;
color: white;
overflow: hidden;
}
#cursor::before {
content: '\0275A';
display: inline-block;
color: white;
animation: cursor 1s step-end infinite;
}
@keyframes cursor {
from, to {
color: white;
}
50% {
color: #181818;
}
}
#info {
position: absolute;
width: 150px;
top: 34px;
right: 8px;
text-align: right;
font-size: 11px;
background-color: rgba(24,24,24,0.8);
}
.decrypt {
animation: decrypt 2s forwards;
}
@keyframes decrypt {
from {
color: #0073b1;
}
to {
color: white;
}
}
#email {
padding-left: 10px;
width: 320px;
white-space: normal;
}
.hide {
display: none !important;
}
.fade-out {
animation: fade-out 0.5s forwards;
}
@keyframes fade-out {
to {
opacity: 0;
pointer-events: none;
}
}
#crash {
position: absolute;
top: 14px;
left: 10px;
width: 960px;
height: 580px;
padding: 8px;
overflow: hidden;
color: white;
letter-spacing: 3px;
line-height: 22px;
word-break: break-all;
white-space: pre-wrap;
opacity: 0.5;
animation: crashing 0.5s linear;
}
@keyframes crashing {
from {
height: 0;
}
to {
height: 95%;
}
}
#offline {
position: absolute;
top: -2px;
left: 10px;
width: 960px;
height: 606px;
padding: 8px;
animation: offline-fade 0.3s;
}
#offline-banner {
position: absolute;
display: inline-block;
border: 8px solid rgba(255,0,0,0.5);
border-radius: 16px;
font-size: 60px;
font-weight: 700;
padding: 20px 20px 20px 40px;
color: white;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
letter-spacing: 32px;
}
#offline-banner::before {
content: '';
position: absolute;
top: 20px;
left: 20px;
background-color: rgba(255,0,0,0.3);
width: 550px;
height: 125px;
z-index: -1;
}
.failed {
border-color: #F47E1B !important;
}
.failed:hover {
color: #F47E1B !important;
}
.failed::before {
background-color: rgba(244,126,27,0.3) !important;
}
#continue {
position: absolute;
top: 410px;
left: 640px;
color: white;
font-size: 16px;
line-height: 20px;
cursor: pointer;
padding: 8px;
background-color: #181818;
border-radius: 5px;
border: 4px solid rgba(255,0,0,0.5);
}
#continue:hover {
color: #F00;
}
@keyframes offline-fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#console {
position: absolute;
top: 530px;
height: 60px;
width: 944px;
overflow: hidden;
color: white;
font-size: 12px;
}
#retry {
position: absolute;
top: 540px;
right: 10px;
color: white;
font-size: 20px;
cursor: pointer;
display: flex;
align-items: center;
}
#retry-text {
font-size: 12px;
padding-right: 8px;
}
#quit {
position: absolute;
top: 570px;
right: 10px;
color: white;
font-size: 20px;
cursor: pointer;
display: flex;
align-items: center;
}
#quit-text {
font-size: 12px;
padding-right: 8px;
}
.brand {
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 614px;
color: #333;
font-size: 14px;
font-family: sans-serif;
letter-spacing: 1px;
}
.base {
position: absolute;
left: 50%;
transform: translateX(-50%);
top: 694px;
box-shadow: 1px 1px 10px 0px #333;
border-bottom: 3px solid #555;
border-radius: 0 0 20px 20px;
background: #999;
background-image: -webkit-linear-gradient(left, #555 0%, #777 50%, #555 100%);
width: 1160px;
height: 26px;
}
.base::before {
content:"";
display: block;
border-radius: 0 0 10px 10px;
height: 14px;
width: 180px;
left:50%;
position: absolute;
background:#999;
left: 50%;
transform: translateX(-50%);
}
.title {
letter-spacing: 3px;
background-image: -webkit-linear-gradient(left, #094781 0%, #181818 40%);
border-radius: 5px;
padding: 4px 0 4px 8px;
}
.banner {
background-image: -webkit-linear-gradient(left, #094781 0%, #181818 60%);
border-radius: 5px;
padding: 4px 0 4px 8px;
font-weight: 700;
}
#mesh {
position: absolute;
top: 30px;
left: 34px;
width: 926px;
height: 510px;
}
#mesh circle, #mesh line {
cursor: pointer;
}
.mesh-id {
position: absolute;
top: 12px;
left: 370px;
width: 230px;
text-align: center;
}
.spinner {
display: inline-block;
animation: spinner .8s ease infinite;
}
@keyframes spinner {
to {
transform: rotate(360deg);
}
}
.blink {
animation: blink 2s ease-in-out infinite alternate
}
@keyframes blink {
to {
opacity: 0.6;
}
}
.health {
position: absolute;
top: 12px;
right: 12px;
}
#coins {
position: absolute;
top: 30px;
right: 12px;
}
#data {
position: absolute;
top: 11px;
right: 175px;
}
#toolbar {
position: absolute;
top: 34px;
left: 0px;
width: 32px;
height: 400px;
font-size: 28px;
line-height: 42px;
text-align: center;
}
[data-tool] {
border-left: 2px solid transparent;
cursor: pointer;
}
[data-tool] > div {
font-size: 10px;
line-height: 10px;
padding-bottom: 10px;
}
[data-tool="info"] {
padding-top: 10px;
font-size: 20px;
font-weight: 700;
padding-left: 6px;
}
[data-tool="info"]:hover, [data-tool="info"].selected {
border-left: 2px solid #FFF;
}
[data-tool="crash"]:hover, [data-tool="crash"].selected {
border-left: 2px solid #D34E53;
}
[data-tool="cut"]:hover, [data-tool="cut"].selected {
border-left: 2px solid #F89100;
}
[data-tool="slow"]:hover, [data-tool="slow"].selected {
border-left: 2px solid #FCC700;
}
[data-tool="corrupt"] {
font-size: 20px;
}
[data-tool="corrupt"]:hover, [data-tool="corrupt"].selected {
border-left: 2px solid #535C8E;
}
[data-tool="reroute"]:hover, [data-tool="reroute"].selected {
border-left: 2px solid #9E379F;
}
[data-tool="intercept"] {
font-size: 26px;
}
[data-tool="intercept"]:hover, [data-tool="intercept"].selected {
border-left: 2px solid #1375F7;
}
[data-tool="mine"] {
font-size: 26px;
}
[data-tool="mine"]:hover, [data-tool="mine"].selected {
border-left: 2px solid #080;
}
.node {
fill: #5691DC;
}
.node:hover {
stroke: #5691DC;
stroke-width: 7px;
}
.node-effect {
stroke: transparent;
stroke-width: 2px;
fill: transparent;
pointer-events: none;
}
.node:hover + .node-effect {
stroke-width: 4px;
stroke-dasharray: none;
animation: none;
}
.node-effect-animate {
stroke-dasharray: 5 2;
animation: progress 3s linear infinite reverse;
}
.node-effect-corrupt {
stroke: #535C8E;
}
.node-effect-reroute {
stroke: #9E379F;
}
.node-effect-intercept {
stroke: #1375F7;
}
.node-effect-mine {
stroke: #080;
}
.node-effect-firewall {
stroke: #FFF;
}
.node-packet {
fill: #8BBF50;
}
.node-packet:hover {
stroke: #8BBF50 !important;
}
.node-offline {
fill: #D34E53 !important;
}
.node-offline:hover {
stroke: #D34E53 !important;
}
.edge-interact {
stroke: transparent;
stroke-width: 4px;
}
.edge-interact:hover {
stroke: rgba(153,153,153,0.3);
}
.edge-empty {
stroke: rgba(255, 255, 255, 0.2);
}
.edge-forward {
stroke: transparent;
}
.edge-reverse {
stroke: transparent;
}
.edge-slow {
stroke: #FCC700 !important;
}
.edge-cut {
stroke: #D34E53 !important;
}
.edge-empty-slow {
stroke: rgba(252, 199, 0, 0.3);
}
.edge-offline-empty {
stroke: #D34E53;
}
.edge-packet-empty {
stroke: transparent !important;
}
.edge-packet-forward {
stroke: #8BBF50;
stroke-dasharray: 5;
animation: progress 3s linear infinite;
}
.edge-packet-reverse {
stroke: #3B6D3D;
stroke-dasharray: 5;
animation: progress 3s linear infinite reverse;
}
@keyframes progress {
to {
stroke-dashoffset: 100;
}
}
</style>
<script>
//
// _____ _ _ __ __ _____ ____ _ _ _____ ____
// | ____| | \ | | | \/ | | ____| / ___| | | | | | ____| | _ \
// | _| | \| | | |\/| | | _| \___ \ | |_| | | _| | | | |
// | |___ | |\ | | | | | | |___ ___) | | _ | | |___ | |_| |
// |_____| |_| \_| |_| |_| |_____| |____/ |_| |_| |_____| |____/
//
//
// Merseene Twister Pseudo-Random Number Generator
// Used to deterministically generate stages based on a seed
function MersenneTwister(seed) {
seed = seed || Date.now();
this.N = 624;
this.M = 397;
this.MATRIX_A = 0x9908b0df;
this.UPPER_MASK = 0x80000000;
this.LOWER_MASK = 0x7fffffff;
this.I = Math.pow(2, 32);
this.mt = new Array(this.N);
this.mti = this.N + 1;
this.mt[0] = seed >>> 0;
for (this.mti = 1; this.mti < this.N; this.mti++) {
const s = this.mt[this.mti - 1] ^ (this.mt[this.mti - 1] >>> 30);
this.mt[this.mti] = (((((s & 0xffff0000) >>> 16) * 1812433253) << 16) +
(s & 0x0000ffff) * 1812433253) + this.mti;
this.mt[this.mti] >>>= 0;
}
};
MersenneTwister.prototype.random = function() {
const mag01 = new Array(0x0, this.MATRIX_A);
let y;
if (this.mti >= this.N) {
let kk;
for (kk = 0; kk < this.N - this.M; kk++) {
y = (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);
this.mt[kk] = this.mt[kk + this.M] ^ (y >>> 1) ^ mag01[y & 0x1];
}
for (;kk < this.N - 1; kk++) {
y = (this.mt[kk] & this.UPPER_MASK) | (this.mt[kk + 1] & this.LOWER_MASK);
this.mt[kk] = this.mt[kk + (this.M - this.N)] ^ (y >>> 1) ^ mag01[y & 0x1];
}
y = (this.mt[this.N - 1] & this.UPPER_MASK) | (this.mt[0] & this.LOWER_MASK);
this.mt[this.N - 1] = this.mt[this.M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];
this.mti = 0;
}
y = this.mt[this.mti++];
y ^= (y >>> 11);
y ^= (y << 7) & 0x9d2c5680;
y ^= (y << 15) & 0xefc60000;
y ^= (y >>> 18);
y = y >>> 0;
return (y + 0.5) / this.I;
};
// Rotate-13 "encryption"
function rot13(text, decrypt) {
let string = '';
for (let i = 0; i < text.length; i++) {
let value = text.charCodeAt(i);
value += (decrypt) ? -13 : 13;
if (value > 126) {
value = 32 + (value - 127);
} else if (value < 32) {
value = 127 + (value - 32);
}
string += String.fromCharCode(value);
}
return string;
}
// Create a separate random number generator for ephemeral details
const prng = new MersenneTwister();
const rand = (min, max) => Math.floor(prng.random() * (max - min + 1)) + min;
// Map that returns Infinity rather than undefined,
// used for scoring paths in A* path finding
Map.prototype.value = function(key) {
const value = this.get(key);
if (value === undefined) {
return Infinity;
}
return value;
};
// Convenience functions
const size = (object) => Object.keys(object || {}).length;
const $ = id => document.getElementById(id);
const add = (element, className) => element.classList.add(className);
const remove = (element, className) => element.classList.remove(className);
const hide = element => add(element, 'hide');
const show = element => remove(element, 'hide');
const scroll = element => element.scrollTop = element.scrollHeight + element.clientHeight;
// Random, fake IP Address generator
let IPs = {};
function generateIP() {
let address = null;
while (address === null || IPs[address]) {
address = rand(1, 254) + '.' + rand(0, 254) + '.' + rand(0, 254) + '.' + rand(1, 254);
}
IPs[address] = true;
return address;
}
// Asynchronous sequencer for managing game state across different async events
// such as input, game router, press enter to continue...
function sequence(worker, done) {
let i = 0;
function queue(func, delay) {
setTimeout(func, delay || 0);
}
function next(timeout) {
if (timeout === false) {
if (done) {
queue(done);
}
} else {
i++;
timeout = (timeout === undefined || timeout < 0) ? 100 : parseInt(timeout);
queue(iterate, timeout);
}
}
function iterate() {
queue(function() {
worker(next, i);
});
}
iterate();
}
//////////
// Game Script as large text blobs with "&" triggers, simplistic turing machine
// for driving the game state.
const boot = `<div class="banner">Gilgamesh OS version 4.15.0-33-generic (build 13,312)</div>
Command line: BOOT_IMAGE=/gilgamesh-4.15.0-33-generic root=/dev/sda2:ro
KERNEL supported cpus:
MaasNeotek m47_64
m47/fpu: Supporting XSAVE feature 0x001: m87 floating point registers
m47/fpu: Supporting XSAVE feature 0x002: SSE registers
m47/fpu: Enabled xstate features 0x7, context size 832 bytes
e820: BIOS-provided physical RAM map
e820: update [mem 0x00000000-0x00000fff] usable => reserved
total RAM covered: 16288M
On node 0 totalpages: 4164976
DMA zone: 64 pages used for memmap
DMA zone: 3997 pages, LIFO batch:0
Normal zone: 54720 pages used for memmap
Normal zone: 3502080 pages, LIFO batch:31
Reserved but unavailable: 98 pages
ACPI: PM-Timer IO Port: 0x1808
ACPI: Local APIC address 0xfee00
smpboot: Allowing 4 CPUs
Kernel/User page tables isolation enabled
Hierarchical RCU implementation
RCU restricting CPUs from nr_cpu=8192 to nr_cpu_ids=4
Tasks RCU enabled
RCU: Adjusting geometry for nr_cpu_ids=4
NR_IRQS 52454, nr_irqs 728, preallocated irqs 16
console: color smart device [tty0] enabled
ACPI: Core revision 20180813
Security Framework initialized
mce: CPU supports 7 MCE banks
smp: Bringing up secondary CPUs
m47: Booting SMP configuration:
node 0, CPUs: 1 2 3
smp: Brought up 1 node, 4 CPUs
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io 0x0000-0x0cf7]
pci_bus 0000:00: root bus resource [mem 0xfe000000-0xfe113fff]
pci_bus 0000:00: root bus resource [bus 00-3e]
usbcore: registered new interface drivers: usbfs, hub, usb, mesh
NET: Registered protocol family 1
NET: Registered protocol family 2
TCP established hash table entries: 1310722 (1048576 bytes)
TCP bind hash table entries: 65536 (1048576 bytes)
TCP: Hash tables configured (established 131072 bind 65536)
NET: Registered protocol family 47
Meshtooth: Core ver 0.47
Meshtooth: NET device and connection manager initialized
EXT5-fs (sda2): mounting ext4 file system using the ext5 subsystem
EXT5-fs (sda2): mounted filesystem with journal.
Bridge firewalling registered
Initializing XFRM meshlink socket
Meshfilter messages via MESHLINK v0.47
random: initializing Mersenne Twister
MeshConnect initializing interface mesh0
&K
?2000Entering interactive mode...!!
&L
Gilgamesh 47.04.3 LTS terminus tty0
terminus login: &Tmark
Password: &T&R15*
?800!!
Welcome to Gilgamesh 47.04.3 LTS (Gilgamesh OS 4.15.0-33 m47_64)
System information as of &DT
System load: 0.0 Processes: 135
Usage of /: 2.1% of 256GB Users logged in: 1
Memory usage: 1% IP address for en0: &IP
Swap usage: 0% IP address for mesh0: &IP
Last login: &DP
You have new mail.
`;
const menu = `&P&T./enmeshed
<div style="color:#005b96;line-height:8px;letter-spacing:-1px"> ███████╗███╗ ██╗███╗ ███╗███████╗███████╗██╗ ██╗███████╗██████╗<br> ██╔════╝████╗ ██║████╗ ████║██╔════╝██╔════╝██║ ██║██╔════╝██╔══██╗<br> █████╗ ██╔██╗ ██║██╔████╔██║█████╗ ███████╗███████║█████╗ ██║ ██║<br> ██╔══╝ ██║╚██╗██║██║╚██╔╝██║██╔══╝ ╚════██║██╔══██║██╔══╝ ██║ ██║<br> ███████╗██║ ╚████║██║ ╚═╝ ██║███████╗███████║██║ ██║███████╗██████╔╝<br> ╚══════╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚══════╝╚═════╝<br><br>&R73─
&$
1) Story
2) Challenge
&O
&I`;
const rimraf = `
?1000&Prm -rf /
&KKernel Panic
Kernel Panic
Kernel Panic
OFFLINE
?5000Rebooting...`;
const message = `Mark,
I can't believe you were forced out of the company that YOU founded
because you tried stop Gilgamesh technology from being deployed as a
tool for surveillance and censorship.
The first phase of meshes are being rolled out today. Hypothetically
speaking, it would be a disasterous if somehow all those meshes went
offline... A failure of that scale would likely doom the company and
the technology. Anywho, I've attached some unrelated data that can
just delete...
Good luck,
-Deborah`.replace(/\n/g, '&');
const email = `
&P&Tmail --unread
&m one unread message:
&V┌&R72─
&BDate:&b &DE
&BFrom:&b Unverified Sender <[email protected]>
&BTo:&b Mark Barr <[email protected]>
&BSubject:&b Hackers Hate This Mesh Network, Find Out Why!
&BAttachments:&b <span id="attachment">mesh.pdf.exe</span>
<div id="email">${ rot13(message) }</div>
&V└&R72─
?3000&m Encryption detected - decrypting... <span id="decryptor" class="spinner">|</span>
&Y&C&m Press &BENTER&b to download attachment and delete message.
&y&N&m saved to ~/Downloads/enmeshed.zip
&P&Tunzip ~/Downloads/enmeshed.zip
inflating: enmeshed.txt
extracting: gilgamesh-plugin-MemCorrupt.bin
extracting: gilgamesh-plugin-DoS.RST.bin
extracting: gilgamesh-plugin-MiTM.Proxy.bin
&P&Tcat enmeshed.txt
&F
&G0
`;
//////////
// Mesh Edges, tracks several svg elements for state and animation,
// manages mouse over and click interactions
function Edge(mesh, edgeId, start, end) {
const self = this;
// Identifiers
self.object = 'edge';
self.id = edgeId;
self.name = mesh.edges.length.toString(16).padStart(4, 0);
// States
self.online = true;
self.speed = mesh.rand(1, mesh.speeds.length - 1);
// Associated nodes with positions
self.nodes = [
start, end
];
self.start = {
x: start.pos.x,
y: start.pos.y
};
self.end = {
x: end.pos.x,
y: end.pos.y
};
// Timing based measure of length
self.ticks = Math.ceil(mesh.distance(start, end));
// SVG elements
self.elements = {
empty: mesh.svg.line(self.start.x, self.start.y, self.end.x, self.end.y, 'edge-empty'),
forward: mesh.svg.line(self.start.x, self.start.y, self.end.x, self.end.y, 'edge-forward'),
reverse: mesh.svg.line(self.start.x, self.start.y, self.end.x, self.end.y, 'edge-reverse'),
interact: mesh.svg.line(self.start.x, self.start.y, self.end.x, self.end.y, 'edge-interact')
};
// Click, applies effect when one is selected
self.elements.interact.onclick = function() {
if (!self.effect) {
if (mesh.effect.type === 'cut' && mesh.tools.cut.decrement()) {
self.online = false;
add(self.elements.empty, 'edge-offline-empty');
add(self.elements.forward, 'edge-cut');
add(self.elements.reverse, 'edge-cut');
} else if (mesh.effect.type === 'slow' && mesh.tools.slow.decrement()) {
self.speed = 0;
add(self.elements.empty, 'edge-empty-slow');
add(self.elements.forward, 'edge-slow');
add(self.elements.reverse, 'edge-slow');
} else {
return;
}
self.effect = mesh.tools[mesh.effect.type];
}
};
// Mouse over, displays info and any applied effects
self.elements.interact.onmouseover = function() {
const len = Math.max(start.address.length, end.address.length);
let info = 'Connection #' + self.name + mesh.dotColor(self) + '\n\n' +
mesh.dotColor(start) + ' ↱ ' + start.address.padStart(len, ' ') + ' \n' +
mesh.dotColor(end) + ' ' + end.address.padEnd(len, ' ') + ' ↲ ' +
'\n\n' + 'Bandwidth:'.padEnd(len + 3, ' ') + '\n';
if (self.speed === 0) {
info += '<span style="color:#D9AF3C">' + mesh.speeds[self.speed].name + ' </span>';
} else {
info += mesh.speeds[self.speed].name + ' ';
}
if (self.effect) {
info += '\n\n<span style="color:red">Anomaly detected: </span>\n' +
self.effect.name + '/' + self.effect.cve;
}
mesh.elements.info.innerHTML = info;
};
// Mouse out, clears info
self.elements.interact.onmouseout = function() {
mesh.elements.info.innerHTML = '';
};
// Association with entire mesh
mesh.edges.push(self);
mesh.connections[edgeId] = self;
// Sets itself as a connection on start adn end nodes
start.connections[end.id] = {
source: start,
node: end,
edge: self
};
end.connections[start.id] = {
source: end,
node: start,
edge: self
};
// Interfaces for tracking statistics
start.interfaces[edgeId] = {
name: 'me' + size(start.interfaces),
rx: 0,
tx: 0,
dropped: 0
};
end.interfaces[edgeId] = {
name: 'me' + size(end.interfaces),
rx: 0,
tx: 0,
dropped: 0
};
// Any packets currently traversing the edge
const packets = new Set();
self.packet = {};
// Scan what packets are present to control animations
self.packet.scan = function() {
if (packets.size) {
let forward = false;
let reverse = false;
packets.forEach(function(item) {
if (item.hop && item.hop.node === start) {
forward = true;
} else {
reverse = true;
}
});
add(self.elements.empty, 'edge-packet-empty');
if (forward) {
add(self.elements.forward, 'edge-packet-forward');
} else {
remove(self.elements.forward, 'edge-packet-forward');
}
if (reverse) {
add(self.elements.reverse, 'edge-packet-reverse');
} else {
remove(self.elements.reverse, 'edge-packet-reverse');
}
} else {
remove(self.elements.empty, 'edge-packet-empty');
remove(self.elements.forward, 'edge-packet-forward');
remove(self.elements.reverse, 'edge-packet-reverse');
}
};
// Add a packet to the edge and set animations
self.packet.add = function(packet) {
packets.add(packet);
self.packet.scan();
};
// Remove a packet from the edge and set animations
self.packet.delete = function(packet) {
packets.delete(packet);
self.packet.scan();
};
return self;
}
// Mesh Nodes, randomly placed, tracks state and animations with
// a few svg elements, provides interactions
function Node(mesh) {
const self = this;
self.object = 'node';
self.online = true;
// Generate random, unoccupied position, tracked as an ID
while (self.id === undefined || mesh.positions[self.id] !== undefined) {
self.x = mesh.rand(0, mesh.width - 1);
self.y = mesh.rand(0, mesh.height - 1);
self.id = mesh.id(self.x, self.y);
}
mesh.positions[self.id] = self;
// Position with random perturbations to avoid too much a grid look
self.pos = {
x: (self.x * mesh.scale) + (mesh.scale / 2) + mesh.rand(-mesh.perturb, mesh.perturb),
y: (self.y * mesh.scale) + (mesh.scale / 2) + mesh.rand(-mesh.perturb, mesh.perturb)
};
self.address = generateIP();
mesh.addresses[self.address] = self;
self.connections = {};
self.interfaces = {};
// Find neighboring nodes within a specified range
self.search = function(range) {
const neighbors = [];
for (let y = self.y - range; y <= (self.y + range); y++) {
for (let x = self.x - range; x <= (self.x + range); x++) {
const neighbor = mesh.coords(x, y);
if (neighbor && neighbor.id !== self.id) {
neighbors.push(neighbor);
}
}
}
return neighbors;
};
// Connect this node to neighbors with an increasing distance until
// a minimum number of connections is met
self.connect = function() {
for (let range = mesh.range; size(self.connections) < mesh.minimum; range++) {
self.search(range).forEach(function(neighbor) {