-
Notifications
You must be signed in to change notification settings - Fork 8
/
IRCP-Lab-Multi.ps1
358 lines (345 loc) · 17.9 KB
/
IRCP-Lab-Multi.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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<######################################################################
Incident Response Collection Protocol (IRCP)
Multi-Image Version
! Edit the KAPE parsers below depending on investigational needs!
! For multiple KAPE parsers use a comma to seperate the values !
#######################################################################>
####################### KAPE Targets & Modules ########################
$kapeTargets = "!SANS_Triage"
$kapeModules = "!EZParser,Chainsaw"
#######################################################################
####### TRANSCRIPT AND TITLE
Start-Transcript .\ircpMultiConsole.log | out-null
Clear-Host
$ircp = "@
`$`$`$`$`$`$\ `$`$`$`$`$`$`$\ `$`$`$`$`$`$\ `$`$`$`$`$`$`$\
\_`$`$ _|`$`$ __`$`$\ `$`$ __`$`$\ `$`$ __`$`$\
`$`$ | `$`$ | `$`$ |`$`$ / \__|`$`$ | `$`$ |
`$`$ | `$`$`$`$`$`$`$ |`$`$ | `$`$`$`$`$`$`$ |
`$`$ | `$`$ __`$`$ `$`$ | `$`$ ____/
`$`$ | `$`$ | `$`$ |`$`$ | `$`$\ `$`$ |
`$`$`$`$`$`$\ `$`$ | `$`$ |\`$`$`$`$`$`$ |`$`$ |
\______|\__| \__| \______/ \__|
@"
Write-Host $ircp
Write-Host -ForegroundColor Yellow "============ Incident Response Collection Protocol ============"
Write-Host ""
####### VARIABLE DECLARATION & TARGET DRIVE SELECTION
Write-Host -ForegroundColor Yellow "============ Select the Target Drive"
Write-Host ""
Start-Sleep -Seconds 2
Add-Type -AssemblyName System.Windows.Forms
$browser = New-Object System.Windows.Forms.FolderBrowserDialog
$browser.RootFolder = 'MyComputer'
$browser.Description = "Select the Target Drive"
$null = $browser.ShowDialog()
$targetDrives = $browser.SelectedPath
$Drives = (Get-WmiObject -Query "Select * from Win32_LogicalDisk")
$e01Images = Get-ChildItem -Path $targetDrives -include *.e01 -recurse -File
$vmdkImages = Get-ChildItem -Path $targetDrives -include *.vmdk -recurse -File
$vhdImages = Get-ChildItem -Path $targetDrives -include *.vhd -recurse -File
$vhdxImages = Get-ChildItem -Path $targetDrives -include *.vhdx -recurse -File
Write-Host -ForegroundColor Yellow "============ $targetDrives Selected"
Write-Host ""
Start-Sleep -Seconds 1
Write-Host -ForegroundColor Yellow "============ Searching $targetDrives for Images"
####### E01 LOGIC
foreach ($e01 in $e01Images)
{
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
$DriveLetter = $null
Write-Host ""
Write-Host "Found Image - $($e01.basename)"
Write-Host ""
Start-Sleep -Seconds 1
$PathExists = Test-Path Evidence
If ($PathExists -eq $false) {
mkdir Evidence | Out-Null }
Set-Location Evidence
$PathExists = Test-Path $e01.basename
If ($PathExists -eq $false) {
mkdir $e01.basename | Out-Null }
$PathExists = Test-Path "$($e01.basename)\Modules"
If ($PathExists -eq $false) {
mkdir "$($e01.basename)\Modules" | Out-Null }
$PathExists = Test-Path "$($e01.basename)\Targets"
If ($PathExists -eq $false) {
mkdir "$($e01.basename)\Targets" | Out-Null }
Set-Location ..
Write-Host -ForegroundColor Yellow "============ Evidence Collection Folders Created"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($e01.basename)\Targets"
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($e01.basename)\Modules"
Write-Host ""
Start-Sleep -Seconds 1
if ($e01 -Like "*.e01")
{
Write-Host -ForegroundColor Yellow "============ Mounting E01 Image"
Write-Host ""
.\arsenal\aim_cli.exe /mount /readonly /filename=$e01 /provider=libewf /background
Start-Sleep -Seconds 5
}
:e01 while($true)
{
$DrivesCountNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
if ($DrivesCount -ne $DrivesCountNew)
{
$DrivesNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk")
$DriveLetter = Compare-Object -ReferenceObject $Drives -DifferenceObject $DrivesNew | Select-Object -ExpandProperty InputObject | Select-Object -ExpandProperty DeviceId
if (!($null -eq $DriveLetter))
{
Write-host "Image mounted as $DriveLetter"
foreach ($OSDriveLetter in $DriveLetter)
{
if (Test-Path "${OSDriveLetter}\windows\system32")
{
Write-Host "Operating System Drive is ${OSDriveLetter}"
Write-Host ""
}
}
}
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
Write-Host -ForegroundColor Yellow "============ Executing KAPE on $OSDriveLetter Drive for $($e01.basename)"
Write-Host ""
KAPE\kape.exe --ifw --tsource $OSDriveLetter --tdest Evidence\"$($e01.basename)"\Targets --target $kapeTargets --zip target --module $kapeModules,RECmd_BasicSystemInfo --msource Evidence\"$($e01.basename)"\Targets\$drive --mdest Evidence\"$($e01.basename)"\Modules
Write-Host -ForegroundColor Yellow "============ KAPE Completed on $OSDriveLetter Drive for $($e01.basename)"
Write-Host ""
.\arsenal\aim_cli.exe /dismount /force
Write-Host ""
Write-Host -ForegroundColor Yellow "============ $OSDriveLetter Drive Dismounted"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ IRCP Completed on $OSDriveLetter Drive for $($e01.basename)"
Move-Item -Path .\Evidence\$($e01.basename)\Modules\Registry\*_BasicSystemInfo_Output.csv .\Evidence\$($e01.basename)\TargetSystemInfo.csv
Move-Item -Path .\Evidence\$($e01.basename)\Modules\*.txt -Destination .\Evidence\$($e01.basename)\kapeModules.log
Move-Item -Path .\Evidence\$($e01.basename)\Targets\*.txt -Destination .\Evidence\$($e01.basename)\kapeTargets.log
Start-Sleep -Seconds 5
break
}
}
}
####### VMDK LOGIC
foreach ($vmdk in $vmdkImages)
{
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
$DriveLetter = $null
Write-Host ""
Write-Host "Found Image - $($vmdk.basename)"
Write-Host ""
Start-Sleep -Seconds 1
if ($vmdk -Like "*.vmdk" -And $vmdk.length -lt 3000)
{
$PathExists = Test-Path Evidence
If ($PathExists -eq $false) {
mkdir Evidence | Out-Null }
Set-Location Evidence
$PathExists = Test-Path $($vmdk.basename)
If ($PathExists -eq $false) {
mkdir $vmdk.basename | Out-Null }
$PathExists = Test-Path "$($vmdk.basename)\Modules"
If ($PathExists -eq $false) {
mkdir "$($vmdk.basename)\Modules" | Out-Null }
$PathExists = Test-Path "$($vmdk.basename)\Targets"
If ($PathExists -eq $false) {
mkdir "$($vmdk.basename)\Targets" | Out-Null }
Set-Location ..
Start-Sleep -Seconds 2
Write-Host ""
Write-Host -ForegroundColor Yellow "============ Evidence Collection Folders Created"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($vmdk.basename)\Targets"
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($vmdk.basename)\Modules"
Write-Host ""
Start-Sleep -Seconds 1
Write-Host -ForegroundColor Yellow "============ Mounting VMDK Image"
Write-Host ""
.\arsenal\aim_cli.exe /mount /readonly /filename=$vmdk /provider=DiscUtils /background
Start-Sleep -Seconds 5
}
:vmdk while($vmdk -Like "*.vmdk" -And $vmdk.length -lt 3000)
{
$DrivesCountNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
if ($DrivesCount -ne $DrivesCountNew)
{
$DrivesNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk")
$DriveLetter = Compare-Object -ReferenceObject $Drives -DifferenceObject $DrivesNew | Select-Object -ExpandProperty InputObject | Select-Object -ExpandProperty DeviceId
if (!($null -eq $DriveLetter))
{
Write-host "Image mounted as $DriveLetter"
foreach ($OSDriveLetter in $DriveLetter)
{
if (Test-Path "${OSDriveLetter}\windows\system32")
{
Write-Host "Operating System Drive is ${OSDriveLetter} Drive"
Write-Host ""
}
}
}
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
Write-Host -ForegroundColor Yellow "============ Executing KAPE on $OSDriveLetter Drive for $($vmdk.basename)"
Write-Host ""
KAPE\kape.exe --ifw --tsource $OSDriveLetter --tdest Evidence\"$($vmdk.basename)"\Targets --target $kapeTargets --zip target --module $kapeModules,RECmd_BasicSystemInfo --msource Evidence\"$($vmdk.basename)"\Targets\$drive --mdest Evidence\"$($vmdk.basename)"\Modules
Write-Host -ForegroundColor Yellow "============ KAPE Complete on $OSD Drive for $($vmdk.basename)"
Write-Host ""
.\arsenal\aim_cli.exe /dismount /force
Write-Host ""
Write-Host -ForegroundColor Yellow "============ $DriveLetter Dismounted"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ IRCP Complete on $OSDriveLetter Drive for $($vmdk.basename)"
Move-Item -Path .\Evidence\$($vmdk.basename)\Modules\*.txt -Destination .\Evidence\$($vmdk.basename)\kapeModules.log
Move-Item -Path .\Evidence\$($vmdk.basename)\Targets\*.txt -Destination .\Evidence\$($vmdk.basename)\kapeTargets.log
Move-Item -Path .\Evidence\$($vmdk.basename)\Modules\Registry\*_BasicSystemInfo_Output.csv .\Evidence\$($vmdk.basename)\TargetSystemInfo.csv
Start-Sleep -Seconds 5
break
}
}
}
####### VHD LOGIC
foreach ($vhd in $vhdImages)
{
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
$DriveLetter = $null
Write-Host ""
Write-Host "Found Image - $($vhd.basename)"
Write-Host ""
Start-Sleep -Seconds 1
$PathExists = Test-Path Evidence
If ($PathExists -eq $false) {
mkdir Evidence | Out-Null }
Set-Location Evidence
$PathExists = Test-Path $vhd.basename
If ($PathExists -eq $false) {
mkdir $vhd.basename | Out-Null }
$PathExists = Test-Path "$($vhd.basename)\Modules"
If ($PathExists -eq $false) {
mkdir "$($vhd.basename)\Modules" | Out-Null}
$PathExists = Test-Path "$($vhd.basename)\Targets"
If ($PathExists -eq $false) {
mkdir "$($vhd.basename)\Targets" | Out-Null}
Set-Location ..
Write-Host -ForegroundColor Yellow "============ Evidence Collection Folders Created"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($vhd.basename)\Targets"
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($vhd.basename)\Modules"
Write-Host ""
Start-Sleep -Seconds 1
if ($vhd -Like "*.vhd")
{
Write-Host -ForegroundColor Yellow "============ Mounting VHD Image"
Write-Host ""
.\arsenal\aim_cli.exe /mount /readonly /filename=$vhd /provider=DiscUtils /background
}
:vhd while($true)
{
$DrivesCountNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
if ($DrivesCount -ne $DrivesCountNew)
{
$DrivesNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk")
$DriveLetter = Compare-Object -ReferenceObject $Drives -DifferenceObject $DrivesNew | Select-Object -ExpandProperty InputObject | Select-Object -ExpandProperty DeviceId
if (!($null -eq $DriveLetter))
{
Write-host "Image mounted as $DriveLetter"
foreach ($OSDriveLetter in $DriveLetter)
{
if (Test-Path "${OSDriveLetter}\windows\system32")
{
Write-Host "Operating System Drive is ${OSDriveLetter}"
Write-Host ""
}
}
}
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
Write-Host -ForegroundColor Yellow "============ Executing KAPE on $OSDriveLetter Drive for $($vhd.basename)"
Write-Host ""
KAPE\kape.exe --ifw --tsource $OSDriveLetter --tdest Evidence\"$($vhd.basename)"\Targets --target $kapeTargets --zip target --module $kapeModules,RECmd_BasicSystemInfo --msource Evidence\"$($vhd.basename)"\Targets\$drive --mdest Evidence\"$($vhd.basename)"\Modules
Write-Host -ForegroundColor Yellow "============ KAPE Completed on $OSDriveLetter Drive for $($vhd.basename)"
Write-Host ""
.\arsenal\aim_cli.exe /dismount /force
Write-Host ""
Write-Host -ForegroundColor Yellow "============ $OSDriveLetter Drive Dismounted"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ KAPE Complete on $OSDriveLetter Drive for $($vhd.basename)"
Move-Item -Path .\Evidence\$($vhd.basename)\Modules\Registry\*_BasicSystemInfo_Output.csv .\Evidence\$($vhd.basename)\TargetSystemInfo.csv
Move-Item -Path .\Evidence\$($vhd.basename)\Modules\*.txt -Destination .\Evidence\$($vhd.basename)\kapeModules.log
Move-Item -Path .\Evidence\$($vhd.basename)\Targets\*.txt -Destination .\Evidence\$($vhd.basename)\kapeTargets.log
Start-Sleep -Seconds 5
break
}
}
}
####### VHDX LOGIC
foreach ($vhdx in $vhdxImages)
{
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
$DriveLetter = $null
Write-Host ""
Write-Host "Found Image - $($vhdx.basename)"
Write-Host ""
Start-Sleep -Seconds 1
$PathExists = Test-Path Evidence
If ($PathExists -eq $false) {
mkdir Evidence | Out-Null }
Set-Location Evidence
$PathExists = Test-Path $($vhdx.basename)
If ($PathExists -eq $false) {
mkdir \$($vhdx.basename) | Out-Null }
$PathExists = Test-Path "$($vhdx.basename)\Modules"
If ($PathExists -eq $false) {
mkdir "$($vhdx.basename)\Modules" | Out-Null}
$PathExists = Test-Path "$($vhdx.basename)\Targets"
If ($PathExists -eq $false) {
mkdir "$($vhdx.basename)\Targets" | Out-Null}
Set-Location ..
Write-Host -ForegroundColor Yellow "============ Evidence Collection Folders Created"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($vhdx.basename)\Targets"
Write-Host -ForegroundColor Yellow "============ .\Evidence\$($vhdx.basename)\Modules"
Write-Host ""
Start-Sleep -Seconds 1
if ($vhdx -Like "*.vhdx")
{
Write-Host -ForegroundColor Yellow "============ Mounting VHDX Image"
Write-Host ""
.\arsenal\aim_cli.exe /mount /readonly /filename=$vhdx /provider=DiscUtils /background
}
:vhdx while($true)
{
$DrivesCountNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
if ($DrivesCount -ne $DrivesCountNew)
{
$DrivesNew = (Get-WmiObject -Query "Select * from Win32_LogicalDisk")
$DriveLetter = Compare-Object -ReferenceObject $Drives -DifferenceObject $DrivesNew | Select-Object -ExpandProperty InputObject | Select-Object -ExpandProperty DeviceId
if (!($null -eq $DriveLetter))
{
Write-host "Image mounted as $DriveLetter"
foreach ($OSDriveLetter in $DriveLetter)
{
if (Test-Path "${OSDriveLetter}\windows\system32")
{
Write-Host "Operating System Drive is ${OSDriveLetter}"
Write-Host ""
}
}
}
$DrivesCount = (Get-WmiObject -Query "Select * from Win32_LogicalDisk").Count
Write-Host -ForegroundColor Yellow "============ Executing KAPE on $OSDriveLetter Drive for $($vhdx.basename)"
Write-Host ""
KAPE\kape.exe --ifw --tsource $OSDriveLetter --tdest Evidence\"$($vhdx.basename)"\Targets --target $kapeTargets --zip target --module $kapeModules,RECmd_BasicSystemInfo --msource Evidence\"$($vhdx.basename)"\Targets\$drive --mdest Evidence\"$($vhdx.basename)"\Modules
Write-Host -ForegroundColor Yellow "============ KAPE Completed on $OSDriveLetter Drive for $($vhdx.basename)"
Write-Host ""
.\arsenal\aim_cli.exe /dismount /force
Write-Host ""
Write-Host -ForegroundColor Yellow "============ $OSDriveLetter Dismounted"
Write-Host ""
Write-Host -ForegroundColor Yellow "============ KAPE Complete on $OSDriveLetter Drive for $($vhdx.basename)"
Move-Item -Path .\Evidence\$($vhdx.basename)\Modules\Registry\*_BasicSystemInfo_Output.csv .\Evidence\$($vhdx.basename)\TargetSystemInfo.csv
Move-Item -Path .\Evidence\$($vhdx.basename)\Modules\*.txt -Destination .\Evidence\$($vhdx.basename)\kapeModules.log
Move-Item -Path .\Evidence\$($vhdx.basename)\Targets\*.txt -Destination .\Evidence\$($vhdx.basename)\kapeTargets.log
Start-Sleep -Seconds 5
break
}
}
}
####### TRANSCRIPT AUDIT
Stop-Transcript | Out-Null
Move-Item -Path .\ircpMultiConsole.log -Destination .\Evidence\ircpMultiLabConsole.log
Write-Host -ForegroundColor Yellow "============ Incident Response Collector Protocol Completed Collection ============"