Advertisement
DOGGYWOOF

intercept system file deltetion

Jan 8th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. -- List of protected directories
  2. local protectedDirs = {
  3. ["/disk/os"] = true,
  4. ["/disk/boot"] = true,
  5. ["/disk/bootloader"] = true
  6. }
  7.  
  8. -- Function to check if the path is protected
  9. local function isProtected(path)
  10. return protectedDirs[path]
  11. end
  12.  
  13. -- Override the os.remove function
  14. local oldRemove = os.remove
  15. os.remove = function(path)
  16. if isProtected(path) then
  17. print("Are you sure you want to delete this protected directory? (Y/N)")
  18. local answer = read()
  19. if answer:lower() == "y" then
  20. oldRemove(path)
  21. else
  22. print("Deletion cancelled.")
  23. end
  24. else
  25. oldRemove(path)
  26. end
  27. end
  28.  
  29. -- Constantly run to intercept deletion attempts
  30. while true do
  31. os.pullEvent() -- Wait for an event to keep the script running
  32. end
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement