This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
forked from D4rk5t0rM/RemoteAcquisition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xdr-collectkit.ps1
323 lines (262 loc) · 10.1 KB
/
xdr-collectkit.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
$Command=$args[0]
function Get-Version {
Write-Output " ____ _ _ _ _ ___ _ "
Write-Output " / ___|___ | | | ___ ___| |_| |/ (_) |_ "
Write-Output "| | / _ \| | |/ _ \/ __| __| ' /| | __| "
Write-Output "| |__| (_) | | | __/ (__| |_| . \| | |_ "
Write-Output " \____\___/|_|_|\___|\___|\__|_|\_\_|\__| "
Write-Output ""
Write-Output "Author: Nicholas Dhaeyer - [email protected] - @DhaeyerWolf"
Write-Output "V2022-10-05"
}
function help {
<#
.NOTES
Author: [email protected]
Updated: 2022-05-25
Summary: Gives you the instructions
#>
Get-Version
Write-Output ""
Write-Output ""
Write-Output "Usage: 'PowerShell -ep bypass ./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 "===== 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: [email protected]
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 ./
}
function RL-Win-Basic {
<#
.NOTES
Author: [email protected]
Updated: 2022-05-25
Summary: Runs a Basic Fast redline script for windows: Memory, Network, Services, Tasks, Persitence, Users.
Usage: 'PowerShell -ep bypass ./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: [email protected]
Updated: 2022-05-25
Summary: Runs a redline Windows script that gets Memory, Network, Services & Tasks.
Usage: 'PowerShell -ep bypass ./collectkit RL-Win-Mem-Fast'
#>
Redline -URL "https://github.com/D4rk5t0rM/RemoteAcquisition/raw/main/RedlineCaptures/Redline-Win-Memory-Fast.zip"
}
function Redline([string]$URL) {
<#
.NOTES
Author: [email protected]
Updated: 2022-05-25
Summary: Uses redeline A redline script defined in a RL-* command. - Do not run this on it's own
Usage: 'PowerShell -ep bypass ./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: [email protected]
Updated: 2022-05-23
Summary: Gets a Memdump of the host.
Usage: 'PowerShell -ep bypass ./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: [email protected]
Updated: 2022-05-25
Summary: Dumps a process according to procdump arguments
Usage: 'PowerShell -ep bypass ./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: [email protected]
Updated: 2022-05-23
Summary: Gets Lists & gets the user's browser extentions.
Usage: 'PowerShell -ep bypass ./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: [email protected]
Updated: 2022-10-05
Summary: Gets a ZIP file of all files of a browser on a system
Usage: 'PowerShell -ep bypass ./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: [email protected]
Updated: 2022-10-05
Summary: Gets Lists & gets the user's browser extentions.
Usage: PowerShell -ep bypass ./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
}
# Remediation actions
function Remediate-Item {
<#
.NOTES
Author: [email protected]
Updated: 2022-09-09
Summary: emoves a given file/folder by using 'Remove-Item -Recurse -Force [dir/file]'
Usage: 'PowerShell -ep bypass ./collectkit rm [dir/file]' full path is required
#>
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: [email protected]
Updated: 2022-05-22
Summary: Removes the collection file. should be run after the Get-* commands
Usage: 'PowerShell -ep bypass ./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