SuicidalSTDz

EnderOS Developemental

Mar 10th, 2013
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.86 KB | None | 0 0
  1. --Coded by SuicidalSTDz
  2. --License:
  3. --The code of "EnderOS" in any form is intellectual
  4. --property of SuicidalSTDz. You may not reproduce,
  5. --redistribute, or modify it in any way!
  6.  
  7. --This OS stores User information in a hashed form. Making "hackers" tremble in fear >:) Not really...
  8. --The hash that EnderOS uses is Sha-256 and makes storage safer :)
  9.  
  10. --If you find any bugs(I know there are a few) please report them on the CC Forums on the EnderOS thread!
  11. --Thank you for using EnderOS and enjoy!
  12.  
  13. --Games
  14. --EnderOS includes SkullPong by Skullblade, AdventureCraft by Mikee251, and FireWolf by GravityScore
  15.  
  16. --11
  17. local nonEditableFiles = {
  18. "/.EnderOS/.userInfo",
  19. "/.EnderOS/.passInfo",
  20. "/.EnderOS/.userHint",
  21. "/.EnderOS/.firewolf",
  22. "/.EnderOS/.edit",
  23. ".EnderOS/.userInfo",
  24. ".EnderOS/.passInfo",
  25. ".EnderOS/.userHint",
  26. ".EnderOS/.firewolf",
  27. ".EnderOS/.edit",
  28. "startup"
  29. }
  30.  
  31. local version = "v3.0"
  32. local saltHash = "T01hFg62zY"
  33. local adventureCraft = ""
  34. local firewolf = "A7wGH3ty"
  35. local edit = ""
  36. local skullpong = ""
  37. local userWrite = io.open("/.EnderOS/.userInfo","w")
  38. local userRead = io.open("/.EnderOS/.userInfo","r")
  39. local passWrite = io.open("/.EnderOS/.passInfo","w")
  40. local passRead = io.open("/.EnderOS/.passInfo","r")
  41. local hintWrite = io.open("/.EnderOS/.userHint","w")
  42. local hintRead = io.open("/.EnderOS/.userHint","r")
  43.  
  44. local function reset() --FINISHED
  45. term.clear()
  46. term.setCursorPos(1,1)
  47. end
  48.  
  49. local function sha256(msg) --FINISHED
  50. local function band(int1, int2, int3, ...)
  51. local ret =
  52. ((int1%0x00000002>=0x00000001 and int2%0x00000002>=0x00000001 and 0x00000001) or 0)+
  53. ((int1%0x00000004>=0x00000002 and int2%0x00000004>=0x00000002 and 0x00000002) or 0)+
  54. ((int1%0x00000008>=0x00000004 and int2%0x00000008>=0x00000004 and 0x00000004) or 0)+
  55. ((int1%0x00000010>=0x00000008 and int2%0x00000010>=0x00000008 and 0x00000008) or 0)+
  56. ((int1%0x00000020>=0x00000010 and int2%0x00000020>=0x00000010 and 0x00000010) or 0)+
  57. ((int1%0x00000040>=0x00000020 and int2%0x00000040>=0x00000020 and 0x00000020) or 0)+
  58. ((int1%0x00000080>=0x00000040 and int2%0x00000080>=0x00000040 and 0x00000040) or 0)+
  59. ((int1%0x00000100>=0x00000080 and int2%0x00000100>=0x00000080 and 0x00000080) or 0)+
  60. ((int1%0x00000200>=0x00000100 and int2%0x00000200>=0x00000100 and 0x00000100) or 0)+
  61. ((int1%0x00000400>=0x00000200 and int2%0x00000400>=0x00000200 and 0x00000200) or 0)+
  62. ((int1%0x00000800>=0x00000400 and int2%0x00000800>=0x00000400 and 0x00000400) or 0)+
  63. ((int1%0x00001000>=0x00000800 and int2%0x00001000>=0x00000800 and 0x00000800) or 0)+
  64. ((int1%0x00002000>=0x00001000 and int2%0x00002000>=0x00001000 and 0x00001000) or 0)+
  65. ((int1%0x00004000>=0x00002000 and int2%0x00004000>=0x00002000 and 0x00002000) or 0)+
  66. ((int1%0x00008000>=0x00004000 and int2%0x00008000>=0x00004000 and 0x00004000) or 0)+
  67. ((int1%0x00010000>=0x00008000 and int2%0x00010000>=0x00008000 and 0x00008000) or 0)+
  68. ((int1%0x00020000>=0x00010000 and int2%0x00020000>=0x00010000 and 0x00010000) or 0)+
  69. ((int1%0x00040000>=0x00020000 and int2%0x00040000>=0x00020000 and 0x00020000) or 0)+
  70. ((int1%0x00080000>=0x00040000 and int2%0x00080000>=0x00040000 and 0x00040000) or 0)+
  71. ((int1%0x00100000>=0x00080000 and int2%0x00100000>=0x00080000 and 0x00080000) or 0)+
  72. ((int1%0x00200000>=0x00100000 and int2%0x00200000>=0x00100000 and 0x00100000) or 0)+
  73. ((int1%0x00400000>=0x00200000 and int2%0x00400000>=0x00200000 and 0x00200000) or 0)+
  74. ((int1%0x00800000>=0x00400000 and int2%0x00800000>=0x00400000 and 0x00400000) or 0)+
  75. ((int1%0x01000000>=0x00800000 and int2%0x01000000>=0x00800000 and 0x00800000) or 0)+
  76. ((int1%0x02000000>=0x01000000 and int2%0x02000000>=0x01000000 and 0x01000000) or 0)+
  77. ((int1%0x04000000>=0x02000000 and int2%0x04000000>=0x02000000 and 0x02000000) or 0)+
  78. ((int1%0x08000000>=0x04000000 and int2%0x08000000>=0x04000000 and 0x04000000) or 0)+
  79. ((int1%0x10000000>=0x08000000 and int2%0x10000000>=0x08000000 and 0x08000000) or 0)+
  80. ((int1%0x20000000>=0x10000000 and int2%0x20000000>=0x10000000 and 0x10000000) or 0)+
  81. ((int1%0x40000000>=0x20000000 and int2%0x40000000>=0x20000000 and 0x20000000) or 0)+
  82. ((int1%0x80000000>=0x40000000 and int2%0x80000000>=0x40000000 and 0x40000000) or 0)+
  83. ((int1>=0x80000000 and int2>=0x80000000 and 0x80000000) or 0)
  84.  
  85. return (int3 and band(ret, int3, ...)) or ret
  86. end
  87.  
  88. local function bxor(int1, int2, int3, ...)
  89. local ret =
  90. ((int1%0x00000002>=0x00000001 ~= (int2%0x00000002>=0x00000001) and 0x00000001) or 0)+
  91. ((int1%0x00000004>=0x00000002 ~= (int2%0x00000004>=0x00000002) and 0x00000002) or 0)+
  92. ((int1%0x00000008>=0x00000004 ~= (int2%0x00000008>=0x00000004) and 0x00000004) or 0)+
  93. ((int1%0x00000010>=0x00000008 ~= (int2%0x00000010>=0x00000008) and 0x00000008) or 0)+
  94. ((int1%0x00000020>=0x00000010 ~= (int2%0x00000020>=0x00000010) and 0x00000010) or 0)+
  95. ((int1%0x00000040>=0x00000020 ~= (int2%0x00000040>=0x00000020) and 0x00000020) or 0)+
  96. ((int1%0x00000080>=0x00000040 ~= (int2%0x00000080>=0x00000040) and 0x00000040) or 0)+
  97. ((int1%0x00000100>=0x00000080 ~= (int2%0x00000100>=0x00000080) and 0x00000080) or 0)+
  98. ((int1%0x00000200>=0x00000100 ~= (int2%0x00000200>=0x00000100) and 0x00000100) or 0)+
  99. ((int1%0x00000400>=0x00000200 ~= (int2%0x00000400>=0x00000200) and 0x00000200) or 0)+
  100. ((int1%0x00000800>=0x00000400 ~= (int2%0x00000800>=0x00000400) and 0x00000400) or 0)+
  101. ((int1%0x00001000>=0x00000800 ~= (int2%0x00001000>=0x00000800) and 0x00000800) or 0)+
  102. ((int1%0x00002000>=0x00001000 ~= (int2%0x00002000>=0x00001000) and 0x00001000) or 0)+
  103. ((int1%0x00004000>=0x00002000 ~= (int2%0x00004000>=0x00002000) and 0x00002000) or 0)+
  104. ((int1%0x00008000>=0x00004000 ~= (int2%0x00008000>=0x00004000) and 0x00004000) or 0)+
  105. ((int1%0x00010000>=0x00008000 ~= (int2%0x00010000>=0x00008000) and 0x00008000) or 0)+
  106. ((int1%0x00020000>=0x00010000 ~= (int2%0x00020000>=0x00010000) and 0x00010000) or 0)+
  107. ((int1%0x00040000>=0x00020000 ~= (int2%0x00040000>=0x00020000) and 0x00020000) or 0)+
  108. ((int1%0x00080000>=0x00040000 ~= (int2%0x00080000>=0x00040000) and 0x00040000) or 0)+
  109. ((int1%0x00100000>=0x00080000 ~= (int2%0x00100000>=0x00080000) and 0x00080000) or 0)+
  110. ((int1%0x00200000>=0x00100000 ~= (int2%0x00200000>=0x00100000) and 0x00100000) or 0)+
  111. ((int1%0x00400000>=0x00200000 ~= (int2%0x00400000>=0x00200000) and 0x00200000) or 0)+
  112. ((int1%0x00800000>=0x00400000 ~= (int2%0x00800000>=0x00400000) and 0x00400000) or 0)+
  113. ((int1%0x01000000>=0x00800000 ~= (int2%0x01000000>=0x00800000) and 0x00800000) or 0)+
  114. ((int1%0x02000000>=0x01000000 ~= (int2%0x02000000>=0x01000000) and 0x01000000) or 0)+
  115. ((int1%0x04000000>=0x02000000 ~= (int2%0x04000000>=0x02000000) and 0x02000000) or 0)+
  116. ((int1%0x08000000>=0x04000000 ~= (int2%0x08000000>=0x04000000) and 0x04000000) or 0)+
  117. ((int1%0x10000000>=0x08000000 ~= (int2%0x10000000>=0x08000000) and 0x08000000) or 0)+
  118. ((int1%0x20000000>=0x10000000 ~= (int2%0x20000000>=0x10000000) and 0x10000000) or 0)+
  119. ((int1%0x40000000>=0x20000000 ~= (int2%0x40000000>=0x20000000) and 0x20000000) or 0)+
  120. ((int1%0x80000000>=0x40000000 ~= (int2%0x80000000>=0x40000000) and 0x40000000) or 0)+
  121. ((int1>=0x80000000 ~= (int2>=0x80000000) and 0x80000000) or 0)
  122.  
  123. return (int3 and bxor(ret, int3, ...)) or ret
  124. end
  125.  
  126. local function bnot(int)
  127. return 4294967295 - int
  128. end
  129.  
  130. local function rshift(int, by)
  131. local shifted = int / (2 ^ by)
  132. return shifted - shifted % 1
  133. end
  134.  
  135. local function rrotate(int, by)
  136. local shifted = int / (2 ^ by)
  137. local fraction = shifted % 1
  138. return (shifted - fraction) + fraction * (2 ^ 32)
  139. end
  140.  
  141. local k = {
  142. 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
  143. 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
  144. 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
  145. 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
  146. 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
  147. 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
  148. 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
  149. 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
  150. 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
  151. 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
  152. 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
  153. 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
  154. 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
  155. 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
  156. 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
  157. 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
  158. }
  159.  
  160. local function str2hexa(s)
  161. local h = string.gsub(s, ".", function(c)
  162. return string.format("%02x", string.byte(c))
  163. end)
  164. return h
  165. end
  166.  
  167. local function num2s(l, n)
  168. local s = ""
  169. for i = 1, n do
  170. local rem = l % 256
  171. s = string.char(rem) .. s
  172. l = (l - rem) / 256
  173. end
  174. return s
  175. end
  176.  
  177. local function s232num(s, i)
  178. local n = 0
  179. for i = i, i + 3 do n = n*256 + string.byte(s, i) end
  180. return n
  181. end
  182.  
  183. local function preproc(msg, len)
  184. local extra = 64 - ((len + 1 + 8) % 64)
  185. len = num2s(8 * len, 8)
  186. msg = msg .. "\128" .. string.rep("\0", extra) .. len
  187. return msg
  188. end
  189.  
  190. local function initH256(H)
  191. H[1] = 0x6a09e667
  192. H[2] = 0xbb67ae85
  193. H[3] = 0x3c6ef372
  194. H[4] = 0xa54ff53a
  195. H[5] = 0x510e527f
  196. H[6] = 0x9b05688c
  197. H[7] = 0x1f83d9ab
  198. H[8] = 0x5be0cd19
  199. return H
  200. end
  201.  
  202. local function digestblock(msg, i, H)
  203. local w = {}
  204. for j = 1, 16 do w[j] = s232num(msg, i + (j - 1) * 4) end
  205. for j = 17, 64 do
  206. local v = w[j - 15]
  207. local s0 = bxor(rrotate(v, 7), rrotate(v, 18), rshift(v, 3))
  208. v = w[j - 2]
  209. local s1 = bxor(rrotate(v, 17), rrotate(v, 19), rshift(v, 10))
  210. w[j] = w[j - 16] + s0 + w[j - 7] + s1
  211. end
  212.  
  213. local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6], H[7], H[8]
  214. for i = 1, 64 do
  215. local s0 = bxor(rrotate(a, 2), rrotate(a, 13), rrotate(a, 22))
  216. local maj = bxor(band(a, b), band(a, c), band(b, c))
  217. local t2 = s0 + maj
  218. local s1 = bxor(rrotate(e, 6), rrotate(e, 11), rrotate(e, 25))
  219. local ch = bxor (band(e, f), band(bnot(e), g))
  220. local t1 = h + s1 + ch + k[i] + w[i]
  221. h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2
  222. end
  223.  
  224. H[1] = band(H[1], a)
  225. H[2] = band(H[2], b)
  226. H[3] = band(H[3], c)
  227. H[4] = band(H[4], d)
  228. H[5] = band(H[5], e)
  229. H[6] = band(H[6], f)
  230. H[7] = band(H[7], g)
  231. H[8] = band(H[8], h)
  232. end
  233.  
  234. msg = preproc(msg, #msg)
  235. local H = initH256({})
  236. for i = 1, #msg, 64 do digestblock(msg, i, H) end
  237. return str2hexa(num2s(H[1], 4) .. num2s(H[2], 4) .. num2s(H[3], 4) .. num2s(H[4], 4) ..
  238. num2s(H[5], 4) .. num2s(H[6], 4) .. num2s(H[7], 4) .. num2s(H[8], 4))
  239. end
  240.  
  241. local function defineSettings() --FINISHED
  242.  
  243. --Check if EnderOS is installed
  244. if not fs.exists("/.EnderOS/.EnderOSisInstalled") then
  245. fs.makeDir("/.EnderOS/")
  246. end
  247.  
  248.  
  249.  
  250. local userRead = io.open("/.EnderOS/.userInfo","r")
  251. local userContents = userRead:read()
  252. userRead:close()
  253. if not fs.exists("/.EnderOS/.userInfo") or userContents == nil then
  254. repeat
  255. reset()
  256. term.setTextColor(colors.orange)
  257. print("Please enter your desired Username")
  258. term.setTextColor(colors.white)
  259. username = read()
  260. if #username <2 or username == "Username" or username == "username" then
  261. term.setTextColor(colors.red)
  262. print("The Endermen hack you in their sleep!")
  263. sleep(3)
  264. end
  265. sleep(0.1)
  266. until #username >2 and username ~= "Username" and username ~= "username"
  267. local hash = sha256(username..saltHash)
  268. local userWrite = io.open("/.EnderOS/.userInfo","w")
  269. userWrite:write(hash)
  270. userWrite:close()
  271. end
  272.  
  273. local passRead = io.open("/.EnderOS/.passInfo","r")
  274. local passContents = passRead:read()
  275. passRead:close()
  276. if not fs.exists("/.EnderOS/.passInfo") or passContents == nil then
  277. repeat
  278. reset()
  279. term.setTextColor(colors.orange)
  280. print("Please enter your desired Password")
  281. term.setTextColor(colors.white)
  282. password = read("*")
  283. if #password <2 or password == "Password" or password == "password" then
  284. term.setTextColor(colors.red)
  285. print("The Endermen hack you in their sleep!")
  286. sleep(2.5)
  287. end
  288. sleep(0.1)
  289. local userRead = io.open("/.EnderOS/.userInfo","r")
  290. userContents = userRead:read()
  291. userRead:close()
  292. if userContents == sha256(password..saltHash) then
  293. term.setTextColor(colors.red)
  294. io.write("The Endermen prevent you from using the same Username and Password")
  295. sleep(2.5)
  296. end
  297. until #password >2 and password ~= "Password" and writePass ~= "password" and password ~= userContents
  298. local hash = sha256(password..saltHash)
  299. local passWrite = io.open("/.EnderOS/.passInfo","w")
  300. passWrite:write(hash)
  301. passWrite:close()
  302. end
  303.  
  304. local hintRead = io.open("/.EnderOS/.userHint","r")
  305. local hintContents = hintRead:read()
  306. hintRead:close()
  307. if not fs.exists("/.EnderOS/.userHint") or hintContents == nil then
  308. repeat
  309. reset()
  310. term.setTextColor(colors.orange)
  311. print("Please enter your desired Password hint")
  312. term.setTextColor(colors.white)
  313. hint = read()
  314. if #hint >30 then
  315. term.setTextColor(colors.red)
  316. print("The Endermen revoke any hint greater than 30 characters!")
  317. sleep(2.5)
  318. return userInfo()
  319. end
  320. until #hint <=30
  321. local hintWrite = io.open("/.EnderOS/.userInfo","w")
  322. hintWrite:write(hint)
  323. hintWrite:close()
  324. end
  325.  
  326. --Create a file saying EnderOS is installed
  327. if userContents ~= nil and passContents ~= nil and hintContents ~= nil and not fs.exists("/.EnderOS/.EnderOSisInstalled") then
  328. local installC = io.open("/.EnderOS/.EnderOSisInstalled", "w")
  329. installC:write("If said user happens to stumble across this file, said user shall leave said file alone!")
  330. installC:close()
  331. end
  332. end
  333.  
  334. local function frame() --FINISHED
  335. print("+-------------------------------------------------+")
  336. for i = 1,17 do
  337. print("| |")
  338. end
  339. term.write("+-------------------------------------------------+")
  340. end
  341.  
  342. local function screen() --FINISHED
  343. reset()
  344. term.setTextColor(colors.lime)
  345. print("+-------------------------------------------------+")
  346. print("| |")
  347. print("| ")
  348. term.setCursorPos(19,3)
  349. term.setTextColor(colors.purple)
  350. write("EnderOS "..version)
  351. term.setTextColor(colors.lime)
  352. term.setCursorPos(31,3)
  353. print(" |")
  354. print("| |")
  355. print("| |")
  356. print("| |")
  357. print("| |")
  358. print("| ")
  359. term.setCursorPos(10,8)
  360. term.setTextColor(colors.orange)
  361. print("Username:")
  362. term.setCursorPos(19,8)
  363. print(" ")
  364. term.setCursorPos(50,8)
  365. term.setTextColor(colors.lime)
  366. print(" |")
  367. print("| |")
  368. print("| ")
  369. term.setTextColor(colors.orange)
  370. term.setCursorPos(10,10)
  371. print("Password:")
  372. term.setCursorPos(19,10)
  373. print(" ")
  374. term.setCursorPos(50,10)
  375. term.setTextColor(colors.lime)
  376. print(" |")
  377. print("| |")
  378. print("| |")
  379. print("| ")
  380. term.setCursorPos(8,13)
  381. term.setTextColor(colors.blue)
  382. print("Password Hint: ")
  383. term.setCursorPos(50,13)
  384. term.setTextColor(colors.lime)
  385. print(" |")
  386. print("| |")
  387. print("| |")
  388. print("| |")
  389. print("| |")
  390. print("| |")
  391. write("+-------------------------------------------------+")
  392. end
  393.  
  394. local function login() --FINISHED
  395. if fs.exists("/.EnderOS/.lock") then --Checks if the user locked his/her computer
  396. term.setBackgroundColor(colors.black)
  397. userRead = io.open("/.EnderOS/.userInfo","r")
  398. userContents = userRead:read()
  399. userRead:close()
  400. passRead = io.open("/.EnderOS/.passInfo","r")
  401. passContents = passRead:read()
  402. passRead:close()
  403. repeat
  404. reset()
  405. term.setTextColor(colors.lime)
  406. frame()
  407. term.setCursorPos(11,4)
  408. term.setTextColor(colors.purple)
  409. term.write("This computer has been locked!")
  410. term.setCursorPos(15,8)
  411. term.setTextColor(colors.orange)
  412. term.write("Username:")
  413. term.setCursorPos(15,10)
  414. term.write("Password:")
  415. term.setCursorPos(25,8)
  416. term.setTextColor(colors.white)
  417. username = read()
  418. hashUsername = sha256(username..saltHash)
  419. term.setCursorPos(25,10)
  420. password = read("*")
  421. hashPassword = sha256(password..saltHash)
  422. until hashUsername == userContents and hashPassword == passContents
  423. fs.delete("/.EnderOS/.lock")
  424. return startScreen()
  425. end
  426. userRead = io.open("/.EnderOS/.userInfo","r")
  427. userContents = userRead:read()
  428. userRead:close()
  429. passRead = io.open("/.EnderOS/.passInfo","r")
  430. passContents = passRead:read()
  431. passRead:close()
  432. hintRead = io.open("/.EnderOS/.userHint","r")
  433. hintContents = hintRead:read()
  434. hintRead:close()
  435. while true do
  436. repeat
  437. screen()
  438. term.setCursorPos(23,13)
  439. term.setTextColor(colors.lightGray)
  440. print(hintContents)
  441. term.setTextColor(colors.white)
  442. term.setCursorPos(20,8)
  443. term.setTextColor(colors.white)
  444. username = read()
  445. hashU = sha256(username..saltHash)
  446. term.setCursorPos(20,10)
  447. term.setTextColor(colors.white)
  448. password = read("*")
  449. hashP = sha256(password..saltHash)
  450. until hashU == userContents and hashP == passContents
  451. break
  452. end
  453. --startScreen()
  454. end
  455.  
  456. local function games() --FINISHED
  457. term.setTextColor(colors.purple)
  458. frame()
  459. term.setCursorPos(18,1)
  460. term.setTextColor(colors.lime)
  461. print("[EnderOS Games]")
  462. term.setCursorPos(3,3)
  463. print("{SkullPong} {AdventureCraft}")
  464. term.setCursorPos(3,1)
  465. term.setTextColor(colors.orange)
  466. term.write("[Back]")
  467. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  468. if button == 1 then
  469. if (xPos >=3 and xPos <=13 and yPos == 3) then
  470. shell.run("/.EnderOS/.skullpong")
  471. elseif (xPos >=3 and xPos <=9 and yPos == 1) then
  472. return startScreen()
  473. elseif (xPos >=17 and xPos <=32 and yPos == 3) then
  474. shell.run("/.EnderOS/.adventureCraft")
  475. else
  476. return games()
  477. end
  478. else
  479. return games()
  480. end
  481. end
  482.  
  483. local function settings() --FINISHED
  484. local function changeUsername()
  485. repeat
  486. reset()
  487. term.setTextColor(colors.orange)
  488. local passContents = passRead:read()
  489. passRead:close()
  490. print("Please enter your password: ")
  491. term.setTextColor(colors.white)
  492. local input = read("*")
  493. local hash = sha256(input..saltHash)
  494. if hash ~= passContents then
  495. term.setTextColor(colors.red)
  496. print("Invalid password")
  497. sleep(1.5)
  498. end
  499. until hash == passContents
  500. repeat
  501. reset()
  502. term.setTextColor(colors.orange)
  503. print("Enter new username: ")
  504. term.setTextColor(colors.white)
  505. username = read()
  506. if #writeUser<=2 then
  507. term.setTextColor(colors.red)
  508. print("The Endermen hack you in their sleep!")
  509. sleep(3)
  510. end
  511. until #username>2
  512. local hash = sha256(writeUser..saltHash)
  513. userWrite:write(hash)
  514. userWrite:close()
  515. term.setTextColor(colors.lightBlue)
  516. print("Your new username is "..username)
  517. sleep(2)
  518. end
  519. local function changePassword()
  520. repeat
  521. reset()
  522. term.setTextColor(colors.orange)
  523. local passContents = passRead:read()
  524. passRead:close()
  525. print("Please enter your password: ")
  526. term.setTextColor(colors.white)
  527. local input = read("*")
  528. local hash = sha256(input..saltHash)
  529. if hash ~= passContents then
  530. term.setTextColor(colors.red)
  531. print("Invalid password")
  532. sleep(1.5)
  533. end
  534. until hash == passContents
  535. sleep(0.1)
  536. repeat
  537. term.setTextColor(colors.orange)
  538. print("Enter new password: ")
  539. term.setTextColor(colors.white)
  540. local password = read("*")
  541. if #password <=2 then
  542. term.setTextColor(colors.red)
  543. print("The Endermen hack you in their sleep!")
  544. sleep(3)
  545. end
  546. until #password >2
  547. local hash = sha256(password..saltHash)
  548. passWrite:write(hash)
  549. pass:close()
  550. term.setTextColor(colors.lightBlue)
  551. print("Your new password is "..password)
  552. sleep(2)
  553. end
  554. local function changeHint()
  555. repeat
  556. reset()
  557. term.setTextColor(colors.orange)
  558. local passContents = passRead:read()
  559. passRead:close()
  560. print("Please enter your password: ")
  561. term.setTextColor(colors.white)
  562. local input = read("*")
  563. local hash = sha256(input..saltHash)
  564. if hash ~= passContents then
  565. term.setTextColor(colors.red)
  566. print("Invalid password")
  567. sleep(1.5)
  568. end
  569. until hash == passContents
  570. sleep(0.1)
  571. repeat
  572. term.setTextColor(colors.orange)
  573. print("Enter new hint: ")
  574. term.setTextColor(colors.white)
  575. hint = read()
  576. if #hint >30 then
  577. term.setTextColor(colors.red)
  578. print("This Hint exceeds the max hint length of 30!")
  579. sleep(3)
  580. end
  581. until #hint <=30
  582. if hint == nil then return error("EnderOS has crashed: attempt to get length of nil; hint returned nil?") end
  583. hintWrite:write(hint)
  584. hintWrite:close()
  585. term.setTextColor(colors.lightBlue)
  586. print("Your new hint is "..hint)
  587. sleep(2)
  588. end
  589. local function uninstall()
  590. reset()
  591. term.setCursorPos(15,7)
  592. term.setTextColor(colors.purple)
  593. print("Uninstalling EnderOS")
  594. term.setCursorPos(17,9)
  595. term.setTextColor(colors.lime)
  596. term.write("[XX----------]")
  597. sleep(1)
  598. fs.delete("/.EnderOS/.EnderOSisInstalled")
  599. term.setCursorPos(17,9)
  600. term.write("[XXXX--------]")
  601. sleep(1)
  602. fs.delete("/.EnderOS/.userInfo")
  603. term.setCursorPos(17,9)
  604. term.write("[XXXXXX------]")
  605. sleep(1)
  606. fs.delete("/.EnderOS/.userHint")
  607. term.setCursorPos(17,9)
  608. term.write("[XXXXXXXX----]")
  609. sleep(1)
  610. fs.delete("/.EnderOS/.passInfo")
  611. term.setCursorPos(17,9)
  612. term.write("[XXXXXXXXXX--]")
  613. sleep(1)
  614. fs.delete("/.EnderOS/.firewolf")
  615. fs.delete("/.EnderOS")
  616. fs.delete(".Firewolf_Data")
  617. fs.delete(".Installer")
  618. term.setCursorPos(17,9)
  619. term.write("[XXXXXXXXXXXX]")
  620. sleep(1)
  621. reset()
  622. term.setCursorPos(12,7)
  623. term.setTextColor(colors.purple)
  624. term.write("Until next time - The Endermen")
  625. sleep(3)
  626. if fs.exists("EnderOS") then fs.delete("EnderOS") end
  627. local ender = io.open("EnderOS","w")
  628. ender:write("The file the Endermen made is called .Endermen")
  629. ender:close()
  630. reset()
  631. term.setTextColor(colors.white)
  632. print("The Endermen seem to have made a file that contains EnderOS for later use")
  633. sleep(4)
  634. if fs.exists("/.Endermen") then fs.delete("/.Endermen") end
  635. fs.move("startup",".Endermen")
  636. os.reboot()
  637. end
  638. local function settingScreen()
  639. term.setTextColor(colors.purple)
  640. frame()
  641. term.setCursorPos(17,1)
  642. term.setTextColor(colors.lime)
  643. print("[EnderOS Settings]")
  644. term.setCursorPos(7,3)
  645. print("{Change Username} {Change Password}")
  646. term.setCursorPos(3,5)
  647. print("{Change Password Hint} {Uninstall EnderOS}")
  648. term.setCursorPos(3,1)
  649. term.setTextColor(colors.orange)
  650. term.write("[Back]")
  651. term.setTextColor(colors.white)
  652. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  653. if button == 1 then
  654. if (xPos >=7 and xPos <=23 and yPos == 3) then --CHANGE USERNAME
  655. return changeUsername()
  656. elseif (xPos >=27 and xPos <=43 and yPos == 3) then --Change Password
  657. return changePassword()
  658. elseif (xPos >=3 and xPos <=24 and yPos == 5) then --Change Hint
  659. return changeHint()
  660. elseif (xPos >=28 and xPos <=46 and yPos == 5) then --Uninstall
  661. return uninstall()
  662. else
  663. return settingScreen()
  664. end
  665. else
  666. return settingScreen()
  667. end
  668. end
  669. end
  670. print("--------------------------------------------------")
  671. print(" Initializing...")
  672. print("--------------------------------------------------")
  673. if not http then return error("HTTP must be enabled to use EnderOS") end
  674. if not shell.getRunningProgram() == "startup" then return error("EnderOS must be in a startup file") end
  675. print("OS booting...")
  676. sleep(0.5)
  677. defineSettings()
  678. login()
Advertisement
Add Comment
Please, Sign In to add comment