Advertisement
Guest User

login

a guest
Jun 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.50 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("Secure login. Please enter your username and password")
  12. write("Username: ")
  13. local uName = read()
  14. write("Password: ")
  15. local uPwR = read("*")
  16. if fs.exists("login/pw.lgn") == true then
  17.   hRPW = fs.open("login/pw.lgn", "r")
  18.   local test = hRPW.readLine()
  19.   local test2 = hRPW.readLine()
  20.   local test3 = hRPW.readLine()
  21.   local uPwRS = uPwR..test2
  22.   local uPwRSH = loginsha.sha256(uPwRS)
  23.   if test == uName then
  24.     if test3 == uPwRSH then
  25.       print("Correct password. Welcome to your PC.")
  26.       sleep(3)
  27.       term.setBackgroundColor( colors.black )
  28.       term.clear()
  29.       term.setCursorPos(1,1)
  30.       print("SecureLogin 1.4")
  31.       break
  32.     else
  33.       print("Username or password incorrect. Please try again.")
  34.       sleep(3)
  35.       end
  36.   else
  37.     print("Username or password incorrect. Please try again.")
  38.     sleep(3)
  39.     end
  40. else
  41.   print("You do not have a password file. Creating one.")
  42.   fs.delete("login/pw.lgn")
  43.   hMkPw = fs.open("login/pw.lgn", "w")
  44.   write("Enter new username: ")
  45.   NUname = read()
  46.   write("Enter new password: ")
  47.   NUpw = read("*")
  48.   sl1 = logsalt.rand(256)
  49.   NUpwF = NUpw..sl1
  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(5)
  57.   os.reboot()
  58.   end
  59. hRPW.close()
  60. end
  61. else
  62. print("Thanks for downloading SecureLogin 1.4. Downloading required graphics etc.")
  63. shell.run("mkdir login")
  64. shell.run("wget https://pastebin.com/raw/PJjAybwf login/img")
  65. shell.run("wget https://pastebin.com/raw/SuxqjP3s login/limg1")
  66. sleep(1)
  67. imgc = paintutils.loadImage("login/limg1")
  68. paintutils.drawImage(imgc, 1, 1)
  69. shell.run("wget https://pastebin.com/raw/WLvxP5Vn login/loginsha")
  70. sleep(1)
  71. shell.run("wget https://pastebin.com/raw/9YW1XWXN login/logsalt")
  72. sleep(2)
  73. term.clear()
  74. term.setCursorPos(1, 1)
  75. print("Initial download complete.")
  76. fs.copy(shell.getRunningProgram(), "login/login")
  77. print("Set login as startup program? (y/n)")
  78. write("Choice: ")
  79. if read() == "y" then
  80. fs.delete("startup")
  81. fs.copy("login/login", "startup")
  82. print("Set as start up file.")
  83. elseif read() == "Y" then
  84. fs.delete("startup")
  85. fs.copy("login/login", "startup")
  86. print("Set as startup file.")
  87. end
  88. os.reboot()
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement