-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcollectkit
More file actions
422 lines (334 loc) · 12.8 KB
/
collectkit
File metadata and controls
422 lines (334 loc) · 12.8 KB
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
Param(
[parameter(Position = 0)] [String] $Command,
[parameter(Position = 1)] [String] $Arg1
)
function Get-Version {
Write-Output " ____ _ _ _ _ ___ _ "
Write-Output " / ___|___ | | | ___ ___| |_| |/ (_) |_ "
Write-Output "| | / _ \| | |/ _ \/ __| __| ' /| | __| "
Write-Output "| |__| (_) | | | __/ (__| |_| . \| | |_ "
Write-Output " \____\___/|_|_|\___|\___|\__|_|\_\_|\__| "
Write-Output ""
Write-Output "Author: Nicholas Dhaeyer - nicholas.dhaeyer@nviso.eu | @DhaeyerWolf"
Write-Output "V2024-10-10"
}
function help {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-25
Summary: Gives you the instructions
#>
Get-Version
Write-Output ""
Write-Output ""
Write-Output "Usage: 'run collectkit [Command] [argument]'"
Write-Output ""
Write-Output "Possible commands:"
Write-Output "------------------"
Write-Output ""
Write-Output "===== COLLECTION ====="
Write-Output "- Redline Captures -"
Write-Output "RL-Win-Basic: Runs a Basic Fast redline script for windows: Memory, Network, Services, Tasks, Persitence, Users. - collection can take longer depending on how much calculations are needed."
Write-Output "RL-Win-Mem-Fast:Runs a redline Windows script that gets Memory, Network, Services & Tasks. - collection can take longer depending on how much calculations are needed."
Write-Output ""
Write-Output "- Memory Captures -"
Write-Output "Get-Mem: Makes a Memdump. Can take longer depending on how much memory the system has. 8GB RAM can take up to 15+ min."
Write-Output "Get-Proc: Makes a dump of a process using procdump. Usage: <run collectkit 'Get-Proc <procID|procName>'>"
Write-Output ""
Write-Output "- Browser Captures -"
Write-Output "Get-Extentions: Gets Lists & gets the user's browser extentions. - Only Chrome supported (for now) "
Write-Output "Get-BrowserFiles: Get all files stored by a browser currently supported: IE, MS Edge, Chrome, Firefox "
Write-Output ""
Write-Output "- List Files -"
Write-Output "List-DefaultFolder:Lists the files in the folder C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Downloads\"
Write-Output "Get-Folder: Zips the specified folder and makes it available for download (default MDE download size is max 3GB)"
Write-Output ""
Write-Output "- Other collections -"
Write-Output "Get-Basic-Info:
- runs a modified version of mamun-sec dfirt tool
- runs nov3mb3r's trident tool
- Gets PowerShell history of all users "
Write-Output ""
Write-Output "===== REMEDIATION ====="
Write-Output "Remediate-Item: removes a given file/folder by using 'Remove-Item -Recurse -Force [dir/file]'"
Write-Output ""
Write-Output "===== CLEANUP ====="
Write-Output "Rm-Collection: Removes the collection.zip file used in all collections."
## TODO:
List-DefaultFolder
}
# Default folder listing display
function List-DefaultFolder{
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-10-05
Summary: Lists the files in the folder C:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Downloads\
Usage: 'run collectkit List-DefaultFolder'
#>
Write-Output ""
Write-Output ""
Write-Output "
+++++++++++++++++++++++++++++++++++++++++++++
+ Current Files in the default folder: +
+ C:\ProgramData\Microsoft\Windows Defender +
+ Advanced Threat Protection\Downloads\ +
+++++++++++++++++++++++++++++++++++++++++++++"
Get-ChildItem ./
}
# Redline Captures
function RL-Win-Basic {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-25
Summary: Runs a Basic Fast redline script for windows: Memory, Network, Services, Tasks, Persitence, Users.
Usage: 'run collectkit RL-Win-Basic'
#>
Redline -URL "https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/RedlineCaptures/Redline-Win-Basic.zip"
}
function RL-Win-Mem-Fast {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-25
Summary: Runs a redline Windows script that gets Memory, Network, Services & Tasks.
Usage: 'run collectkit RL-Win-Mem-Fast'
#>
Redline -URL "https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/RedlineCaptures/Redline-Win-Memory-Fast.zip"
}
function RL-Full-Disk {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2024-10-10
Summary: Runs a redline Windows script that gets Memory, Network, Services & Tasks.
Usage: 'run collectkit RL-Full-Disk
#>
Redline -URL "https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/RedlineCaptures/Redline-Basic+fullDiskEnum.zip"
}
# Collections
function Redline([string]$URL) {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-25
Summary: Uses redeline A redline script defined in a RL-* command. - Do not run this on it's own
Usage: 'run collectkit RL-[Redline Script]'
#>
# Download & Unpack:
Write-Output "Downloading $URL"
Start-BitsTransfer -Source $URL -Destination Redline.zip
Expand-Archive Redline.zip -Force
# Execution:
start .\Redline\RunRedlineAudit.bat -Wait
# Needed to collect the created sessions
#Start-Sleep -Seconds $timeout
Compress-Archive -path .\Redline\Sessions\ .\collection.zip -CompressionLevel optimal -Force
Write-Output "Please collect the file collection.zip. Run: getfile '$(pwd)\collection.zip'"
Write-Output "To clean up the collection file run: <run collectkit Rm-Collection>"
List-DefaultFolder
}
function Get-Mem {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-23
Summary: Gets a Memdump of the host.
Usage: 'run collectkit Get-Mem'
#>
$hostname = hostname
# Download:
Start-BitsTransfer -Source https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/Setup/7z.exe -Destination 7z.exe
Start-BitsTransfer -Source https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/Setup/winpmem_mini_x64_rc2.exe -Destination winpmem.exe
Start-BitsTransfer -Source https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/Setup/7z.dll -Destination 7z.dll
# Create Memdump:
.\winpmem.exe .\$hostname-Memdump.raw
#Zip if bigger than 3GB - limit of MDE getfile command
if((Get-Item .\$hostname-Memdump.raw).length -gt 3GB) {
.\7z.exe a -tzip .\$hostname-Memdump.zip .\$hostname-Memdump.raw
Write-Output "run command: <getfile '$(pwd)\$hostname-Memdump.zip'>"
}
else{
Write-Output "run command: <getfile '$(pwd)\$hostname-Memdump.raw'>"
}
List-DefaultFolder
}
function Get-Proc {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-25
Summary: Dumps a process according to procdump arguments
Usage: 'run collectkit "Get-Proc [process name/id]"'
#>
# Download:
Start-BitsTransfer -Source https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/Setup/procdump64.exe -Destination procdump64.exe
if ([System.IO.File]::Exists(".\7z.exe")){
Start-BitsTransfer -Source https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/Setup/7z.exe -Destination 7z.exe}
if ([System.IO.File]::Exists(".\7z.dll")){
Start-BitsTransfer -Source https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/Setup/7z.dll -Destination 7z.dll}
# Create ProcDump:
.\procdump64.exe $Arg1 -ma -o proc-$Arg1.dmp /accepteula
#Zip if bigger than 3GB - limit of MDE getfile command
if((Get-Item .\proc-$Arg1.dmp).length -gt 200MB) {
.\7z.exe a -tzip .\proc-$Arg1.zip .\proc-$Arg1.dmp
Write-Output "run command: <getfile '$(pwd)\proc-$Arg1.zip'>"
}
else{
Write-Output "run command: <getfile '$(pwd)\proc-$Arg1.dmp'>"
}
List-DefaultFolder
}
function Get-Extentions {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-23
Summary: Gets Lists & gets the user's browser extentions.
Usage: 'run collectkit Get-Extentions'
#>
# Chrome
$chrome = @()
$chromeTmp = New-Object System.Collections.Generic.List[System.Object]
foreach($User in Get-ChildItem c:\Users\){
$chromeTmp.Add("C:\Users\$User\AppData\Local\Google\Chrome\User Data\Default\Extensions\")
}
$chromeTmp.ToArray()
foreach($path in $chromeTmp){
if(Test-Path -Path $path){
$chrome += $path
}
}
foreach($path in $chrome){
Get-ChildItem $path
}
Compress-Archive -path $chrome .\Chrome-Extentions.zip -CompressionLevel optimal
Write-Output ""
Write-Output "Please collect the file .\Chrome-Extentions.zip Run: getfile '$(pwd)\Chrome-Extentions.zip'"
List-DefaultFolder
}
function Get-BrowserFiles {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-10-05
Summary: Gets a ZIP file of all files of a browser on a system
Usage: 'run collectkit Get-BrowserFiles'
#>
# Setup
Start-BitsTransfer -Source https://raw.githubusercontent.com/D4rk5t0rM/RemoteAcquisition/main/Setup/CollectBrowserfiles.cmd -Destination CollectBrowserfiles.cmd
# Execution
cmd.exe /c CollectBrowserfiles.cmd
Compress-Archive -path .\Browser_Files .\Browser_Files.zip -CompressionLevel optimal
# Cleanup
Remove-Item -Recurse -Force .\Browser_Files
Remove-Item -Recurse -Force .\CollectBrowserfiles.cmd
Write-Output "Please collect the file .\Browser_Files.zip Run: getfile '$(pwd)\Browser_Files.zip'"
List-DefaultFolder
}
function Get-Folder {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-10-05
Summary: Gets Lists & gets the user's browser extentions.
Usage: run collectkit "Get-Folder '<folderpath>'"
#>
$OutputFile = $Arg1.Split("\")[-1]
$OutputFile
Compress-Archive -path $Arg1 .\"$OutputFile".zip -CompressionLevel optimal
Write-Output "Please collect the file .\$OutputFile.zip Run: getfile '$(pwd)\$OutputFile.zip'"
List-DefaultFolder
}
# Run external scripts
function Get-Basic-Info {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-10-05
Summary:- runs a modified version of mamun-sec dfirt tool
- runs nov3mb3r's trident tool
- Gets PowerShell history of all users
Usage: 'run collectkit Get-Basic-Info"
#>
# Default setup
mkdir .\Basic-Info
# dfirt
## Setup
Start-BitsTransfer -Source https://raw.githubusercontent.com/D4rk5t0rM/Forensics-tools/main/.scripts/dfirt.ps1 -Destination .\dfirt.ps1
## Execution
PowerShell -ep bypass .\dfirt.ps1
## prepare export
Move-Item .\report.txt .\Basic-Info\dfirt_$(hostname).txt
Get-Content .\Basic-Info\dfirt_$(hostname).txt
# Trident
## Setup
Start-BitsTransfer -Source https://raw.githubusercontent.com/nov3mb3r/trident/main/trident.ps1 -Destination .\trident.ps1
## Execution
PowerShell -ep bypass .\trident.ps1
# prepare export
Move-Item .\trident_$(hostname).txt .\Basic-Info\trident_$(hostname).txt
Get-Content .\Basic-Info\trident_$(hostname).txt
# Powershell History
foreach ($u in $(get-localuser | % {$_.Name})){
Copy-Item c:\Users\$u\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt .\Basic-Info\"$u"_PowershellHistory.txt 2> .\error.txt
Write-Output "
+++++++++++++++++++++++++++++
+ Powerhsell History for: +
+ $u
+++++++++++++++++++++++++++++
"
Get-Content .\Basic-Info\"$u"_PowershellHistory.txt
}
# --------------------
# Collection
Compress-Archive -path .\Basic-Info .\Basic-Info.zip -CompressionLevel optimal
Write-Output "Please collect the file .\Basic-Info.zip Run: getfile '$(pwd)\Basic-Info.zip'"
# Cleanup
Remove-Item -Recurse -Force .\dfirt.ps1
Remove-Item -Recurse -Force .\trident.ps1
Remove-Item -Recurse -Force .\Basic-Info
Remove-Item -Recurse -Force .\error.txt
List-DefaultFolder
}
# Remediation actions
function Remediate-Item {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-09-09
Summary: emoves a given file/folder by using 'Remove-Item -Recurse -Force [dir/file]'
Usage: 'run collectkit "rm [dir/file]"' full path is required. full path with spaces, use "rm '[path]'"
#>
Remove-Item -Recurse -Force $Arg1
Write-Output "Executed the command"
Write-Output "Files left on disk: ...."
Get-ChildItem $(Split-Path -Path $Arg1)
}
# Cleanup:
function Rm-Collection {
<#
.NOTES
Author: nicholas.dhaeyer@nviso.eu | @DhaeyerWolf
Updated: 2022-05-22
Summary: Removes the collection file. should be run after the Get-* commands
Usage: 'run collectkit Rm-Collection'
#>
Remove-Item -Recurse -Force *
Write-Output "Done! following files are still on disk:"
List-DefaultFolder
}
Function Invoke-CollectKit {
$available = (Get-ChildItem function: | Where-Object CommandType -EQ "Function" | Where-Object Helpfile -EQ $null | Where-Object Source -EQ "" | Where-Object Name -NE "Invoke-CollectKit").Name
if ($available.Contains($Command)) {
&$Command
} else {
Write-Output "Valid remediation actions are:"
ForEach ($c in $available) {
Write-Output $c
}
}
}
Invoke-CollectKit