Advertisement
DOGGYWOOF

Untitled

Dec 9th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. -- Function to draw a border with a title
  2. local function drawBorderWithTitle(title)
  3. term.clear()
  4. local w, h = term.getSize()
  5. for y = 1, h do
  6. term.setCursorPos(1, y)
  7. term.write("|")
  8. term.setCursorPos(w, y)
  9. term.write("|")
  10. end
  11. for x = 1, w do
  12. term.setCursorPos(x, 1)
  13. term.write("-")
  14. term.setCursorPos(x, h)
  15. term.write("-")
  16. end
  17. term.setCursorPos(1, 1)
  18. term.write("+")
  19. term.setCursorPos(w, 1)
  20. term.write("+")
  21. term.setCursorPos(1, h)
  22. term.write("+")
  23. term.setCursorPos(w, h)
  24. term.write("+")
  25.  
  26. -- Center the title
  27. local x = math.floor((w - #title) / 2) + 1
  28. term.setCursorPos(x, 1)
  29. term.write("[" .. title .. "]")
  30. end
  31.  
  32. -- Function to center text on the screen
  33. local function centerText(text, y)
  34. local w, _ = term.getSize()
  35. local x = math.floor((w - #text) / 2) + 1
  36. term.setCursorPos(x, y)
  37. term.write(text)
  38. end
  39.  
  40. -- Function to verify the recovery key
  41. local function verifyRecoveryKey()
  42. local keyPath = "/disk/security/RecoveryKey.txt"
  43. if fs.exists(keyPath) then
  44. local file = fs.open(keyPath, "r")
  45. local storedKey = file.readAll()
  46. file.close()
  47.  
  48. term.clear()
  49. drawBorderWithTitle("Doggy OS System Security")
  50. centerText("Recovery key needed to regain access", 3)
  51. centerText("", 5)
  52.  
  53. term.setCursorPos(10, 7)
  54. term.write("Enter Key: ")
  55. local enteredKey = read()
  56.  
  57. if enteredKey == storedKey then
  58. centerText("Unlocking device...", 10)
  59. os.sleep(2)
  60. return true
  61. else
  62. centerText("Invalid key", 10)
  63. os.sleep(2)
  64. end
  65. else
  66. centerText("Recovery Key not found. Contact support.", 8)
  67. os.sleep(2)
  68. end
  69. return false
  70. end
  71.  
  72. -- Function to start recovery key authentication
  73. local function authenticate()
  74. term.clear()
  75. drawBorderWithTitle("Doggy OS Secure Boot")
  76.  
  77. if not verifyRecoveryKey() then
  78. os.reboot()
  79. end
  80. end
  81.  
  82. -- Start authentication process
  83. authenticate()
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement