SHARE
TWEET

Adware Removal script

applehelpwriter Aug 23rd, 2017 509 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ###########################################################
  2. -->> ABOUT
  3. ###########################################################
  4. (*
  5.  
  6.  Phil Stokes -- 2017
  7.  applehelpwriter.com
  8.  sqwarq.com
  9.  
  10. *)
  11. ###########################################################
  12. -->> DESCRIPTION
  13. ###########################################################
  14. (*
  15.  
  16. Remove adware components from a Mac
  17.  
  18. *)
  19. ###########################################################
  20. -->> USAGE
  21. ###########################################################
  22. (*
  23.  
  24. Open this script with the Script Editor.app located at
  25. /Applications/Utilities/Script Editor.app
  26.  
  27. At the bottom left of the window, click the 3rd icon and click the 'Events' button in the pane.
  28.  
  29. Click the ▶︎ button in the Editor's toolbar.
  30.  
  31. Provide an administrator password to authorise the removal of the adware items.
  32.  
  33. If you receive any error messages, please take a screenshot of the error and contact support@sqwarq.com
  34.  
  35. If you receive any error messages, do not quit the Script Editor or close the script window as it contains information that you may be asked for. You can dismiss the error message.
  36.  
  37. *)
  38.  
  39.  
  40. # constants
  41. set tLabel to "Sqwarq Adware Removal Script"
  42. set removalList to {"/Library/ZAgxheFe/ZAgxheFe.app/Contents/MacOS/ZAgxheFe", "/Library/ZAgxheFe/ZAgxheFe.app", "/Library/ZAgxheFe", "/Library/outtrick/outtrick", "/Library/outtrick", "~/Library/LaunchAgents/com.outtrick.plist", "/Library/LaunchDaemons/com.ZAgxheFe.plist", "/Library/LaunchAgents/com.filite.plist"}
  43.  
  44. set refusedToDieList to {}
  45. set msg to ""
  46.  
  47.  
  48. #handlers
  49. on checkExistence:suspect
  50.     if suspect begins with "~" then
  51.         set suspect to (POSIX path of (path to home folder)) & text 2 thru -1 of suspect
  52.     end if
  53.     tell application "Finder"
  54.         if exists suspect as POSIX file then
  55.             return true
  56.         else
  57.             return false
  58.         end if
  59.     end tell
  60. end checkExistence:
  61.  
  62. on doubleEscapeSpaces:aPath
  63.     if aPath contains " " then
  64.         set o to offset of " " in aPath
  65.         set _prefix to text 1 thru (o - 1) of aPath
  66.         set _suffix to text o thru -1 of aPath
  67.         set aPath to _prefix & "\\" & _suffix
  68.     end if
  69.     return aPath
  70. end doubleEscapeSpaces:
  71.  
  72. #commands
  73. repeat with i from 1 to count of removalList
  74.     set doesExist to false
  75.     set remove_item to item i of removalList
  76.     set doesExist to (its checkExistence:remove_item)
  77.     # 'quoted form' isn't reliable, so:
  78.     set shell_item to (its doubleEscapeSpaces:remove_item)
  79.     try
  80.         if doesExist is true then
  81.             do shell script "rm -rf " & shell_item with administrator privileges
  82.         end if
  83.     on error
  84.         set end of refusedToDieList to remove_item
  85.         log "Could not remove " & remove_item
  86.     end try
  87.     if (its checkExistence:remove_item) then
  88.         set end of refusedToDieList to remove_item
  89.     end if
  90. end repeat
  91.  
  92.  
  93. # results
  94. if (count of refusedToDieList) < (count of removalList) then
  95.     set msg to "Restart your Mac to complete the removal of the adware infection." & return & return & "Quit this script, save any other work, and choose 'Restart' from the  Apple menu."
  96. else if (count of refusedToDieList) > 0 then
  97.     set msg to "Error: Could not delete one or more items."
  98.     display dialog msg with title tLabel buttons "OK" default button "OK" with icon 1
  99. else
  100.     set msg to "The script failed for an unknown reason. "
  101. end if
  102. display dialog msg with title tLabel buttons "OK" default button "OK" with icon 1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top