-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathInvoke-EDRChecker.ps1
310 lines (281 loc) · 12.3 KB
/
Invoke-EDRChecker.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
$edr_list = @('activeconsole',
'ADA-PreCheck',
'ahnlab',
'amsi.dll',
'anti malware',
'anti-malware',
'antimalware',
'anti virus',
'anti-virus',
'antivirus',
'appsense',
'attivo networks',
'attivonetworks',
'authtap',
'avast',
'avecto',
'bitdefender',
'blackberry',
'canary',
'carbonblack',
'carbon black',
'cb.exe',
'check point',
'ciscoamp',
'cisco amp',
'countercept',
'countertack',
'cramtray',
'crssvc',
'crowdstrike',
'csagent',
'csfalcon',
'csshell',
'cybereason',
'cyclorama',
'cylance',
'cynet',
'cyoptics',
'cyupdate',
'cyvera',
'cyserver',
'cytray',
'darktrace',
'deep instinct',
'defendpoint',
'defender',
'eectrl',
'elastic',
'endgame',
'f-secure',
'forcepoint',
'fortinet',
'fireeye',
'groundling',
'GRRservic',
'harfanglab',
'inspector',
'ivanti',
'juniper networks',
'kaspersky',
'lacuna',
'logrhythm',
'malware',
'malwarebytes',
'mandiant',
'mcafee',
'morphisec',
'msascuil',
'msmpeng',
'nissrv',
'omni',
'omniagent',
'osquery',
'Palo Alto Networks',
'pgeposervice',
'pgsystemtray',
'privilegeguard',
'procwall',
'protectorservic',
'qianxin',
'qradar',
'qualys',
'rapid7',
'redcloak',
'red canary',
'SanerNow',
'sangfor',
'secureworks',
'securityhealthservice',
'semlaunchsv',
'sentinel',
'sentinelone',
'sepliveupdat',
'sisidsservice',
'sisipsservice',
'sisipsutil',
'smc.exe',
'smcgui',
'snac64',
'somma',
'sophos',
'splunk',
'srtsp',
'symantec',
'symcorpu',
'symefasi',
'sysinternal',
'sysmon',
'tanium',
'tda.exe',
'tdawork',
'tehtris',
'threat',
'trellix',
'tpython',
'trend micro',
'uptycs',
'vectra',
'watchguard',
'wincollect',
'windowssensor',
'wireshark',
'withsecure',
'xagt.exe',
'xagtnotif.exe'
)
<#
.SYNOPSIS
Enumerates the host and checks it for defensive products.
Author: Ross Bingham (@PwnDexter)
License: BSD 3-Clause
Required Dependencies: None
Optional Dependencies: None
.DESCRIPTION
Enumerates the target host by querying processes, process metadata, dlls loaded into your current process and each dlls metadata, known install paths, installed services, the registry and running drivers then checks the output against a list of known defensive products such as AV's, EDR's and logging tools.
.PARAMETER Force
Forces registry checks when not running as admin.
.PARAMETER Remote
Specifies the computername to perform the remote checks against.
.PARAMETER Ignore
Forces the remote checks against the target regardless of connectivity and name resolution.
.EXAMPLE
PS C:\> Invoke-EDRChecker
PS C:\> Invoke-EDRChecker -Force
PS C:\> Invoke-EDRChecker -Remote <hostname>
PS C:\> Invoke-EDRChecker -Remote <hostname> -Ignore
#>
function Invoke-EDRChecker
{
[CmdletBinding(DefaultParameterSetName='Registry')]
param(
[Parameter(ParameterSetName='Registry', Mandatory=$false)][switch] $Force,
[Parameter(ParameterSetName='Remote', Mandatory=$false)][switch] $Remote,
[Parameter(ParameterSetName='Remote', Mandatory=$false)][switch] $Ignore,
[Parameter(ParameterSetName='Remote', Mandatory=$false, position=0)][string] $ComputerName
)
$edr = $edr_list
if ($Remote -eq $false)
{
Write-Output ""
Write-Output "[!] Performing EDR Checks"
Write-Output "[!] Checking current user integrity"
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
$isadm = (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
if ($isadm | Select-String -Pattern "True") {Write-Output "[+] Running as admin, all checks will be performed"}
elseif (($isadm | Select-String -Pattern "False") -and ($Force -eq $false))
{Write-Output "[-] Not running as admin, process metadata, registry and drivers will not be checked"; Write-Output "[-] Use the -Force flag to force registry checks when not running as admin"}
elseif (($isadm | Select-String -Pattern "False") -or ($Force -eq $true))
{Write-Output "[-] Not running as admin, process metadata and drivers will not be checked"; Write-Output "[+] The -Force flag has been passed for best efforts registry checks"}
Write-Output ""
Write-Output "[!] Checking running processes"
if ($proc = Get-Process | Select-Object ProcessName,Name,Path,Company,Product,Description | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $proc -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] No suspicious processes found"}
Write-Output ""
Write-Output "[!] Checking loaded DLLs in your current process"
$procdll = Get-Process -Id $pid -Module
if ($metadll = (Get-Item $procdll.FileName).VersionInfo | Select-Object CompanyName,FileDescription,FileName,InternalName,LegalCopyright,OriginalFileName,ProductName | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $metadll -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] No suspicious DLLs loaded"}
Write-Output ""
Write-Output "[!] Checking Program Files"
if ($prog = Get-ChildItem -Path 'C:\Program Files\*' | Select-Object Name | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $prog -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] Nothing found in Program Files"}
Write-Output ""
Write-Output "[!] Checking Program Files x86"
if ($prog86 = Get-ChildItem -Path 'C:\Program Files (x86)\*' | Select-Object Name | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $prog86 -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] Nothing found in Program Files x86"}
Write-Output ""
Write-Output "[!] Checking Program Data"
if ($progd = Get-ChildItem -Path 'C:\ProgramData\*' | Select-Object Name | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $progd -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] Nothing found in Program Data"}
Write-Output ""
Write-Output "[!] Checking installed services"
if ($serv = Get-Service | Select-Object Name,DisplayName,ServiceName | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $serv -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] No suspicious services found"}
if (($isadm | Select-String -Pattern "True") -or ($Force -eq $true))
{
Write-Output ""
Write-Output "[!] Checking the registry"
if ($reg = Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\*' | Select-Object PSChildName,PSPath,DisplayName,ImagePath,Description | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $reg -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] Nothing found in Registry"}
}
if ($isadm | Select-String -Pattern "True")
{
Write-Output ""
Write-Output "[!] Checking the drivers"
if ($drv = fltmc instances | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $drv -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] No suspicious drivers found"}
}
}
if ($Remote -eq $true)
{
if ([string]::IsNullOrEmpty($ComputerName))
{Throw "[-] ComputerName not set, please provide the hostname of the target"}
if ($Ignore -ne $true)
{
Write-Output ""
Write-Output "[!] Checking connectivity to $ComputerName"
$con = Test-Connection -ComputerName $ComputerName -Count 2 -Delay 2 -Quiet
if ($con | Select-String -Pattern "False")
{Throw "[-] Connectivity to $ComputerName failed, use the -Ignore flag to attempt the checks anyway"}
else {Write-Output "[+] Connectivity to $ComputerName confirmed"}
Write-Output ""
Write-Output "[!] Resolving $ComputerName to it's FQDN"
$fqdn = [System.Net.DNS]::GetHostEntry($ComputerName).hostname
if ([string]::IsNullOrEmpty($fqdn))
{Throw "[-] Unable to resolve $ComputerName to a FQDN, use the -Ignore flag to attempt the checks anyway"}
else {Write-Output "[+] Successfully resolved $Computername to $fqdn"}
$targ = $fqdn
}
elseif ($ignore -eq $true)
{
Write-Output ""
Write-Output "[!] Ignoring connectivity and FQDN checks to $ComputerName, this may result in errors"
$targ = $ComputerName
}
$targ = $targ
Write-Output ""
Write-Output "[!] Performing EDR Checks against $targ, remote checks are limited to process listing, common install directories and installed services"
Write-Output ""
Write-Output "[!] Checking running processes of $targ"
if ($proc = Get-Process -ComputerName $targ | Select-Object ProcessName,Name,Path,Company,Product,Description | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $proc -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] No suspicious processes found"}
Write-Output ""
Write-Output "[!] Checking running services of $targ"
if ($serv = Get-Service -ComputerName $targ | Select-Object Name,DisplayName,ServiceName | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $serv -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] No suspicious services found"}
Write-Output ""
Write-Output "[!] Checking Program Files on $targ"
if ($prog = Get-ChildItem -Path "\\$targ\c$\Program Files\*" | Select-Object Name | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $prog -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] Nothing found in Program Files"}
Write-Output ""
Write-Output "[!] Checking Program Files x86 on $targ"
if ($prog86 = Get-ChildItem -Path "\\$targ\c$\Program Files (x86)\*" | Select-Object Name | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $prog86 -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] Nothing found in Program Files x86"}
Write-Output ""
Write-Output "[!] Checking Program Data on $targ"
if ($progd = Get-ChildItem -Path "\\$targ\c$\ProgramData\*" | Select-Object Name | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $progd -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] Nothing found in Program Data"}
Write-Output ""
Write-Output "[!] Checking installed services on $targ"
if ($serv = Get-Service -ComputerName $targ | Select-Object Name,DisplayName,ServiceName | Select-String -Pattern $edr -AllMatches)
{ForEach ($p in $serv -Replace "@{") {Write-Output "[-] $p".Trim("}")}}
else {Write-Output "[+] No suspicious services found"}
}
Write-Output ""
Write-Output "[!] EDR Checks Complete"
Write-Output ""
}