Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function warnUser(filename)
- print("WARNING: File '" .. filename .. "' has been detected which modifies the startup file of the computer, which can prevent it from starting up.")
- end
- local function searchFileForKeyword(filename, keyword, skipKey)
- local file = fs.open(filename, "r")
- if not file then return end
- local content = file.readAll()
- file.close()
- if content:find(skipKey) then
- return
- end
- if content:find(keyword) then
- warnUser(filename)
- end
- end
- local function searchDirectory(path, keyword, skipKey)
- -- Skip the /rom directory and its subdirectories
- if path == "/rom" or string.sub(path, 1, 5) == "/rom/" then
- return
- end
- local files = fs.list(path)
- for _, file in ipairs(files) do
- local fullPath = fs.combine(path, file)
- if fs.isDir(fullPath) then
- searchDirectory(fullPath, keyword, skipKey)
- else
- searchFileForKeyword(fullPath, keyword, skipKey)
- end
- end
- end
- local function main()
- local keyword = "startup"
- local skipKey = "2f02e58e09db074280d6c10106c7511a"
- local rootPath = "/"
- searchDirectory(rootPath, keyword, skipKey)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement