-
Notifications
You must be signed in to change notification settings - Fork 0
/
Computer.cs
202 lines (164 loc) · 5.5 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
using System;
using System.Collections.Generic;
namespace hacknet_viewer {
public class Computer {
public string id;
public string name;
public string ip;
public string icon;
public string type;
public int security;
public bool allowsDefaultBootModule;
public List<File> files;
public List<String> links; // Nodes that are connected
// Security
public int portsForCrack; // Above 100 causes an inviolability error
public int proxyTime; // Set to -1 to remove
public List<int> ports; // Valid ports: 21, 22, 25, 80, 1433, 104, 6881, 443, 192, 554
// Firewall
public int firewallLevel; // Set to -1 to remove
public string firewallSolution;
public double firewallAdditionalTime;
// Trace
public int traceTimer; // Set to -1 to remove]
public bool passiveTracker;
// Admin
public string adminPass;
public string adminType;
public bool adminResetPass;
public bool adminIsSuper;
// Users
public List<Account> accounts;
// Port remapping
public Dictionary<int, int> portRemapping;
// Positioning
public Position position;
// eOSDevice
public EOSDevice eOSDevice;
// Daemons
/*
* Booleans that set daemons for the node.
* These are simply set by having the daemon tag
* in the XML file for the node.
*/
public List<Daemon> daemons;
public Computer(Memory memoryDump) {
this.MemoryDump = memoryDump;
}
public Memory MemoryDump { get; set; }
public Computer(string id, string name, string ip, string icon,
int security, string type, bool allowsDefaultBootModule) {
this.id = id;
this.name = name;
this.ip = ip;
this.icon = icon;
this.security = security;
this.type = type;
this.allowsDefaultBootModule = allowsDefaultBootModule;
this.portsForCrack = 4;
this.proxyTime = -1;
this.files = new List<File>();
this.links = new List<String>();
this.ports = new List<int> { 21, 22, 25, 80, 1433, 104, 6881, 443, 192, 554 };
// Firewall
this.firewallLevel = -1; // Cannot be shorter than the solution! (unless -1)
this.firewallSolution = "";
this.firewallAdditionalTime = 1.0;
// Trace
this.traceTimer = -1;
this.passiveTracker = false;
// Admin
this.accounts = new List<Account> {
new Account { name = "admin", password = "", type = "admin" }
};
this.adminType = "progress";
this.adminResetPass = false;
this.adminIsSuper = false;
// Port remapping
this.portRemapping = new Dictionary<int, int>();
// Position
this.position.target = "";
this.position.pos = 0;
this.position.total = 0;
this.position.extraDistance = 0.0;
this.position.force = false;
// eOSDevice
this.eOSDevice = null;
// Daemons
this.daemons = new List<Daemon>();
this.MemoryDump = new Memory();
}
public override string ToString() {
string fileString = "";
foreach(File file in files)
fileString += file + "\n";
string linkString = "";
foreach(string link in links)
linkString += link + "\n";
string portString = "";
foreach(int port in this.ports)
portString += port + ", ";
string accountString = "";
foreach(Account acc in accounts) {
if(acc.name != "admin")
accountString += acc.name + ": " + acc.password + " type: " + acc.type + "\n";
}
string portRemappingString = "";
foreach(KeyValuePair<int, int> entry in portRemapping) {
portRemappingString += entry.Key + ": " + entry.Value + ", ";
}
string positionString = "target: " + position.target + "\npos: " + position.pos +
"\ntotal: " + position.total +
"\nextra distance: " + position.extraDistance +
"\nforce: " + position.force;
string daemonString = "";
foreach(Daemon daemon in daemons) {
daemonString += daemon + "\n";
}
return "<" + id + " (computer)\n" +
"name: " + name + "\n" +
"ip: " + ip + "\n" +
"icon: " + icon +
"\ntype: " + type +
"\nsecurity: " + security +
"\nallowsDefaultBootModule: " + allowsDefaultBootModule +
"\nfiles: " + fileString.TrimEnd('\n') +
"\nlinks: " + linkString.TrimEnd('\n') +
"\nports: " + portString.Trim().TrimEnd(',') +
"\nports for crack: " + portsForCrack + (portsForCrack > 100 ? " (INVIOLABILITY)" : "") +
"\nport remap: " + portRemappingString.Trim().TrimEnd(',') +
"\nproxy time: " + proxyTime + (proxyTime == -1 ? " (disabled)" : "") +
"\nfirewall level: " + firewallLevel + (firewallLevel == -1 ? " (disabled)" : "") +
"\nfirewall solution: " + firewallSolution +
"\nfirewall additional time: " + firewallAdditionalTime +
"\ntrace timer: " + traceTimer + (traceTimer == -1 ? " (disabled)" : "") +
"\npassive trace: " + passiveTracker +
"\nadmin password: " + adminPass +
"\nadmin type: " + adminType +
"\nadmin reset password: " + adminResetPass +
"\nadmin is super: " + adminIsSuper +
"\naccounts: " + accountString.TrimEnd('\n') +
"\nposition: " + positionString +
"\neOS Device: " + (eOSDevice == null ? "none" : eOSDevice.ToString()) +
"\ndaemons: " + daemonString.Trim() +
"\nmemory: " + MemoryDump +
">";
}
}
public struct Account {
public string name;
public string password;
public string type;
}
public struct Position {
public string target;
public int pos;
public int total;
public double extraDistance;
public bool force;
}
public struct Mail {
public string username;
public string pass;
}
}