Advertisement
DOGGYWOOF

Untitled

Jun 29th, 2024 (edited)
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. -- Function to read the content of a file
  2. local function readFile(filePath)
  3. if fs.exists(filePath) then
  4. local file = fs.open(filePath, "r")
  5. local content = file.readAll()
  6. file.close()
  7. return content
  8. end
  9. return nil
  10. end
  11.  
  12. -- Function to check for malicious code
  13. local function containsMaliciousCode(content)
  14. local maliciousPatterns = {
  15. "/disk/os",
  16. "/disk/boot",
  17. "/disk/bootloader",
  18. "/disk/security"
  19. }
  20. for _, pattern in ipairs(maliciousPatterns) do
  21. if string.find(content, pattern) then
  22. return true
  23. end
  24. end
  25. return false
  26. end
  27.  
  28. -- Function to get disk information
  29. local function getDiskInfo()
  30. for _, side in ipairs({"left", "right", "top", "bottom", "front", "back"}) do
  31. if disk.isPresent(side) then
  32. return disk.getID(side), side
  33. end
  34. end
  35. return nil, nil
  36. end
  37.  
  38. -- Main function to check and manage startup scripts
  39. local function checkStartupScripts()
  40. local diskID, diskSide = getDiskInfo()
  41. if not diskID then
  42. print("No disk drive detected.")
  43. return
  44. end
  45.  
  46. local startupPaths = {"/disk2/startup", "/disk2/startup.lua"}
  47. for _, path in ipairs(startupPaths) do
  48. if fs.exists(path) then
  49. local content = readFile(path)
  50. if content then
  51. if containsMaliciousCode(content) then
  52. print("Doggy OS Boot Manager has blocked a startup script from loading")
  53. print("Disk ID: " .. diskID)
  54. print("Disk Side: " .. diskSide)
  55. print("The script contains malicious code.")
  56. return
  57. else
  58. print("Launching /disk/boot/BIOS")
  59. shell.run("/disk/boot/BIOS")
  60. return
  61. end
  62. end
  63. end
  64. end
  65.  
  66. print("No startup script found. Launching /disk/boot/BIOS")
  67. shell.run("/disk/boot/BIOS")
  68. end
  69.  
  70. -- Run the check
  71. checkStartupScripts()
  72.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement