-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.lua
More file actions
417 lines (406 loc) · 13.3 KB
/
installer.lua
File metadata and controls
417 lines (406 loc) · 13.3 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
-- Unfinished! OS Being created on GitHub at https://github.com/xXDMOGXx/MOGOS
local setup = 1
local length = 5
local name = tostring(math.random(25565))
for i=1, length-#name do
name = "0"..name
end
local passPath = "/tempPass"
local cert = ""
local preInstalls = {}
function clear()
term.clear()
term.setCursorPos(1,1)
end
function tableConcat(t1,t2)
for i=1,#t2 do
t1[#t1+1] = t2[i]
end
return t1
end
function startInstall()
clear()
print("Downloading System Files")
if (setup == 1) then
shell.run("pastebin get MP1fCGU8 MOGOS/System/APIs/Settings.lua")
shell.run("pastebin get ezy3eZ11 MOGOS/System/APIs/Display.lua")
shell.run("pastebin get skSLv9sj MOGOS/System/APIs/CryptoNet.lua")
shell.run("pastebin get sM4w8V6Z MOGOS/System/APIs/Event.lua")
shell.run("pastebin get 41qPd7bg MOGOS/System/Programs/Framework/frameworkMain.prg")
--shell.run("pastebin get pJuEeR2E MOGOS/System/Programs/Framework/Assets/Images/bar.pic")
--shell.run("pastebin get pJuEeR2E MOGOS/System/Programs/Framework/Assets/Images/up.pic")
--shell.run("pastebin get pJuEeR2E MOGOS/System/Programs/Framework/Assets/Images/down.pic")
shell.run("pastebin get 5JUZYdyG MOGOS/System/Programs/Paint.app/paintMain.prg")
shell.run("pastebin get Xre5RUKC MOGOS/System/Programs/Paint.app/info.set")
shell.run("pastebin get qizK0n4z MOGOS/System/Programs/Paint.app/Assets/Maps/main.map")
shell.run("pastebin get kS5cvcMb MOGOS/System/Programs/Paint.app/Assets/Images/icon.pic")
shell.run("pastebin get 5D02sdht MOGOS/System/Programs/Paint.app/Assets/Images/selector.pic")
shell.run("pastebin get eniq0ZmU MOGOS/System/Programs/Paint.app/Assets/Images/eraser.pic")
shell.run("pastebin get 6yFxq7rY MOGOS/System/Programs/Paint.app/Assets/Images/picker.pic")
fs.makeDir("MOGOS/User/"..name.."/Storage/Images")
if (fs.exists(passPath)) then
fs.copy(passPath, "MOGOS/User/"..name.."/Settings/.password")
end
end
os.unloadAPI("/CryptoNet.lua")
for i=1, #preInstalls do
fs.delete(preInstalls[i])
end
clear()
print("MOGOS Download Complete. Restart Now?")
print("")
print("1: Yes")
print("2: No")
print("")
term.write("> ")
local answer = read()
if (answer == "1") then
print("Restarting...")
os.reboot()
elseif (answer == "2") then
clear()
print("Not Restarting. OS will run on next boot")
os.sleep(3)
clear()
else
clear()
print("Invalid Answer")
print("Not Restarting. OS will run on next boot")
os.sleep(3)
clear()
end
end
local function checkCancel(string)
string = string or "cancel"
if (string.lower(string) == "cancel") then
print("Canceling Install...")
os.unloadAPI("/CryptoNet.lua")
for i=1, #preInstalls do
fs.delete(preInstalls[i])
end
os.sleep(1)
os.reboot()
end
end
local function preCheck()
if (fs.exists("MOGOS")) then
clear()
print("Previous Install Detected!")
print("Reinstalling will delete all current MOGOS files on the computer!")
print("")
print("1: Continue")
print("2: Cancel")
print("")
term.write("> ")
local continue = read()
if (continue == "1") then
print("Type YES to confirm")
print("")
term.write("> ")
local yes = read()
if (string.lower(yes) == "yes") then
print("Deleting Old Files...")
fs.delete("MOGOS")
return true
else
print("Invalid Answer")
checkCancel()
end
elseif (continue == "2") then
checkCancel()
else
print("Invalid Answer")
checkCancel()
end
else
return true
end
end
local function installCert()
local subAnswer
print("Do you have a certificate to install? (From a trusted source!)")
print("")
print("1: Yes")
print("2: No")
print("")
term.write("> ")
local cert = read()
checkCancel(cert)
clear()
if (cert == "1") then
print("Please insert a signed certificate in a floppy disk on disk/, then type OK")
print("")
term.write("> ")
local OK = read()
checkCancel(OK)
clear()
if (string.lower(OK) == "ok") then
print("Copying...")
print("Copied!")
subAnswer = "Loaded"
os.sleep(1)
end
elseif (cert == "2") then
subAnswer = "None"
else
print("Invalid Answer")
checkCancel()
end
clear()
return subAnswer
end
local function createPassword(name, forced)
local override = forced or false
local subAnswerList = {}
local set
if (override) then
set = "1"
else
print("")
print("1: Yes")
print("2: No")
print("")
term.write("> ")
set = read()
checkCancel(set)
end
clear()
if (set == "1") then
clear()
table.insert(subAnswerList, "Password Storage: Hash, ID Locked")
print("Please enter a password (Whatever you want)")
print("")
term.write("> ")
local password = read()
table.insert(subAnswerList, "Password: "..password)
local file = fs.open(passPath,"w")
print("Hashing (May take a while) ...")
file.write(textutils.serialize(CryptoNet.sha256.pbkdf2(password, name..os.getComputerID(), 10)))
file.close()
table.insert(preInstalls, passPath)
elseif (set == "2") then
table.insert(subAnswerList, "Password: None")
else
print("Invalid Answer")
checkCancel()
end
clear()
return subAnswerList
end
local function createUsername()
print("What name would you like the initial user to be called? (Whatever you want)")
print("")
term.write("> ")
local name = read()
clear()
return name
end
if (preCheck()) then
shell.run("pastebin get skSLv9sj /CryptoNet.lua")
os.loadAPI("/CryptoNet.lua")
table.insert(preInstalls, "/CryptoNet.lua")
clear()
clear()
local answerList = {}
print("Welcome to the MOGOS installer!")
print("Type Cancel at any option to end installation.")
print("")
print("Do you want to enter the advanced setup?")
print("")
print("1: Yes")
print("2: No")
print("")
term.write("> ")
local advanced = read()
checkCancel(advanced)
clear()
if (advanced == "1") then
table.insert(answerList, "Setup Mode: Advanced")
print("What type of device are you setting up?")
print("")
print("1: General PC")
print("2: Standalone Program")
print("3: Server")
print("4: Certificate Authority")
print("")
term.write("> ")
local device = read()
checkCancel(device)
clear()
if (device == "1") then
setup = 1
table.insert(answerList, "Device: General PC")
name = createUsername()
table.insert(answerList, "User's Name: "..name)
print("Would you like to set a password? (Recommended)")
tableConcat(answerList, createPassword(name))
table.insert(answerList, "Certificate: "..installCert())
elseif (device == "2") then
setup = 2
table.insert(answerList, "Device: Standalone Program")
clear()
print("Will login be enabled?")
print("")
print("1: Yes")
print("2: No")
print("")
term.write("> ")
local login = read()
checkCancel(login)
clear()
if (login == "1") then
table.insert(answerList, "Login: Enabled")
name = createUsername()
table.insert(answerList, "User's Name: "..name)
print("Would you like to set a password?")
tableConcat(answerList, createPassword(name))
elseif (login == "2") then
table.insert(answerList, "Login: Disabled")
else
print("Invalid Answer")
checkCancel()
end
clear()
print("How will the program be stored?")
print("")
print("1: Stay On Floppy Disk")
print("2: Copied To Computer")
print("")
term.write("> ")
local stored = read()
checkCancel(stored)
clear()
if (stored == "1") then
table.insert(answerList, "Storage: Stay On Floppy Disk")
print("Whenever computer starts up, if a valid .app program is in a floppy disk on disk/, it will be loaded")
elseif (stored == "2") then
table.insert(answerList, "Storage: Copied To Computer")
print("Please insert a valid .app program in a floppy disk on disk/, then type OK")
print("")
term.write("> ")
local OK = read()
checkCancel(OK)
clear()
if (string.lower(OK) == "ok") then
print("Checking Validity...")
print("Copied!")
table.insert(answerList, "Program: Loaded")
os.sleep(1)
else
print("Invalid Answer")
checkCancel()
end
else
print("Invalid Answer")
checkCancel()
end
clear()
table.insert(answerList, "Certificate: "..installCert())
elseif (device == "3") then
setup = 3
table.insert(answerList, "Device: Server")
print("What is the server's public name? (Whatever you want)")
print("")
term.write("> ")
name = read()
table.insert(answerList, "Server Name: "..name)
clear()
print("Would you like to set a password? (Highly Recommended!)")
tableConcat(answerList, createPassword(name))
print("Do you want to create a certificate to be signed?")
print("")
print("1: Yes")
print("2: No")
print("")
term.write("> ")
local cert = read()
checkCancel(cert)
clear()
if (cert == "1") then
print("Please insert a floppy disk on disk/, then type OK")
print("")
term.write("> ")
local OK = read()
checkCancel(OK)
clear()
if (string.lower(OK) == "ok") then
print("Creating unsigned certificate...")
print("Created!")
print("Give this floppy to a trusted certificate authority for approval")
os.sleep(5)
table.insert(answerList, "Certificate: Created")
end
elseif (cert == "2") then
print("Certificate can be created later in settings")
os.sleep(3)
table.insert(answerList, "Certificate: Not Created")
else
print("Invalid Answer")
checkCancel()
end
elseif (device == "4") then
setup = 4
table.insert(answerList, "Device: Certificate Authority")
print("What is the authority's public name? (Whatever you want)")
print("")
term.write("> ")
name = read()
table.insert(answerList, "Authority Name: "..name)
clear()
print("Would you like to set a password? (Highly Recommended!)")
tableConcat(answerList, createPassword(name))
print("Never sign untrusted certificates!")
print("Creating signiture...")
os.sleep(3)
print("Created!")
os.sleep(3)
else
print("Invalid Answer")
checkCancel()
end
elseif (advanced == "2") then
setup = 1
table.insert(answerList, "Setup Mode: Simple")
print("What name would you like to be called? (Whatever you want)")
print("")
term.write("> ")
name = read()
table.insert(answerList, "Name: "..name)
clear()
print("Would you like to set a password? (Recommended)")
print("")
print("1: Yes")
print("2: No")
print("")
term.write("> ")
local set = read()
checkCancel(set)
clear()
if (set == "1") then
tableConcat(answerList, createPassword(name, "3"))
elseif (set ~= "2") then
print("Invalid Answer")
checkCancel()
end
else
print("Invalid Answer")
checkCancel()
end
clear()
for i = 1, #answerList do
print(answerList[i])
end
print("")
print("Is this correct?")
print("Type YES to confirm")
print("")
term.write("> ")
local yes = read()
if (string.lower(yes) == "yes") then
print("Beginning Install...")
startInstall()
else
print("Invalid Answer")
checkCancel()
end
end