Advertisement
DOGGYWOOF

DOG-Integrity

Oct 19th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. -- secureBootCheck.lua
  2.  
  3. -- Function to check if .settings file exists and contains shell.allow_disk_startup
  4. local function isSecureBootConfigured()
  5. local settingsPath = "/.settings"
  6. if fs.exists(settingsPath) then
  7. local file = fs.open(settingsPath, "r")
  8. if file then
  9. local contents = file.readAll()
  10. file.close()
  11. -- Check if .settings contains shell.allow_disk_startup
  12. if not string.find(contents, '["%s-]shell%.allow_disk_startup["%s-]') then
  13. return false -- shell.allow_disk_startup not found
  14. end
  15. end
  16. else
  17. -- .settings file doesn't exist
  18. return false -- Secure boot configuration file is missing
  19. end
  20. return true -- Secure boot is properly configured
  21. end
  22.  
  23. -- Function to display the fullscreen error
  24. local function showErrorScreen()
  25. term.clear()
  26. term.setCursorPos(1, 1)
  27.  
  28. -- ASCII art
  29. local asciiArt = [[
  30. |\_/|
  31. | @ @ Doggy OS Security!
  32. | <> _
  33. | _/\------____ ((| |))
  34. | `--' |
  35. ____|_ ___| |___.'
  36. /_/_____/____/_______|
  37. ]]
  38.  
  39. -- Shorter error message
  40. local errorMessage = "Security error. This function has failed"
  41.  
  42. -- Calculate positions for centering the ASCII art
  43. local width, height = term.getSize()
  44. local artLines = {}
  45. for line in asciiArt:gmatch("[^\r\n]+") do
  46. table.insert(artLines, line)
  47. end
  48.  
  49. local startY = math.floor((height - #artLines - 2) / 2)
  50. local startX = math.floor((width - #artLines[1]) / 2)
  51.  
  52. -- Display ASCII art centered
  53. for i, line in ipairs(artLines) do
  54. term.setCursorPos(startX, startY + i)
  55. term.write(line)
  56. end
  57.  
  58. -- Display the shorter error message below the ASCII art, centered
  59. local messageX = math.floor((width - #errorMessage) / 2)
  60. term.setCursorPos(messageX, startY + #artLines + 2)
  61. term.write(errorMessage)
  62.  
  63. -- Prevent further execution
  64. while true do
  65. os.pullEvent("key")
  66. end
  67. end
  68.  
  69. -- Run the secure boot check and show error if it fails
  70. if not isSecureBootConfigured() then
  71. showErrorScreen()
  72. end
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement