Advertisement
DOGGYWOOF

OS verifcation

Feb 9th, 2024 (edited)
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. local configFile = "/disk/os/config.txt"
  2. local osVerification = false
  3.  
  4. -- Function to check and load config settings
  5. local function loadConfig()
  6. if fs.exists(configFile) then
  7. local file = fs.open(configFile, "r")
  8. osVerification = (file.readLine() == "true")
  9. file.close()
  10. end
  11. end
  12.  
  13. -- Function to display OS verification status
  14. local function displayVerificationStatus()
  15. term.clear()
  16. term.setCursorPos(1, 1)
  17. print("OS verification is " .. (osVerification and "enabled" or "disabled"))
  18. print("---------------------------------")
  19. end
  20.  
  21. -- Function to unlock bootloader
  22. local function unlockBootloader()
  23. local startupContent = [[
  24. term.clear()
  25. term.setCursorPos(1, 1)
  26. print("VA11-ILLA bootloader unlocked")
  27. print("Doggy OS security has disabled, Boot Doggy OS?")
  28. print("------------------------------------------------------------")
  29. print("1. Yes")
  30. print("2. No")
  31.  
  32. local choice = read()
  33.  
  34. if choice == "1" then
  35. print("Booting kernel...")
  36. sleep(2)
  37. shell.run("/disk/os/gui")
  38. elseif choice == "2" then
  39. os.shutdown()
  40. end
  41. ]]
  42. local file = fs.open("/startup", "w")
  43. file.write(startupContent)
  44. file.close()
  45.  
  46. -- Set OS verification to disabled after unlocking bootloader
  47. osVerification = false
  48. local config = fs.open(configFile, "w")
  49. config.write("false")
  50. config.close()
  51. end
  52.  
  53. -- Function to lock bootloader
  54. local function lockBootloader()
  55. fs.copy("/recovery/boot/error", "/startup")
  56. end
  57.  
  58. -- Function to enable OS verification
  59. local function enableOSVerification()
  60. term.clear()
  61. term.setCursorPos(1, 1)
  62. print("Enabling OS verification...")
  63. sleep(1)
  64.  
  65. local file = fs.open(configFile, "w")
  66. file.write("true")
  67. file.close()
  68. print("OS verification enabled")
  69. sleep(1)
  70. -- Set OS verification to enabled after enabling OS verification
  71. osVerification = true
  72. end
  73.  
  74. -- Function to run app with superuser permissions
  75. local function runWithSuperuser()
  76. term.clear()
  77. term.setCursorPos(1, 1)
  78. print("Type a file name:")
  79. local fileName = read()
  80.  
  81. -- Display a message before running the app
  82. print("This application has full system access to your OS file system.")
  83. print("Run file: " .. fileName .. "? (yes/no)")
  84. local confirm = read()
  85.  
  86. if confirm:lower() == "yes" then
  87. local success, errorMessage = pcall(function()
  88. shell.run("sudo", fileName)
  89. end)
  90.  
  91. if not success then
  92. print("This operation has failed: " .. errorMessage)
  93. sleep(2)
  94. end
  95. else
  96. print("Operation canceled.")
  97. sleep(1)
  98. end
  99. end
  100.  
  101. -- Main program
  102. while true do
  103. loadConfig()
  104. displayVerificationStatus()
  105.  
  106. -- Show OS verification status and wait for Enter to display the menu
  107. print("Press Enter to continue...")
  108. while true do
  109. local _, key = os.pullEvent("key")
  110. if key == keys.enter then
  111. break
  112. end
  113. end
  114.  
  115. displayMainMenu()
  116.  
  117. local option = read()
  118.  
  119. if option == "1" then
  120. unlockBootloader()
  121. elseif option == "2" then
  122. lockBootloader()
  123. elseif option == "3" then
  124. enableOSVerification()
  125. elseif option == "4" then
  126. runWithSuperuser()
  127. elseif option == "5" then
  128. print("Exiting...")
  129. sleep(1)
  130. term.clear()
  131. term.setCursorPos(1, 1)
  132. break
  133. else
  134. print("Invalid option.")
  135. sleep(1)
  136. end
  137. end
  138.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement