Advertisement
DOGGYWOOF

RT

Mar 16th, 2024 (edited)
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. -- Function to delete a file
  2. local function deleteFile(path)
  3. fs.delete(path)
  4. end
  5.  
  6. -- Main function to monitor files in /disk/packages
  7. local function monitorPackages()
  8. while true do
  9. local files = fs.list("/disk/packages")
  10. for _, file in ipairs(files) do
  11. local path = "/disk/packages/" .. file
  12. if fs.isDir(path) then
  13. -- Ignore directories
  14. goto continue
  15. end
  16.  
  17. local code = fs.open(path, "r")
  18. local content = code.readAll()
  19. code.close()
  20.  
  21. if checkCode(content) or isRestricted(path) then
  22. -- Detected suspicious activity, replace startup script, delete the file, and reboot
  23. securityError()
  24. deleteFile(path)
  25. os.reboot()
  26. end
  27.  
  28. ::continue::
  29. end
  30. sleep(2) -- Check every 2 seconds
  31. end
  32. end
  33.  
  34. -- Start monitoring
  35. parallel.waitForAny(monitorPackages)
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement