-
Notifications
You must be signed in to change notification settings - Fork 2
/
WolfHound.ps1
331 lines (172 loc) · 10.3 KB
/
WolfHound.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#Requires -RunAsAdministrator
$logo = @( '
....
. ;\
/ : ._;
/ _.; :Tb|
/ / ;j$j
_.-" d$$$$
█ █░ ▒█████ ██▓ █████▒██░ ██ ▒█████ █ ██ ███▄ █ ▓█████▄ ./ .. d$$$$;
▓█░ █ ░█░▒██▒ ██▒▓██▒ ▓██ ▒▓██░ ██▒▒██▒ ██▒ ██ ▓██▒ ██ ▀█ █ ▒██▀ ██▌ / /X` d$$$$P. |\
▒█░ █ ░█ ▒██░ ██▒▒██░ ▒████ ░▒██▀▀██░▒██░ ██▒▓██ ▒██░▓██ ▀█ ██▒░██ █▌ / " .d$$$P` |\^"l
░█░ █ ░█ ▒██ ██░▒██░ ░▓█▒ ░░▓█ ░██ ▒██ ██░▓▓█ ░██░▓██▒ ▐▌██▒░▓█▄ ▌ .` `T$P^""""" :
░░██▒██▓ ░ ████▓▒░░██████▒░▒█░ ░▓█▒░██▓░ ████▓▒░▒▒█████▓ ▒██░ ▓██░░▒████▓ ._.` _.` ;
░ ▓░▒ ▒ ░ ▒░▒░▒░ ░ ▒░▓ ░ ▒ ░ ▒ ░░▒░▒░ ▒░▒░▒░ ░▒▓▒ ▒ ▒ ░ ▒░ ▒ ▒ ▒▒▓ ▒ `-.-".-!-` ._. _.-" .-"
▒ ░ ░ ░ ▒ ▒░ ░ ░ ▒ ░ ░ ▒ ░▒░ ░ ░ ▒ ▒░ ░░▒░ ░ ░ ░ ░░ ░ ▒░ ░ ▒ ▒ `.-" _____ ._ .-"
▒ ░ ░ ░ ▒ ▒░ ░ ░ ▒ ░ ░ ▒ ░▒░ ░ ░ ▒ ▒░ ░░▒░ ░ ░ ░ ░░ ░ ▒░ ░ ▒ ▒ -(.($$$$$$$e. .
░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░░ ░░ ░ ░ ▒ ░░░ ░ ░ ░ ░ ░ ░ ░ ░ ""^^T$$$P^) .(:
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ _/ -" /. /:/;
░ ._.`-``-` `)/ /;/;
`-.-"..--"" " / / ;
Creator: Securethelogs.com | @securethelogs .-" ..--"" -` :
..--""--.-` (\ .-(\
..--"" `-\(\/;`
_. :
')
$logo
Write-Output "Let's hunt....."
Start-Sleep -Seconds 3
Write-Output ""
Write-Output "--- Anti-virus present ---"
Write-Output ""
(Get-CimInstance -Namespace root/securitycenter2 -ClassName antivirusproduct).displayName
Write-Output ""
Write-Output "--- Current logged on users ---"
Write-Output ""
(Get-CimInstance win32_LoggedOnUser).Antecedent.Name | Get-Unique
Write-Output ""
if((Get-Service WinRM).Status -ne "running"){
Write-Output "Enabling WinRM service..."
Get-Service WinRM | Set-Service -Status Running
}
Write-Output ""
try {Get-PSSession -Name "hashcheck" -ErrorAction SilentlyContinue | Remove-PSSession ; Get-Job -Name "hashcheck" -ErrorAction SilentlyContinue | Remove-Job} catch {
# No Session
}
try {Get-PSSession -Name "networkcheck" -ErrorAction SilentlyContinue | Remove-PSSession ; Get-Job -Name "networkcheck" -ErrorAction SilentlyContinue | Remove-Job} catch {
# No Session
}
try {Get-PSSession -Name "taskcheck" -ErrorAction SilentlyContinue | Remove-PSSession ; Get-Job -Name "taskcheck" -ErrorAction SilentlyContinue | Remove-Job} catch {
# No Session
}
try {Get-PSSession -Name "eventcheck" -ErrorAction SilentlyContinue | Remove-PSSession ; Get-Job -Name "eventcheck" -ErrorAction SilentlyContinue | Remove-Job} catch {
# No Session
}
# Start Sessions
$hashcheck = New-PSSession -Name "hashcheck"
$networkcheck = New-PSSession -Name "networkcheck"
$taskcheck = New-PSSession -Name "taskcheck"
$eventcheck = New-PSSession -Name "eventcheck"
if ((Get-PSSession -Name "hashcheck") -ne $null){Write-Output "Hash Scan Started..."}
if ((Get-PSSession -Name "networkcheck") -ne $null){Write-Output "Network Check Started..."}
if ((Get-PSSession -Name "taskcheck") -ne $null){Write-Output "Persistence Check Started..."}
if ((Get-PSSession -Name "eventcheck") -ne $null){Write-Output "Event Check Started..."}
Invoke-Command -Session $hashcheck -ScriptBlock {
$StopWatch = New-Object -TypeName System.Diagnostics.Stopwatch
### Edit this line ###
$tmp = "C:\temp\tmp.txt"
### Edit this line ###
(curl https://raw.githubusercontent.com/securethelogs/WolfHound/master/Hashes/md5_hashes.txt -UseBasicParsing).content | Out-File $tmp
$Hashdb = @(Get-Content $tmp)
Remove-Item -Path $tmp -Force
$badfile = @()
$qs = @((Get-ChildItem -Path C:\ -Recurse -ErrorAction SilentlyContinue).fullname | Where-Object {$_ -notlike "C:\Windows\*" -and $_ -notlike "C:\Program Files\*" -and $_ -notlike "C:\Program Files (x86)\*" -and $_ -notlike "C:\ProgramData\*"})
$qsh = @((Get-ChildItem -Path C:\ -Recurse -Hidden -ErrorAction SilentlyContinue).fullname | Where-Object {$_ -notlike "C:\Windows\*" -and $_ -notlike "C:\Program Files\*" -and $_ -notlike "C:\Program Files (x86)\*" -and $_ -notlike "C:\ProgramData\*"})
$qs +=$qsh
$fts = $qs.count
$StopWatch.Start()
foreach ($o in $qs){
### Edit this line for MD5 to Algorithm ###
$fh = (Get-FileHash -Path $o -Algorithm MD5 -ErrorAction SilentlyContinue).Hash
if(($Hashdb.Contains($fh)) -eq "True"){
$badfile += "File Location: " + $o + " | " + "Hash: " + $fh
} else {
# Move on
}
}
$StopWatch.Stop()
Write-Output "--- Hash Check Results ---"
Write-Output ""
Write-Output "Files Scanned: $fts."
$m = ($StopWatch).Elapsed.Minutes
$h = ($StopWatch).Elapsed.Hours
$s = ($StopWatch).Elapsed.Seconds
Write-Output "Scanning time: Hours: $h Mins: $m Seconds: $s"
Write-Output ""
if ($badfile -ne $null){
Write-Output "--- Hash Match Found ---"
Write-Output ""
$badfile
} else {
Write-Output "No Hash Match Found..."
}
Write-Output ""
} -AsJob -JobName "hashcheck"
Invoke-Command -Session $networkcheck -ScriptBlock {
$StopWatch = New-Object -TypeName System.Diagnostics.Stopwatch
Start-Sleep -Seconds 3
### Edit this line ###
$tmp = "C:\temp\tmp.txt"
### Edit this line ###
(curl https://raw.githubusercontent.com/securethelogs/WolfHound/master/BadIPs/IPs.txt -UseBasicParsing).content | Out-File $tmp
$badips = @(Get-Content $tmp)
Remove-Item -Path $tmp -Force
$foundips = @()
$connections = @(Get-NetTCPConnection -State Established | Where-Object {$_.LocalAddress -ne "127.0.0.1" -and $_.RemoteAddress -ne "127.0.0.1"})
$currentconnections = @()
$currentconnections += $connections.localaddress
$currentconnections += $connections.remoteaddress
Write-Output ""
Write-Output "--- Network Scan ---"
Write-Output ""
foreach ($cc in $currentconnections){
if (($badips.Contains($cc)) -eq "True"){
$foundips += $connections | Where-Object {$_.localaddress -eq $cc -or $_.remoteaddress -eq $cc}
}
}
if ($foundips -ne $null){
Write-Output "--- Matching IPs Found ---"
$foundips | Format-Table
} else {
Write-Output "No Matching IPs Found"
}
} -AsJob -JobName "networkcheck"
Invoke-Command -Session $taskcheck -ScriptBlock {
$logontasks = Get-ScheduledTask | Where-Object {$_.Triggers.CimClass -like "*TaskLogonTrigger*"}
Write-Output ""
Write-Output "--- Suspisious Scheduled Tasks Found ---"
$logontasks |Where-Object {$_.CimInstanceProperties.value.runlevel -eq "Highest" -or $_.CimInstanceProperties.value.userID -like "*system*" -and $_.State -ne "Disabled"} | Format-Table TaskPath, TaskName, State
} -AsJob -JobName "taskcheck"
Invoke-Command -Session $eventcheck -ScriptBlock {
Write-Output ""
Write-Output "--- Failed Logon Events ---"
Write-Output ""
Get-EventLog -LogName Security -InstanceId "4625"
Write-Output ""
Write-Output "-- Bitsadmin Downloaded File Events ---"
Write-Output ""
$bits = Get-WinEvent -LogName Microsoft-Windows-Bits-Client/Operational | Where-Object {$_.id -eq "59" -and $_.message -like "*http*" -and $_.message -like "*started*"}
$bits | Where-Object {$_.message -like "*.ps1*" -or $_.message -like "*.bat*" -or $_.message -like "*.exe*" -or $_.message -like "*.vbs*"} | Format-Table
Write-Output ""
Write-Output "-- Suspicious Powershell Events ---"
$ps = Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" | Where-Object {$_.id -eq "4104"}
$ps | Where-Object {$_.message -like "*invoke-command*" -or $_.message -like "*-enc*" -or $_.message -like "*bypass*" -or $_.message -like "*-noin*" -or $_.message -like "*certutil -urlcache*" } | Format-Table
} -AsJob -JobName "eventcheck"
Write-Output ""
Receive-Job -Name "networkcheck" -Wait -Force -AutoRemoveJob
Write-Output ""
Receive-Job -Name "taskcheck" -Wait -Force -AutoRemoveJob
Write-Output ""
Receive-Job -Name "eventcheck" -Wait -Force -AutoRemoveJob
Write-Output ""
Receive-Job -Name "hashcheck" -Wait -Force -AutoRemoveJob
# Cleanup
Get-PSSession -Name "hashcheck" -ErrorAction SilentlyContinue | Remove-PSSession
Get-PSSession -Name "networkcheck" -ErrorAction SilentlyContinue | Remove-PSSession
Get-PSSession -Name "taskcheck" -ErrorAction SilentlyContinue | Remove-PSSession
Get-PSSession -Name "eventcheck" -ErrorAction SilentlyContinue | Remove-PSSession
Write-Output ""
$endwinrm = Read-Host -Prompt "Would you like to end WinRm service? (y/n) "
if ($endwinrm -eq "y"){
Get-Service WinRM | Set-Service -Status Stopped
}