Advertisement
DOGGYWOOF

Untitled

Jul 11th, 2024 (edited)
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. local function warnUser(filename)
  2. print("WARNING: File '" .. filename .. "' has been detected which modifies the startup file of the computer, which can prevent it from starting up.")
  3. end
  4.  
  5. local function searchFileForKeyword(filename, keyword, skipKey)
  6. local file = fs.open(filename, "r")
  7. if not file then return end
  8.  
  9. local content = file.readAll()
  10. file.close()
  11.  
  12. if content:find(skipKey) then
  13. return
  14. end
  15.  
  16. if content:find(keyword) then
  17. warnUser(filename)
  18. end
  19. end
  20.  
  21. local function searchDirectory(path, keyword, skipKey)
  22. -- Skip the /rom directory and its subdirectories
  23. if path == "/rom" or string.sub(path, 1, 5) == "/rom/" then
  24. return
  25. end
  26.  
  27. local files = fs.list(path)
  28. for _, file in ipairs(files) do
  29. local fullPath = fs.combine(path, file)
  30. if fs.isDir(fullPath) then
  31. searchDirectory(fullPath, keyword, skipKey)
  32. else
  33. searchFileForKeyword(fullPath, keyword, skipKey)
  34. end
  35. end
  36. end
  37.  
  38. local function main()
  39. local keyword = "startup"
  40. local skipKey = "2f02e58e09db074280d6c10106c7511a"
  41. local rootPath = "/"
  42.  
  43. searchDirectory(rootPath, keyword, skipKey)
  44. end
  45.  
  46. main()
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement