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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
using ShiftOS.Objects;
using static ShiftOS.Objects.ShiftFS.Utils;
namespace ShiftOS.Server
{
public static class RandomUserGenerator
{
const string USERPREFIXES = "culled;purged;anon;fatal;unaccounted;netban;killed;old";
const string SYSNAMES = "unknown;error;dead;system;mud";
const string PASSCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_";
public static void StartThread()
{
var t = new Thread(() =>
{
var rnd = new Random();
while (Program.server.IsOnline)
{
if (!Directory.Exists("deadsaves"))
{
Directory.CreateDirectory("deadsaves");
}
var sve = new Save();
int passLength = 0;
int securityGrade = rnd.Next(1, 5);
switch (securityGrade)
{
default:
passLength = 4;
break;
case 2:
passLength = 6;
break;
case 3:
passLength = 10;
break;
case 4:
passLength = 15;
break;
}
string pass = "";
char lastChar = '\0';
for (int i = 0; i < passLength; i++)
{
char c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
while(c == lastChar)
{
c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
}
pass += c;
lastChar = c; //this ensures no repeated sequences.
}
sve.Password = pass;
int id_length = rnd.Next(3, 10);
string id = "";
lastChar = '\0';
for (int i = 0; i < id_length; i++)
{
char c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
while (c == lastChar)
{
c = PASSCHARS[rnd.Next(0, PASSCHARS.Length)];
}
id += c;
lastChar = c; //this ensures no repeated sequences.
}
string[] names = USERPREFIXES.Split(';');
string name = names[rnd.Next(0, names.Length)];
sve.Username = $"{id}_{name}";
names = SYSNAMES.Split(';');
name = names[rnd.Next(0, names.Length)];
sve.SystemName = name;
//Codepoint generation.
int startCP = 0;
int maxAmt = 0;
switch (securityGrade)
{
default:
startCP = 1000;
maxAmt = 12500;
break;
case 2:
startCP = 25000;
maxAmt = 50000;
break;
case 3:
startCP = 75000;
maxAmt = 150000;
break;
case 4:
startCP = 500000;
maxAmt = 1500000;
break;
}
sve.Codepoints = rnd.Next(startCP, maxAmt);
//FS treasure generation.
/*
//create a ramdisk dir
var dir = new ShiftOS.Objects.ShiftFS.Directory();
//name the directory after the user
dir.Name = sve.Username;
dir.permissions = Objects.ShiftFS.Permissions.All;
//json the object and mount
string json = Newtonsoft.Json.JsonConvert.SerializeObject(dir);
//mount it to the MUD
ShiftOS.Objects.ShiftFS.Utils.Mount(json);
//get the mount id
int mountid = ShiftOS.Objects.ShiftFS.Utils.Mounts.Count - 1;
bool leakShiftnetDataRandomly = (rnd.Next(0, 10) > 5);
//create home directory
CreateDirectory($"{mountid}:/home");
//create downloads directory
CreateDirectory($"{mountid}:/home/downloads");
//if we're leaking shiftnet data...
CreateDirectory($"{mountid}:/home/documents");
//alright, let's leak some shop items.
foreach(var shop in Newtonsoft.Json.JsonConvert.DeserializeObject<Shop[]>(File.ReadAllText("shops.json")))
{
if(shop != null)
{
try
{
foreach(var item in shop.Items)
{
if(rnd.Next(0,10) > 5)
{
if (sve.Codepoints >= item.Cost)
{
//deduct item's codepoints.
sve.Codepoints -= item.Cost;
//create a new file in user's downloads folder...with the item's name and binary contents inside.
WriteAllBytes($"{mountid}:/home/downloads/{item.Name}.{GetFileExt(item.FileType)}", item.MUDFile);
}
}
}
}
catch { }
}
}
//shiftnetData<ntfsFile, sfsFile>
Dictionary<string, string> shiftnetData = new Dictionary<string, string>();
if(leakShiftnetDataRandomly == true)
{
//And maybe let's leak some shiftnet sites.
LeakDirectories($"{mountid}:/home/documents", out shiftnetData);
//Now start saving the directories.
foreach(var kv in shiftnetData)
{
if(!DirectoryExists(kv.Value))
CreateDirectory(kv.Value);
foreach(var file in Directory.GetFiles(kv.Key))
{
WriteAllBytes(kv.Value, File.ReadAllBytes(file));
}
}
}*/
//save the save file to disk.
File.WriteAllText("deadsaves/" + sve.Username + ".save", Newtonsoft.Json.JsonConvert.SerializeObject(sve, Newtonsoft.Json.Formatting.Indented));
//We don't care about the encryption algorithm because these saves can't be logged into as regular users.
/*
//Now we export the mount.
string exportedMount = ExportMount(mountid);
//And save it to disk.
File.WriteAllText("deadsaves/" + sve.Username + ".mfs", exportedMount);
*/
Thread.Sleep((60 * 60) * 1000); //approx. 1 hour.
}
});
t.IsBackground = true;
t.Start();
}
public static void LeakDirectories(string output, out Dictionary<string,string> targets)
{
var rnd = new Random();
List<string> dirs = new List<string>();
foreach(var pth in getDirectories("shiftnet"))
{
if(rnd.Next(0,10) > 5)
{
dirs.Add(pth);
}
}
targets = new Dictionary<string, string>();
foreach(var dir in dirs)
{
if (!string.IsNullOrWhiteSpace(dir))
{
string sDir = dir.Replace("\\", "/");
if (sDir.Contains("shiftnet"))
{
while (!sDir.StartsWith("shiftnet"))
{
sDir = sDir.Remove(0, 1);
}
targets.Add(dir, output + "/" + sDir);
}
}
}
}
private static List<string> getDirectories(string path)
{
List<string> paths = new List<string>();
foreach(var pth in Directory.GetDirectories(path))
{
paths.AddRange(getDirectories(pth).ToArray());
}
paths.Add(path);
return paths;
}
public static string GetFileExt(int fType)
{
switch((FileType)fType)
{
default:
return "bin";
case FileType.Executable:
return "sft";
case FileType.Filesystem:
return "mfs";
case FileType.Image:
return "pic";
case FileType.JSON:
return "json";
case FileType.Lua:
return "lua";
case FileType.Skin:
return "skn";
case FileType.TextFile:
return ".txt";
}
}
public enum FileType
{
TextFile,
Directory,
Mount,
UpOne,
Image,
Skin,
JSON,
Executable,
Lua,
Python,
Filesystem,
Unknown
}
}
}
|