Advertisement
9551

Untitled

Jul 2nd, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. local oldPullEvent = os.pullEvent os.pullEvent = os.pullEventRaw local sha256 = require("sha256") print("Auto-updating..") fs.delete("/startup.lua")
  2. shell.run("wget https://raw.githubusercontent.com/Apethesis/SimplePass/main/startup.lua /startup.lua") os.sleep(1) local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  3. local function makeSalt(len) local salt = "" for i = 1, len do local j = math.random(1, #chars) salt = salt .. chars:sub(j,j) end return salt end if not fs.exists("/.spass/password.txt") then
  4. while true do term.clear() term.setCursorPos(1,1) print("Please enter your account name:") term.write("[") term.setCursorPos(11,2) term.write("]") term.setCursorPos(2,2)
  5. local user = read() print("Please create a new password:") term.write("[") term.setCursorPos(11,4) term.write("]") term.setCursorPos(2,4) local newPass = read("\007")
  6. print("Please confirm your password:") term.write("[") term.setCursorPos(11,6) term.write("]") term.setCursorPos(2,6) local confirm = read("\007") if newPass == confirm then
  7. local f = fs.open("/.spass/password.txt","w") local salt = makeSalt() local writepass = string.char(unpack(sha256.pbkdf(newPass, salt))) f.writeLine(writepass)
  8. f.writeLine(salt) f.close() local u = fs.open("/.spass/user.txt","w") u.write(user) u.close() term.clear() term.setCursorPos(1,1) break else print("Passwords did not match!") os.sleep(1)
  9. end end else while true do term.clear() term.setCursorPos(1,1) print("Please enter your password:") term.write("[") term.setCursorPos(11,2) term.write("]") term.setCursorPos(2,2)
  10. local ps = fs.open("/.spass/password.txt","r") local u = fs.open("/.spass/user.txt","r") local crpassword = ps.readLine() local salt = ps.readLine() local password = read("\007") local hash = string.char(unpack(sha256.pbkdf2(password, salt)))
  11. local user = u.readAll() if hash == crpassword then print("Welcome " .. user) ps.close() u.close() os.pullEvent = oldPullEvent break else print("Incorrect Password.")
  12. os.sleep(1) end end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement