Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to delete a file
- local function deleteFile(path)
- fs.delete(path)
- end
- -- Main function to monitor files in /disk/packages
- local function monitorPackages()
- while true do
- local files = fs.list("/disk/packages")
- for _, file in ipairs(files) do
- local path = "/disk/packages/" .. file
- if fs.isDir(path) then
- -- Ignore directories
- goto continue
- end
- local code = fs.open(path, "r")
- local content = code.readAll()
- code.close()
- if checkCode(content) or isRestricted(path) then
- -- Detected suspicious activity, replace startup script, delete the file, and reboot
- securityError()
- deleteFile(path)
- os.reboot()
- end
- ::continue::
- end
- sleep(2) -- Check every 2 seconds
- end
- end
- -- Start monitoring
- parallel.waitForAny(monitorPackages)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement