Guest User

login

a guest
Jun 16th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.83 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. 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. Welcome to your PC.")
  26.       sleep(3)
  27.       term.clear()
  28.       term.setCursorPos(1,1)
  29.       print("Reinified academy SecurePC 2.0")
  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(25)
  48.   NUpwF = NUpw..sl1
  49.   NUpwFS = loginsha.sha256(NUpwF)
  50.   hMkPw.writeLine(NUname)
  51.   hMkPw.writeLine(sl1)
  52.   hMkPw.writeLine(NUpwFS)
  53.   hMkPw.close()
  54.   print("Finished creation.")
  55.   sleep(5)
  56.   os.reboot()
  57.   end
  58. hRPW.close()
  59. end
  60. else
  61. imgc = paintutils.loadImage("login/img")
  62. paintutils.drawImage(imgc, 1, 1)
  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. shell.run("wget https://pastebin.com/raw/PSyahsTY login/limg2")
  67. shell.run("wget https://pastebin.com/raw/j9aWDcNQ login/limg3")
  68. shell.run("wget https://pastebin.com/raw/9byDY6za login/limg4")
  69. shell.run("wget https://pastebin.com/raw/qX5dWTH9 login/limg5")
  70. sleep(1)
  71. imgc = paintutils.loadImage("login/limg2")
  72. paintutils.drawImage(imgc, 1, 1)
  73. shell.run("wget https://pastebin.com/raw/WLvxP5Vn login/loginsha")
  74. sleep(1)
  75. imgc = paintutils.loadImage("login/limg3")
  76. paintutils.drawImage(imgc, 1, 1)
  77. shell.run("wget https://pastebin.com/raw/9YW1XWXN login/logsalt")
  78. sleep(1)
  79. imgc = paintutils.loadImage("login/limg4")
  80. paintutils.drawImage(imgc, 1, 1)
  81. sleep(2)
  82. term.clear()
  83. term.setCursorPos(1, 1)
  84. print("Initial download complete.")
  85. fs.copy(shell.getRunningProgram(), "login/login")
  86. print("Set login as startup program? (y/n)")
  87. write("Choice: ")
  88. if read() == "y" then
  89. fs.delete("startup")
  90. fs.copy("login/login", "startup")
  91. print("Set as start up file.")
  92. elseif read() == "Y" then
  93. fs.delete("startup")
  94. fs.copy("login/login", "startup")
  95. print("Set as startup file.")
  96. end
  97. os.reboot()
  98. end
Add Comment
Please, Sign In to add comment