Advertisement
DOGGYWOOF

Untitled

Oct 27th, 2024
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. -- Clear the screen and set up colors
  2. term.clear()
  3. term.setBackgroundColor(colors.black)
  4. term.setTextColor(colors.white)
  5. term.clear()
  6.  
  7. -- Define the width and height of the screen
  8. local width, height = term.getSize()
  9.  
  10. -- Function to center text on the screen
  11. local function centerText(y, text, textColor)
  12. local x = math.floor((width - #text) / 2)
  13. term.setCursorPos(x, y)
  14. term.setTextColor(textColor)
  15. term.write(text)
  16. end
  17.  
  18. -- Display the initial message "Doggy OS Security Error!" at the top in white
  19. centerText(3, "Doggy OS Security Error!", colors.white)
  20.  
  21. -- Function to show an error message with ASCII art
  22. local function showError(message)
  23. term.clear()
  24.  
  25. -- ASCII art with yellow dog and ? eyes
  26. local dogArt = {
  27. " |\\_/| ",
  28. " | ? ? ",
  29. " | <> _ ",
  30. " | _/\\------____ ((| |))",
  31. " | `--' | ",
  32. " _____|_ ___| |___. ",
  33. "/_/_____/____/_______| "
  34. }
  35.  
  36. local startLine = math.floor((height - #dogArt) / 2) - 2
  37.  
  38. -- Display the dog ASCII art with yellow color and ? eyes
  39. term.setTextColor(colors.yellow)
  40. for i, line in ipairs(dogArt) do
  41. centerText(startLine + i, line, colors.yellow)
  42. end
  43.  
  44. -- Display error message below the dog ASCII art in white
  45. term.setTextColor(colors.white)
  46. centerText(startLine + #dogArt + 2, "Error:", colors.white)
  47. centerText(startLine + #dogArt + 3, message, colors.white)
  48.  
  49. -- Move "Please contact support." to the bottom in white
  50. centerText(height - 2, "Please contact support.", colors.white)
  51. end
  52.  
  53. -- Function to request admin credentials
  54. local function requestAdminUnlock()
  55. term.clear()
  56. centerText(3, "System Locked!", colors.red)
  57. centerText(5, "Enter Admin Credentials to Unlock", colors.white)
  58.  
  59. -- Get username and password
  60. term.setCursorPos(math.floor(width / 2) - 6, height // 2)
  61. term.write("Username: ")
  62. local username = read()
  63.  
  64. term.setCursorPos(math.floor(width / 2) - 6, height // 2 + 1)
  65. term.write("Password: ")
  66. local password = read("*")
  67.  
  68. -- Check if user has both password.txt and admin.txt
  69. local userDir = "/disk/users/" .. username
  70. local adminPath = fs.combine(userDir, "admin.txt")
  71. local passwordPath = fs.combine(userDir, "password.txt")
  72.  
  73. if fs.exists(adminPath) and fs.exists(passwordPath) then
  74. local file = fs.open(passwordPath, "r")
  75. if file.readAll() == password then
  76. fs.delete("/boot.lock")
  77. term.clear()
  78. centerText(3, "System Unlocked", colors.green)
  79. sleep(1)
  80. return true
  81. end
  82. file.close()
  83. end
  84.  
  85. centerText(height - 1, "Invalid Credentials or No Admin Privileges.", colors.red)
  86. sleep(2)
  87. return false
  88. end
  89.  
  90. -- Function to check for boot.lock file
  91. local function checkBootLock()
  92. if fs.exists("/boot.lock") then
  93. while not requestAdminUnlock() do end
  94. end
  95. end
  96.  
  97. -- Main function to initiate checks and continue boot process
  98. local function main()
  99. checkBootLock()
  100. -- Additional security checks...
  101. shell.run("/disk/boot/BIOS") -- Continue to boot
  102. end
  103.  
  104. -- Start the main function
  105. main()
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement