Advertisement
DOGGYWOOF

passkey

Mar 8th, 2024 (edited)
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. -- ... (existing code)
  2.  
  3. local function checkPassphrase(username)
  4. local storedPassphrase = getPassphrase(username)
  5.  
  6. if not storedPassphrase then
  7. return false -- Passphrase not set
  8. end
  9.  
  10. term.setTextColor(colors.white)
  11. print("Enter passphrase:")
  12.  
  13. local enteredPassphrase = read("*")
  14.  
  15. return enteredPassphrase == storedPassphrase
  16. end
  17.  
  18. local function checkPasskeyConfig(disk)
  19. local passkeyConfigFile = fs.combine(disk, "passkey.config")
  20.  
  21. if fs.exists(passkeyConfigFile) then
  22. local file = fs.open(passkeyConfigFile, "r")
  23. local storedUsername = file.readLine()
  24. file.close()
  25.  
  26. term.setTextColor(colors.white)
  27. print("Enter username:")
  28.  
  29. local enteredUsername = read()
  30.  
  31. if enteredUsername == storedUsername then
  32. return checkPassphrase(enteredUsername)
  33. else
  34. return false -- Incorrect username
  35. end
  36. else
  37. return false -- passkey.config not found
  38. end
  39. end
  40.  
  41. local function main()
  42. term.clear()
  43. term.setCursorPos(1, 1)
  44.  
  45. term.setTextColor(colors.green)
  46. print("Protected by Doggy OS security")
  47. print("-----------------------------")
  48.  
  49. term.setTextColor(colors.white)
  50.  
  51. -- Check for passkey.config on /disk2/
  52. if checkPasskeyConfig("/disk2/") then
  53. term.clear()
  54. term.setCursorPos(1, 1)
  55. term.setTextColor(colors.lime)
  56. print("Access granted on /disk2/. Welcome!")
  57. os.sleep(2)
  58. -- Continue with the main OS code for /disk2/
  59. return
  60. end
  61.  
  62. -- Check for passkey.config on /disk3/
  63. if checkPasskeyConfig("/disk3/") then
  64. term.clear()
  65. term.setCursorPos(1, 1)
  66. term.setTextColor(colors.lime)
  67. print("Access granted on /disk3/. Welcome!")
  68. os.sleep(2)
  69. -- Continue with the main OS code for /disk3/
  70. return
  71. end
  72.  
  73. -- Continue with the existing code for username entry
  74. print("Enter username:")
  75. local enteredUsername = read()
  76.  
  77. if checkDisabled(enteredUsername) then
  78. term.clear()
  79. term.setCursorPos(1, 1)
  80. term.setTextColor(colors.red)
  81. print("This user has been disabled due to security reasons.")
  82. os.sleep(3) -- Display the disabled message for 3 seconds
  83. print("Contact your administrator for help.")
  84. os.sleep(2) -- Display the contact administrator message for 2 seconds
  85. shell.run("/disk/os/lock.lua") -- Run the lock.lua program
  86. return
  87. end
  88.  
  89. local users = fs.list(USERS_FOLDER)
  90.  
  91. if not users or #users == 0 then
  92. -- No users detected, run the BSOD program
  93. shell.run(ERROR_FOLDER .. BSOD_PROGRAM)
  94. elseif checkCredentials(enteredUsername) then
  95. term.clear()
  96. term.setCursorPos(1, 1)
  97.  
  98. term.setTextColor(colors.lime)
  99. print("Access granted. Welcome, " .. enteredUsername .. "!")
  100. os.sleep(2) -- Display the success message for 2 seconds
  101.  
  102. -- Your main OS code goes here
  103. else
  104. term.clear()
  105. term.setCursorPos(1, 1)
  106.  
  107. term.setTextColor(colors.red)
  108. print("Access denied.")
  109. os.sleep(2) -- Display the access denied message for 2 seconds
  110. end
  111. end
  112.  
  113. main()
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement