forked from ayeskatalas/Sophos-Removal-Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSophos Removal Tool.ps1
207 lines (149 loc) · 7.48 KB
/
Sophos Removal Tool.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#######################################################################
# Sophos Removal Tool v2.0 #
# By Drew Yeskatalas #
# #
# This tool will stop all running Sophos Services and tasks, #
# seek out uninstall strings for associated Sophos Products, #
# And silently remove them. #
# #
# The tool will then remove all Sophos services and directories #
# from Program Files, Program Files (x86), and ProgramData #
# #
# ***Note: This tool needs to be run as an admin with Sophos Admin #
# or Local Administrator rights. #
# #
#######################################################################
#Disable Tamper Protection (may require reboot)
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SAVService" /t REG_DWORD /v Start /d 0x00000004 /f
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Sophos MCS Agent" /t REG_DWORD /v Start /d 0x00000004 /f
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Sophos Endpoint Defense\TamperProtection\Config" /t REG_DWORD /v SAVEnabled /d 0 /f
REG ADD "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Sophos Endpoint Defense\TamperProtection\Config" /t REG_DWORD /v SEDEnabled /d 0 /f
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Sophos\SAVService\TamperProtection" /t REG_DWORD /v Enabled /d 0 /f
#Stop All Sophos Services
net stop "Sophos AutoUpdate Service"
net stop "Sophos Agent"
net stop "SAVService"
net stop "SAVAdminService"
net stop "Sophos Message Router"
net stop "Sophos Web Control Service"
net stop "swi_service"
net stop "swi_update"
net stop "SntpService"
net stop "Sophos System Protection Service"
net stop "Sophos Web Control Service"
net stop "Sophos Endpoint Defense Service"
#Redundant "Stop Sophos Services" check
wmic service where "caption like '%Sophos%'" call stopservice
#Kill all Sophos Services
taskkill /f /im ALMon.exe
taskkill /f /im ALsvc.exe
taskkill /f /im swi_fc.exe
taskkill /f /im swi_filter.exe
taskkill /f /im spa.exe
#Uninstall Sophos Network Threat Protection
$SNTPVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "Sophos Network Threat Protection" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SNTPVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
Start-Process cmd "/c $uninst /qn REBOOT=SUPPRESS /PASSIVE" -NoNewWindow
}
}
Start-Sleep -Seconds 30
#Uninstall Sophos System Protection
$SSPVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "Sophos System Protection" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SSPVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
Start-Process cmd "/c $uninst /qn REBOOT=SUPPRESS /PASSIVE" -NoNewWindow
}
}
Start-Sleep -Seconds 30
#Uninstall Sophos Client Firewall
$SCFVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "Sophos Client Firewall" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SCFVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
Start-Process cmd "/c $uninst /qn REBOOT=SUPPRESS /PASSIVE" -NoNewWindow
}
}
Start-Sleep -Seconds 30
#Uninstall Sophos Anti-Virus
$SAVVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "Sophos Anti-Virus" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SAVVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
Start-Process cmd "/c $uninst /qn REBOOT=SUPPRESS /PASSIVE" -NoNewWindow
}
}
Start-Sleep -Seconds 30
#Uninstall Sophos Remote Management System
$SRMSVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "Sophos Remote Management System" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SRMSVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
Start-Process cmd "/c $uninst /qn REBOOT=SUPPRESS /PASSIVE" -NoNewWindow
}
}
Start-Sleep -Seconds 30
#Uninstall Sophos AutoUpdate
$SAUVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "Sophos AutoUpdate" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SAUVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
Start-Process cmd "/c $uninst /qn REBOOT=SUPPRESS /PASSIVE" -NoNewWindow
}
}
Start-Sleep -Seconds 30
#Uninstall Sophos Endpoint Defense
$SEDVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object {$_.DisplayName -match "Sophos Endpoint Defense" } |
Select-Object -Property DisplayName, UninstallString
ForEach ($ver in $SEDVer) {
If ($ver.UninstallString) {
$uninst = $ver.UninstallString
cmd /c "$uninst"
}
}
Start-Sleep -Seconds 30
#Directory Cleanup
Remove-Item -LiteralPath "C:\Program Files\Sophos*" -Force -Recurse
Remove-Item -LiteralPath "C:\Program Files\Sophos" -Force -Recurse
Remove-Item -LiteralPath "C:\Program Files (x86)\Sophos" -Force -Recurse
Remove-Item -LiteralPath "C:\ProgramData\Sophos" -Force -Recurse
#Remove Registry Keys
REG Delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run" /v "Sophos AutoUpdate Monitor" /f
#Redundant "Stop Sophos Services" check
wmic service where "caption like '%Sophos%'" call stopservice
#Sophos Services Removal
sc.exe delete "SAVService"
sc.exe delete "SAVAdminService"
sc.exe delete "Sophos Web Control Service"
sc.exe delete "Sophos AutoUpdate Service"
sc.exe delete "Sophos Agent"
sc.exe delete "SAVService"
sc.exe delete "SAVAdminService"
sc.exe delete "Sophos Message Router"
sc.exe delete "swi_service"
sc.exe delete "swi_update"
sc.exe delete "SntpService"
sc.exe delete "Sophos System Protection Service"
sc.exe delete "Sophos Endpoint Defense Service"