Advertisement
Guest User

startup

a guest
Jun 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. if fs.exists("login/img") then
  3. img = paintutils.loadImage("login/img")
  4. paintutils.drawImage(img, 1, 1)
  5. sleep(4)
  6. os.loadAPI("login/loginsha")
  7. os.loadAPI("login/logsalt")
  8. while true do
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. print("SecureDoor. Please enter credentials.")
  12. write("Username: ")
  13. uName = read()
  14. write("Password: ")
  15. uPwR = read("*")
  16. if fs.exists("login/pw.lgn") == true then
  17.   hRPW = fs.open("login/pw.lgn", "r")
  18.   test = hRPW.readLine()
  19.   test2 = hRPW.readLine()
  20.   test3 = hRPW.readLine()
  21.   uPwRS = uPwR..test2
  22.   uPwRSH = loginsha.sha256(uPwRS)
  23.   if test == uName then
  24.     if test3 == uPwRSH then
  25.       print("Correct password.")
  26.       sleep(3)
  27.       term.setBackgroundColor( colors.black )
  28.       term.clear()
  29.       term.setCursorPos(1,1)
  30.       break
  31.     else
  32.       print("Username or password incorrect. Please try again.")
  33.       sleep(3)
  34.       end
  35.   else
  36.     print("Username or password incorrect. Please try again.")
  37.     sleep(3)
  38.     end
  39. else
  40.   print("You do not have a password file. Creating one.")
  41.   fs.delete("login/pw.lgn")
  42.   hMkPw = fs.open("login/pw.lgn", "w")
  43.   write("Enter new username: ")
  44.   NUname = read()
  45.   write("Enter new password: ")
  46.   NUpw = read("*")
  47.   sl1 = logsalt.rand(250)
  48.   sl1l = sl1
  49.   NUpwF = NUpw..sl1l
  50.   NUpwFS = loginsha.sha256(NUpwF)
  51.   hMkPw.writeLine(NUname)
  52.   hMkPw.writeLine(sl1)
  53.   hMkPw.writeLine(NUpwFS)
  54.   hMkPw.close()
  55.   print("Finished creation.")
  56.   sleep(2)
  57.   os.reboot()
  58.   end
  59. hRPW.close()
  60. end
  61. else
  62. shell.run("mkdir login")
  63. shell.run("wget https://pastebin.com/raw/PJjAybwf login/img")
  64. shell.run("wget https://pastebin.com/raw/WLvxP5Vn login/loginsha")
  65. shell.run("wget https://pastebin.com/raw/9YW1XWXN login/logsalt")
  66. print("Initial download complete. Ready to run.")
  67. fs.copy(shell.getRunningProgram(), "login/login")
  68. print("Set login as startup program? (y/n)")
  69. write("Choice: ")
  70. if read() == "y" then
  71. fs.delete("startup")
  72. fs.copy("login/login", "startup")
  73. print("Set as start up file.")
  74. elseif read() == "Y" then
  75. fs.delete("startup")
  76. fs.copy("login/login", "startup")
  77. print("Set as startup file.")
  78. end
  79. os.reboot()
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement