-
Notifications
You must be signed in to change notification settings - Fork 2
/
Computer.cs
1988 lines (1886 loc) · 52.1 KB
/
Computer.cs
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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Xml;
using Hacknet.Security;
using Microsoft.Xna.Framework;
namespace Hacknet
{
// Token: 0x02000101 RID: 257
[Serializable]
internal class Computer
{
// Token: 0x060005A0 RID: 1440 RVA: 0x000580B8 File Offset: 0x000562B8
public Computer(string compName, string compIP, Vector2 compLocation, int seclevel, byte compType, OS opSystem)
{
this.name = compName;
this.ip = compIP;
this.location = compLocation;
this.type = compType;
this.files = this.generateRandomFileSystem();
this.idName = compName.Replace(" ", "_");
this.os = opSystem;
this.traceTime = -1f;
this.securityLevel = seclevel;
this.adminIP = NetworkMap.generateRandomIP();
this.users = new List<UserDetail>();
this.adminPass = PortExploits.getRandomPassword();
this.users.Add(new UserDetail("admin", this.adminPass, 1));
this.ports = new List<int>(seclevel);
this.portsOpen = new List<byte>(seclevel);
this.openPortsForSecurityLevel(seclevel);
this.links = new List<int>();
this.daemons = new List<Daemon>();
}
// Token: 0x060005A1 RID: 1441 RVA: 0x0005823C File Offset: 0x0005643C
public void initDaemons()
{
for (int i = 0; i < this.daemons.Count; i++)
{
this.daemons[i].initFiles();
if (this.daemons[i].isListed)
{
this.daemons[i].registerAsDefaultBootDaemon();
}
}
}
// Token: 0x060005A2 RID: 1442 RVA: 0x000582A4 File Offset: 0x000564A4
public FileSystem generateRandomFileSystem()
{
FileSystem fileSystem = new FileSystem();
if (this.type != 5 && this.type != 4)
{
int num = Utils.random.Next(6);
for (int i = 0; i < num; i++)
{
int num2 = 0;
string text;
do
{
text = ((num2 > 10) ? "AA" : "") + this.generateFolderName(Utils.random.Next(100));
num2++;
}
while (fileSystem.root.folders[0].searchForFolder(text) != null);
Folder folder = new Folder(text);
int num3 = Utils.random.Next(3);
for (int j = 0; j < num3; j++)
{
if (Utils.random.NextDouble() > 0.8)
{
num2 = 0;
string text2;
do
{
text2 = this.generateFileName(Utils.random.Next(300));
num2++;
if (num2 > 3)
{
text2 = (int)(Utils.getRandomChar() + Utils.getRandomChar()) + text2;
}
}
while (folder.searchForFile(text2) != null);
folder.files.Add(new FileEntry(Utils.flipCoin() ? this.generateFileData(Utils.random.Next(500)) : Computer.generateBinaryString(500), text2));
}
else
{
FileEntry fileEntry = new FileEntry();
string arg = fileEntry.name;
while (folder.searchForFile(fileEntry.name) != null)
{
fileEntry.name = (int)(Utils.getRandomChar() + Utils.getRandomChar()) + arg;
}
folder.files.Add(fileEntry);
}
}
fileSystem.root.folders[0].folders.Add(folder);
}
}
else if (this.type == 5)
{
fileSystem.root.folders.Insert(0, EOSComp.GenerateEOSFolder());
}
return fileSystem;
}
// Token: 0x060005A3 RID: 1443 RVA: 0x00058500 File Offset: 0x00056700
public void openPortsForSecurityLevel(int security)
{
this.portsNeededForCrack = security - 1;
if (security >= 5)
{
this.portsNeededForCrack--;
float num = 0f;
for (int i = 4; i < security; i++)
{
num += Computer.BASE_PROXY_TICKS / (float)(i - 3);
}
this.addProxy(num);
}
switch (security)
{
default:
this.openPorts(PortExploits.portNums.Count);
break;
case 1:
this.openPorts(PortExploits.portNums.Count - 1);
break;
}
if (security >= 4)
{
this.traceTime = (float)Math.Max(10 - security, 3) * Computer.BASE_TRACE_TIME;
}
if (security >= 5)
{
this.firewall = new Firewall(security - 5);
this.admin = new BasicAdministrator();
}
}
// Token: 0x060005A4 RID: 1444 RVA: 0x000585DC File Offset: 0x000567DC
private void openPorts(int n)
{
int num = 4;
for (int i = num - 1; i >= 0; i--)
{
this.ports.Add(PortExploits.portNums[i]);
this.portsOpen.Add(0);
}
}
// Token: 0x060005A5 RID: 1445 RVA: 0x00058628 File Offset: 0x00056828
public void addProxy(float time)
{
if (time > 0f)
{
this.hasProxy = true;
this.proxyActive = true;
this.proxyOverloadTicks = time;
this.startingOverloadTicks = this.proxyOverloadTicks;
}
}
// Token: 0x060005A6 RID: 1446 RVA: 0x00058668 File Offset: 0x00056868
public void addFirewall(int level)
{
this.firewall = new Firewall(level);
}
// Token: 0x060005A7 RID: 1447 RVA: 0x00058677 File Offset: 0x00056877
public void addFirewall(int level, string solution)
{
this.firewall = new Firewall(level, solution);
}
// Token: 0x060005A8 RID: 1448 RVA: 0x00058687 File Offset: 0x00056887
public void addFirewall(int level, string solution, float additionalTime)
{
this.firewall = new Firewall(level, solution, additionalTime);
}
// Token: 0x060005A9 RID: 1449 RVA: 0x00058698 File Offset: 0x00056898
public void addMultiplayerTargetFile()
{
this.files.root.folders[0].files.Add(new FileEntry("#CRITICAL SYSTEM FILE - DO NOT MODIFY#\n\n" + Computer.generateBinaryString(2000), "system32.sys"));
}
// Token: 0x060005AA RID: 1450 RVA: 0x000586E8 File Offset: 0x000568E8
private void sendNetworkMessage(string s)
{
if (this.os.multiplayer && !this.silent)
{
this.os.sendMessage(s);
}
if (this.externalCounterpart != null)
{
this.externalCounterpart.writeMessage(s);
}
}
// Token: 0x060005AB RID: 1451 RVA: 0x0005873C File Offset: 0x0005693C
private void tryExternalCounterpartDisconnect()
{
if (this.externalCounterpart != null)
{
this.externalCounterpart.disconnect();
}
}
// Token: 0x060005AC RID: 1452 RVA: 0x00058764 File Offset: 0x00056964
public void hostileActionTaken()
{
if (this.os.connectedComp != null)
{
if (this.os.connectedComp.ip.Equals(this.ip))
{
if (this.traceTime > 0f)
{
this.os.traceTracker.start(this.traceTime);
}
if (this.os.timer - this.timeLastPinged > 0.35f)
{
SFX.addCircle(this.getScreenSpacePosition(), this.os.brightLockedColor, 25f);
this.timeLastPinged = this.os.timer;
}
}
}
}
// Token: 0x060005AD RID: 1453 RVA: 0x0005882C File Offset: 0x00056A2C
public void bootupTick(float t)
{
this.bootTimer -= t;
if (this.bootTimer <= 0f)
{
this.disabled = false;
}
}
// Token: 0x060005AE RID: 1454 RVA: 0x00058864 File Offset: 0x00056A64
public void log(string message)
{
if (!this.disabled)
{
if (this.reportingShell != null)
{
this.reportingShell.reportedTo(message);
}
message = string.Concat(new object[]
{
"@",
(int)OS.currentElapsedTime,
" ",
message
});
string text = message;
if (text.Length > 256)
{
text = text.Substring(0, 256);
}
string text2 = text.Replace(" ", "_");
int num = 0;
Folder folder = this.files.root.searchForFolder("log");
bool flag;
do
{
flag = false;
for (int i = 0; i < folder.files.Count; i++)
{
if (folder.files[i] != null && folder.files[i].name == text2)
{
flag = true;
num++;
text2 = (text + "_" + num).Replace(" ", "_");
}
}
}
while (flag);
text = text2;
this.files.root.searchForFolder("log").files.Insert(0, new FileEntry(message, text));
}
}
// Token: 0x060005AF RID: 1455 RVA: 0x000589E8 File Offset: 0x00056BE8
public string generateFolderName(int seed)
{
return "NewFolder" + seed;
}
// Token: 0x060005B0 RID: 1456 RVA: 0x00058A0C File Offset: 0x00056C0C
public string generateFileName(int seed)
{
return "Data" + seed;
}
// Token: 0x060005B1 RID: 1457 RVA: 0x00058A30 File Offset: 0x00056C30
public string generateFileData(int seed)
{
string text = "";
for (int i = 0; i < seed; i++)
{
text = text + " " + i;
}
return text;
}
// Token: 0x060005B2 RID: 1458 RVA: 0x00058A70 File Offset: 0x00056C70
public bool connect(string ipFrom)
{
bool result;
if (this.disabled)
{
result = false;
}
else
{
WhitelistConnectionDaemon whitelistConnectionDaemon = (WhitelistConnectionDaemon)this.getDaemon(typeof(WhitelistConnectionDaemon));
if (whitelistConnectionDaemon != null && ipFrom == this.os.thisComputer.ip)
{
if (!whitelistConnectionDaemon.IPCanPassWhitelist(ipFrom, false))
{
whitelistConnectionDaemon.DisconnectTarget();
return false;
}
}
this.log("Connection: from " + ipFrom);
this.sendNetworkMessage("cConnection " + this.ip + " " + ipFrom);
if (this.externalCounterpart != null)
{
this.externalCounterpart.establishConnection();
}
this.userLoggedIn = false;
result = true;
}
return result;
}
// Token: 0x060005B3 RID: 1459 RVA: 0x00058B3C File Offset: 0x00056D3C
public void addNewUser(string ipFrom, string name, string pass, byte type)
{
this.addNewUser(ipFrom, new UserDetail(name, pass, type));
}
// Token: 0x060005B4 RID: 1460 RVA: 0x00058B50 File Offset: 0x00056D50
public void addNewUser(string ipFrom, UserDetail usr)
{
this.users.Add(usr);
if (!this.silent)
{
this.log("User Account Added: from " + ipFrom + " -Name: " + this.name);
}
this.sendNetworkMessage(string.Concat(new object[]
{
"cAddUser #",
this.ip,
"#",
ipFrom,
"#",
this.name,
"#",
usr.pass,
"#",
usr.type
}));
for (int i = 0; i < this.daemons.Count; i++)
{
this.daemons[i].userAdded(usr.name, usr.pass, usr.type);
}
}
// Token: 0x060005B5 RID: 1461 RVA: 0x00058C44 File Offset: 0x00056E44
public void crash(string ipFrom)
{
if (this.os.connectedComp != null && this.os.connectedComp.Equals(this) && !this.os.connectedComp.Equals(this.os.thisComputer))
{
bool flag = this.os.connectedComp.silent;
Computer connectedComp = this.os.connectedComp;
connectedComp.silent = true;
this.os.connectedComputerCrashed(this);
connectedComp.silent = flag;
}
else if (this.os.thisComputer.Equals(this))
{
this.os.thisComputerCrashed();
}
if (!this.silent)
{
this.log("CRASH REPORT: Kernel Panic -- Fatal Trap");
}
this.disabled = true;
this.bootTimer = Computer.BASE_BOOT_TIME;
this.tryExternalCounterpartDisconnect();
PostProcessor.dangerModeEnabled = false;
this.sendNetworkMessage("cCrash " + this.ip + " " + ipFrom);
}
// Token: 0x060005B6 RID: 1462 RVA: 0x00058D4C File Offset: 0x00056F4C
public void reboot(string ipFrom)
{
if (this.os.connectedComp != null && this.os.connectedComp.Equals(this) && !this.os.connectedComp.Equals(this.os.thisComputer))
{
this.os.connectedComputerCrashed(this);
}
else if (this.os.thisComputer.Equals(this) || this.os.thisComputer.Equals(this.os.connectedComp))
{
this.os.rebootThisComputer();
}
if (!this.silent)
{
this.log("Rebooting system : " + ipFrom);
}
this.disabled = true;
this.bootTimer = Computer.BASE_REBOOT_TIME;
this.tryExternalCounterpartDisconnect();
this.sendNetworkMessage("cReboot " + this.ip + " " + ipFrom);
}
// Token: 0x060005B7 RID: 1463 RVA: 0x00058E4C File Offset: 0x0005704C
public bool canReadFile(string ipFrom, FileEntry f, int index)
{
bool flag = false;
if (ipFrom.Equals(this.adminIP))
{
flag = true;
}
if (ipFrom == this.os.thisComputer.ip && this.currentUser.name != null && this.currentUser.type == 0)
{
flag = true;
}
else
{
for (int i = 0; i < this.users.Count; i++)
{
if (ipFrom.Equals(this.users[i]))
{
flag = true;
}
}
}
bool result;
if (!flag)
{
result = false;
}
else
{
if (f.name[0] != '@')
{
this.log("FileRead: by " + ipFrom + " - file:" + f.name);
this.sendNetworkMessage(string.Concat(new object[]
{
"cFile ",
this.ip,
" ",
ipFrom,
" ",
f.name,
" ",
index
}));
}
result = true;
}
return result;
}
// Token: 0x060005B8 RID: 1464 RVA: 0x00058F98 File Offset: 0x00057198
public bool canCopyFile(string ipFrom, string name)
{
if (this.currentUser.type != 0)
{
if (!this.silent && !ipFrom.Equals(this.adminIP))
{
return false;
}
}
this.log("FileCopied: by " + ipFrom + " - file:" + name);
string s = string.Concat(new string[]
{
"cCopy ",
this.ip,
" ",
ipFrom,
" ",
name
});
this.sendNetworkMessage(s);
return true;
}
// Token: 0x060005B9 RID: 1465 RVA: 0x00059038 File Offset: 0x00057238
public bool deleteFile(string ipFrom, string name, List<int> folderPath)
{
bool flag = false;
if (this.currentUser.type == 1 || this.currentUser.type == 0)
{
flag = true;
}
bool result;
if (!flag && !this.silent && !ipFrom.Equals(this.adminIP) && !ipFrom.Equals(this.ip))
{
result = false;
}
else if (name == "*")
{
Folder folder = this.files.root;
if (folderPath.Count > 0)
{
folder = Programs.getFolderFromNavigationPath(folderPath, folder, this.os);
}
bool flag2 = true;
List<string> list = new List<string>();
for (int i = 0; i < folder.files.Count; i++)
{
if (folder.files[i] != null && !string.IsNullOrWhiteSpace(folder.files[i].name))
{
list.Add(folder.files[i].name);
}
}
for (int i = 0; i < list.Count; i++)
{
flag2 &= this.deleteFile(ipFrom, list[i], folderPath);
}
result = flag2;
}
else
{
if (name[0] != '@')
{
this.log("FileDeleted: by " + ipFrom + " - file:" + name);
}
Folder folder2 = this.files.root;
if (folderPath.Count > 0)
{
folder2 = Programs.getFolderFromNavigationPath(folderPath, folder2, this.os);
}
string value = name;
if (this.os.multiplayer && name[0] == '@')
{
value = name.Substring(name.IndexOf('_'));
}
for (int i = 0; i < folder2.files.Count; i++)
{
string text = folder2.files[i].name;
bool flag3;
if (this.os.multiplayer && name[0] == '@')
{
text = text.Substring(text.IndexOf('_'));
flag3 = text.Equals(value);
}
else
{
flag3 = text.Equals(name);
}
if (flag3)
{
folder2.files.RemoveAt(i);
i--;
}
}
string text2 = string.Concat(new string[]
{
"cDelete #",
this.ip,
"#",
ipFrom,
"#",
name
});
for (int i = 0; i < folderPath.Count; i++)
{
text2 = text2 + "#" + folderPath[i];
}
this.sendNetworkMessage(text2);
result = true;
}
return result;
}
// Token: 0x060005BA RID: 1466 RVA: 0x00059370 File Offset: 0x00057570
public bool moveFile(string ipFrom, string name, string newName, List<int> folderPath, List<int> destFolderPath)
{
if (this.currentUser.type != 0)
{
if (!this.silent && !ipFrom.Equals(this.adminIP) && !ipFrom.Equals(this.ip))
{
return false;
}
}
Folder folder = this.files.root;
folder = Programs.getFolderFromNavigationPath(folderPath, this.files.root, this.os);
Folder folder2 = Programs.getFolderFromNavigationPath(destFolderPath, this.files.root, this.os);
if (newName.StartsWith("/"))
{
if (destFolderPath.Count == 0 || (folderPath.Count > 0 && destFolderPath.Count == folderPath.Count && destFolderPath[0] == folderPath[0]))
{
folder2 = this.files.root;
newName = newName.Substring(1);
Folder folder3 = folder2.searchForFolder(newName);
if (folder3 != null)
{
folder2 = folder3;
newName = name;
}
}
else
{
newName = newName.Substring(1);
}
}
FileEntry fileEntry = null;
for (int i = 0; i < folder.files.Count; i++)
{
if (folder.files[i].name == name)
{
fileEntry = folder.files[i];
folder.files.RemoveAt(i);
break;
}
}
bool result;
if (fileEntry == null)
{
this.os.write("File not Found");
result = false;
}
else
{
if (newName == "" || newName == " ")
{
newName = name;
}
fileEntry.name = newName;
string text = fileEntry.name;
int num = 1;
while (folder2.searchForFile(fileEntry.name) != null)
{
fileEntry.name = string.Concat(new object[]
{
text,
"(",
num,
")"
});
num++;
}
folder2.files.Add(fileEntry);
string text2 = string.Concat(new string[]
{
"cMove #",
this.ip,
"#",
ipFrom,
"#",
name,
"#",
newName,
"#"
});
for (int i = 0; i < folderPath.Count; i++)
{
text2 = text2 + "%" + folderPath[i];
}
text2 += "#";
for (int i = 0; i < destFolderPath.Count; i++)
{
text2 = text2 + "%" + destFolderPath[i];
}
this.sendNetworkMessage(text2);
this.log(string.Concat(new string[]
{
"FileMoved: by ",
ipFrom,
" - file:",
name,
" To: ",
newName
}));
result = true;
}
return result;
}
// Token: 0x060005BB RID: 1467 RVA: 0x000596F8 File Offset: 0x000578F8
public bool makeFile(string ipFrom, string name, string data, List<int> folderPath, bool isUpload = false)
{
bool result;
if (!isUpload && !this.silent && !ipFrom.Equals(this.adminIP) && !ipFrom.Equals(this.ip))
{
result = false;
}
else
{
if (name[0] != '@')
{
this.log("FileCreated: by " + ipFrom + " - file:" + name);
}
Folder folder = this.files.root;
if (folderPath.Count > 0)
{
for (int i = 0; i < folderPath.Count; i++)
{
if (folder.folders.Count > folderPath[i])
{
folder = folder.folders[folderPath[i]];
}
}
}
if (isUpload)
{
folder.files.Insert(0, new FileEntry(data, name));
}
else
{
folder.files.Add(new FileEntry(data, name));
}
string text = string.Concat(new string[]
{
"cMake #",
this.ip,
"#",
ipFrom,
"#",
name,
"#",
data
});
for (int i = 0; i < folderPath.Count; i++)
{
text = text + "#" + folderPath[i];
}
this.sendNetworkMessage(text);
result = true;
}
return result;
}
// Token: 0x060005BC RID: 1468 RVA: 0x0005989C File Offset: 0x00057A9C
public bool makeFolder(string ipFrom, string name, List<int> folderPath)
{
bool result;
if (!this.silent && !ipFrom.Equals(this.adminIP) && !ipFrom.Equals(this.ip))
{
result = false;
}
else
{
if (name[0] != '@')
{
this.log("FolderCreated: by " + ipFrom + " - folder:" + name);
}
Folder folder = this.files.root;
if (folderPath.Count > 0)
{
for (int i = 0; i < folderPath.Count; i++)
{
if (folder.folders.Count > folderPath[i])
{
folder = folder.folders[folderPath[i]];
}
}
}
folder.folders.Add(new Folder(name));
string text = string.Concat(new string[]
{
"cMkDir #",
this.ip,
"#",
ipFrom,
"#",
name
});
for (int i = 0; i < folderPath.Count; i++)
{
text = text + "#" + folderPath[i];
}
this.sendNetworkMessage(text);
result = true;
}
return result;
}
// Token: 0x060005BD RID: 1469 RVA: 0x00059A04 File Offset: 0x00057C04
public void disconnecting(string ipFrom, bool externalDisconnectToo = true)
{
if (!this.silent)
{
this.log(ipFrom + " Disconnected");
}
if (this.os.multiplayer && !this.silent)
{
this.sendNetworkMessage("cDisconnect " + this.ip + " " + ipFrom);
}
if (externalDisconnectToo)
{
this.tryExternalCounterpartDisconnect();
}
}
// Token: 0x060005BE RID: 1470 RVA: 0x00059A7C File Offset: 0x00057C7C
public void giveAdmin(string ipFrom)
{
this.adminIP = ipFrom;
this.log(ipFrom + " Became Admin");
if (this.os.multiplayer && !this.silent)
{
this.sendNetworkMessage("cAdmin " + this.ip + " " + ipFrom);
}
UserDetail value = this.users[0];
value.known = true;
this.users[0] = value;
}
// Token: 0x060005BF RID: 1471 RVA: 0x00059B00 File Offset: 0x00057D00
public void openPort(int portNum, string ipFrom)
{
portNum = this.GetCodePortNumberFromDisplayPort(portNum);
int num = -1;
for (int i = 0; i < this.ports.Count; i++)
{
if (this.ports[i] == portNum)
{
num = i;
break;
}
}
if (num != -1)
{
this.portsOpen[num] = 1;
}
this.log(ipFrom + " Opened Port#" + portNum);
if (!this.silent)
{
this.sendNetworkMessage(string.Concat(new object[]
{
"cPortOpen ",
this.ip,
" ",
ipFrom,
" ",
portNum
}));
}
}
// Token: 0x060005C0 RID: 1472 RVA: 0x00059BCC File Offset: 0x00057DCC
public void closePort(int portNum, string ipFrom)
{
portNum = this.GetCodePortNumberFromDisplayPort(portNum);
int num = -1;
for (int i = 0; i < this.ports.Count; i++)
{
if (this.ports[i] == portNum)
{
num = i;
}
}
bool flag = false;
if (num != -1)
{
flag = (this.portsOpen[num] != 0);
this.portsOpen[num] = 0;
}
if (flag)
{
this.log(ipFrom + " Closed Port#" + portNum);
}
if (!this.silent)
{
this.sendNetworkMessage(string.Concat(new object[]
{
"cPortClose ",
this.ip,
" ",
ipFrom,
" ",
portNum
}));
}
}
// Token: 0x060005C1 RID: 1473 RVA: 0x00059CBC File Offset: 0x00057EBC
public bool isPortOpen(int portNum)
{
for (int i = 0; i < this.ports.Count; i++)
{
if (this.ports[i] == portNum)
{
return this.portsOpen[i] > 0;
}
}
return false;
}
// Token: 0x060005C2 RID: 1474 RVA: 0x00059D14 File Offset: 0x00057F14
public void openCDTray(string ipFrom)
{
if (this.os.thisComputer.ip.Equals(this.ip))
{
Programs.cdDrive(true);
}
this.sendNetworkMessage("cCDDrive " + this.ip + " open");
}
// Token: 0x060005C3 RID: 1475 RVA: 0x00059D6C File Offset: 0x00057F6C
public void closeCDTray(string ipFrom)
{
if (this.os.thisComputer.ip.Equals(this.ip))
{
Programs.cdDrive(false);
}
this.sendNetworkMessage("cCDDrive " + this.ip + " close");
}
// Token: 0x060005C4 RID: 1476 RVA: 0x00059DC4 File Offset: 0x00057FC4
public void forkBombClients(string ipFrom)
{
this.sendNetworkMessage("cFBClients " + this.ip + " " + ipFrom);
if (!this.os.multiplayer)
{
for (int i = 0; i < this.os.ActiveHackers.Count; i++)
{
if (this.os.ActiveHackers[i].Value == this.ip)
{
string key = this.os.ActiveHackers[i].Key;
Computer computer = Programs.getComputer(this.os, key);
computer.crash(this.ip);
}
}
}
}
// Token: 0x060005C5 RID: 1477 RVA: 0x00059E88 File Offset: 0x00058088
public virtual int login(string username, string password, byte type = 1)
{
int result;
if (username.ToLower().Equals("admin") && password.Equals(this.adminPass))
{
this.giveAdmin(this.os.thisComputer.ip);
result = 1;
}
else
{
for (int i = 0; i < this.users.Count; i++)
{
if (this.users[i].name.Equals(username) && this.users[i].pass.Equals(password) && (this.users[i].type == type || type == 1))
{
this.currentUser = this.users[i];
return 2;
}
}
result = 0;
}
return result;
}
// Token: 0x060005C6 RID: 1478 RVA: 0x00059F74 File Offset: 0x00058174
public int GetDisplayPortNumberFromCodePort(int codePort)
{
int result;
if (this.PortRemapping == null || !this.PortRemapping.ContainsKey(codePort))
{
result = codePort;
}
else
{
result = this.PortRemapping[codePort];
}
return result;
}
// Token: 0x060005C7 RID: 1479 RVA: 0x00059FB4 File Offset: 0x000581B4
public int GetCodePortNumberFromDisplayPort(int displayPort)
{
int result;
if (this.PortRemapping == null)
{
result = displayPort;
}
else
{
foreach (KeyValuePair<int, int> keyValuePair in this.PortRemapping)
{
if (keyValuePair.Value == displayPort)
{
return keyValuePair.Key;
}
}
result = displayPort;
}
return result;
}
// Token: 0x060005C8 RID: 1480 RVA: 0x0005A040 File Offset: 0x00058240
public void setAdminPassword(string newPass)
{
this.adminPass = newPass;
for (int i = 0; i < this.users.Count; i++)
{