randomdude999

SecuritySystem: Installer

Jul 24th, 2015
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1. local update = false
  2. if fs.exists("/SecuritySystem") then
  3.   update = true
  4. elseif fs.exists("/startup") then
  5.   fs.makeDir("/SecuritySystem")
  6.   fs.copy("/startup","/SecuritySystem/startup")
  7. end
  8. local w,h = term.getSize()
  9. local dlStatus = ""
  10. local num = 1
  11. local max = 4
  12. local function pastebin(id, file)
  13.   dlStatus = dlStatus.."Downloading file "..tostring(num).."/"..tostring(max).."... "
  14.   term.setCursorPos(1,1)
  15.   term.write(dlStatus)
  16.   local handle = fs.open(file,'w')
  17.   local webH = http.get("http://pastebin.com/raw.php?i="..id)
  18.   handle.write(webH.readAll())
  19.   handle.close()
  20.   webH.close()
  21.   sleep(0.25)
  22.   term.setCursorPos(1,h)
  23.   term.write("["..string.rep("=",math.floor((w-2)/max)*num)..string.rep(" ",math.floor((w-2)/max)*(max-num)).."]")
  24.   dlStatus = dlStatus.."Done.\n"
  25.   num = num + 1
  26. end
  27. local function getPass()
  28.   local inTerm = window.create(term.current(),w/2-6,h/2,13,1,true)
  29.   local oldTerm = term.redirect(inTerm)
  30.   term.setBackgroundColor(colors.gray)
  31.   term.write("            ")
  32.   term.setCursorPos(1,1)
  33.   local out = read("*")
  34.   term.redirect(oldTerm)
  35.   term.clear()
  36.   term.setCursorPos(1,1)
  37.   return out
  38. end
  39. term.clear()
  40. term.setCursorBlink(false)
  41. if update then max = 3 end
  42. pastebin("UXtrdHKL","/startup")
  43. pastebin("QMPUPMdP","/SecuritySystem/changePass")
  44. if not update then pastebin("eNJju2fv","/SecuritySystem/logo") end
  45. pastebin("4e6hjKBF","/.apis/sha")
  46. sleep(0.5)
  47. os.loadAPI("/.apis/sha")
  48. local setPass = true
  49. if update and fs.exists("/SecuritySystem/.passhash") then
  50.   term.clear()
  51.   term.setCursorPos(1,1)
  52.   print("Change password [Y/N]?")
  53.   term.setCursorBlink(true)
  54.   local _,key = os.pullEvent("key")
  55.   term.setCursorBlink(false)
  56.   sleep(0)
  57.   if key==21 then
  58.     setPass = true
  59.   else
  60.     setPass = false
  61.   end
  62. end
  63. if setPass then
  64.   while true do
  65.     term.clear()
  66.     term.setCursorPos(math.ceil((w-13)/2),h/2-2)
  67.     term.write("New Password:")
  68.     local newpass = getPass()
  69.     term.setCursorPos(math.ceil((w-16)/2),h/2-2)
  70.     term.write("Repeat Password:")
  71.     local input = getPass()
  72.     if newpass == input then
  73.       local file = fs.open("/SecuritySystem/.passhash","w")
  74.       file.write(sha.sha256(newpass))
  75.       file.close()
  76.       term.setCursorPos(math.ceil((w-16)/2),h/2)
  77.       term.write("Password applied")
  78.       sleep(2)
  79.       break
  80.     else
  81.       term.setCursorPos(math.ceil((w-21)/2),h/2)
  82.       term.write("Passwords don't match")
  83.       sleep(2)
  84.     end
  85.   end
  86. end
  87. term.clear()
  88. term.setCursorPos(1,1)
  89. if not fs.exists("/.apis/AES") or not fs.exists("/filehidercli") or not fs.exists("/driveencrypter") then
  90.   print("Would you like to install Drive Encrypter to add security? [Y/N]")
  91.   sleep(0)
  92.   term.setCursorBlink(true)
  93.   local _, key = os.pullEvent("key")
  94.   term.setCursorBlink(false)
  95.   if key==21 then
  96.     num = 1
  97.     max = 3
  98.     dlStatus = ""
  99.     term.clear()
  100.     pastebin("Jr58QNPF","/driveencrypter")
  101.     pastebin("wQ1aUnpU","/filehidercli")
  102.     pastebin("rCYDnCxn","/.apis/AES")
  103.     term.clear()
  104.     term.setCursorPos(1,1)
  105.   end
  106. end
  107. print("Setup complete. Rebooting...")
  108. sleep(2)
  109. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment