取证闲谈_

admin 2024年3月27日18:11:52评论13 views字数 10267阅读34分13秒阅读模式

取证闲谈_

免责声明

请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。一旦造成后果请自行承担!如有侵权烦请告知,我们会立即删除并致歉。谢谢!

前言

聊到取证,可以分为活取证和死取证,我们通常所说的活取证是指在主机存活时发现系统被入侵,直接快速的把机器的运行内存dump下来,对运行内存进行分析取证,手机犯罪证据;而死取证通常是指对机器的磁盘做镜像之后分析的取证方法,用于在关机后制作硬盘镜像,通过分析镜像来做取证工作,相比于死取证,活取证是更加的重要,能够获取到当前系统第一手资料与证据,对于整个案件起到了至关重要的作用。一般情况下,在案件现场中,大多数还是windows系统的普通机器,不论是个人笔记本还是办公机房主机等等,但是涉案如果是服务器,则大多数可能以linux系统为主,并且如果现场涉案机器是关机状态下直接做磁盘镜像等操作就可以,但如果是开机状态下,在保护现场的情况下,还要考虑提取系统的网络、进程等数据,以及制作内存镜像等操作

Linux服务器取证

首先需要提取系统的网络,进程,日志等数据

1
2
3
提取所有的IPv4、v6数据:lsof -i>lsof-i.txt
提取所有的进程数据:lsof -K>lsof-K.txt
截获当前正在运行的机器1000帧(根据实际情况而定)数据包:tcpdump -i any -c 1000 -w capture01.cap
STYLUS

取证闲谈_

取证闲谈_

取证闲谈_

1
2
打包/var/log下的所有数据:tar -zcPf var-log.tar /var/log/*
打包root用户:tar -zcPf bash-history.tar /root/.bash_history
ARCADE

取证闲谈_

然后需要采集设备的内存镜像,如果是CentOS,Red Hat系列的Linux系统,推荐使用LiME,它是是一种可加载的内核模块(LKM),如果是Debian和Ubuntu系列的Linux系统,推荐使用fmem
LiME下载地址:https://github.com/504ensicsLabs/LiME
fmem下载地址:https://github.com/NateBrune/fmem

取证闲谈_

取证闲谈_

最后制作设备的磁盘镜像,可以使用dd进行制作,不过dd只能做raw格式的镜像文件,并且需要考虑磁盘的剩余空间,如果空间不足可以保存到外置的USB设备里面

1
2
3
4
5
6
7
8
9
10
11
12
1、本地取数据

fdisk -l # 查看磁盘及分区
dd if=需要拷贝的磁盘 of=/存储目录/镜像文件 (确保存储目录有足够的空间) # 获取整个磁盘镜像文件

2、远程取硬盘数据

# 取证机器 B 上运行
nc -l -p 4445 | dd of=/tmp/sda2.dd

# 受害机器 A 上执行传输,即可完成从受害机器 A 克隆 sda 硬盘到取证机器 B 的任务:
dd if=/dev/sda2 | nc 192.168.10.11 4445
BASH

取证闲谈_

也可以使用ftkimager,可以制作DD和E01格式的镜像文件
工具下载地址https://accessdata.com/product-download

取证闲谈_

内存取证

接下来聊聊内存取证,获取到物理内存之后,接下来的工作就是要对镜像文件进行取证分析,从中提取有用的证据,常使用的工具是Volatility,Volatility是一款开源的,并且基于Python开发的内存取证工具集,可以分析内存中的各种数据,Volatility支持对32位或64位Wnidows、Linux、Mac、Android操作系统的RAM数据进行提取与分析,下面是一些常用的命令参数

imageinfo:识别操作系统、服务包以及硬件架构(32位或64位),并且还能收集DTB地址和样本收集的时间等

取证闲谈_

kpcrscan:扫描潜在的KPCR(内核进程控制区域)结构,在多核系统中,每个处理器都有自己的KPCR,所以通过kpcrscan,可以看到每个处理器的详细信息,包括IDT(中断描述符表)和GDT(全局描述符表)地址;以及当前、空闲和下一个线程;CPU编号、供应商和速度;以及CR3值等等

取证闲谈_

pslist:可以提取系统中的进程,这个命令会遍历由 PsActiveProcessHead指向的双向链表,并显示进程的偏移量、进程名称、进程ID、父进程ID、线程数量、句柄数量以及进程启动和退出的日期/时间等

取证闲谈_

psscan:可以枚举进程,不过和pslist相比,可以找到之前已终止(非活动)的进程以及被rootkit隐藏或解除链接的进程

取证闲谈_

dlllist:提取进程加载的DLL列表

取证闲谈_

getsids:可以查看与进程关联的SID(安全标识符),可以帮助识别恶意提升权限的进程以及属于特定用户的进程

取证闲谈_

cmdscan:用于了解攻击者在受害者系统上的行为

取证闲谈_

consoles:用于查找攻击者在cmd.exe中输入或通过后门执行的命令,相比于cmdscan,不仅打印出攻击者输入的命令,还可以收集整个屏幕缓冲区(输入和输出)

modscan:可以扫描物理内存中的池标记来查找 LDR_DATA_TABLE_ENTRY结构,有助于捕获之前卸载的驱动程序以及被rootkits隐藏/解除链接的驱动程序

取证闲谈_

filescan:用于查找文件

取证闲谈_

connections:可以查看在内存获取时处于活动状态的TCP连接

取证闲谈_

hivescan:查找内存中注册表文件的物理地址

取证闲谈_

hivelist:用于定位内存中注册表文件的虚拟地址以及相应文件在磁盘上的完整路径

取证闲谈_

printkey:提取注册表键中的子键、值、数据和数据类型

取证闲谈_

总之,Volatility命令参数很多,功能强大,不再一一演示

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
Usage: Volatility - A memory forensics analysis platform.

Options:
-h, --help list all available options and their default values.
Default values may be set in the configuration file
(/etc/volatilityrc)
--conf-file=/home/liuty/.volatilityrc
User based configuration file
-d, --debug Debug volatility
--plugins=PLUGINS Additional plugin directories to use (colon separated)
--info Print information about all registered objects
--cache-directory=/home/liuty/.cache/volatility
Directory where cache files are stored
--cache Use caching
--tz=TZ Sets the (Olson) timezone for displaying timestamps
using pytz (if installed) or tzset
-f FILENAME, --filename=FILENAME
Filename to use when opening an image
--profile=WinXPSP2x86
Name of the profile to load (use --info to see a list
of supported profiles)
-l LOCATION, --location=LOCATION
A URN location from which to load an address space
-w, --write Enable write support
--dtb=DTB DTB Address
--shift=SHIFT Mac KASLR shift address
--output=text Output in this format (support is module specific, see
the Module Output Options below)
--output-file=OUTPUT_FILE
Write output in this file
-v, --verbose Verbose information
--physical_shift=PHYSICAL_SHIFT
Linux kernel physical shift address
--virtual_shift=VIRTUAL_SHIFT
Linux kernel virtual shift address
-g KDBG, --kdbg=KDBG Specify a KDBG virtual address (Note: for 64-bit
Windows 8 and above this is the address of
KdCopyDataBlock)
--force Force utilization of suspect profile
--cookie=COOKIE Specify the address of nt!ObHeaderCookie (valid for
Windows 10 only)
-k KPCR, --kpcr=KPCR Specify a specific KPCR address

Supported Plugin Commands:

amcache Print AmCache information
apihooks Detect API hooks in process and kernel memory
atoms Print session and window station atom tables
atomscan Pool scanner for atom tables
auditpol Prints out the Audit Policies from HKLMSECURITYPolicyPolAdtEv
bigpools Dump the big page pools using BigPagePoolScanner
bioskbd Reads the keyboard buffer from Real Mode memory
cachedump Dumps cached domain hashes from memory
callbacks Print system-wide notification routines
clipboard Extract the contents of the windows clipboard
cmdline Display process command-line arguments
cmdscan Extract command history by scanning for _COMMAND_HISTORY
connections Print list of open connections [Windows XP and 2003 Only]
connscan Pool scanner for tcp connections
consoles Extract command history by scanning for _CONSOLE_INFORMATION
crashinfo Dump crash-dump information
deskscan Poolscaner for tagDESKTOP (desktops)
devicetree Show device tree
dlldump Dump DLLs from a process address space
dlllist Print list of loaded dlls for each process
driverirp Driver IRP hook detection
drivermodule Associate driver objects to kernel modules
driverscan Pool scanner for driver objects
dumpcerts Dump RSA private and public SSL keys
dumpfiles Extract memory mapped and cached files
dumpregistry Dumps registry files out to disk
editbox Displays information about Edit controls. (Listbox experimental.)
envars Display process environment variables
eventhooks Print details on windows event hooks
evtlogs Extract Windows Event Logs (XP/2003 only)
filescan Pool scanner for file objects
gahti Dump the USER handle type information
gditimers Print installed GDI timers and callbacks
gdt Display Global Descriptor Table
getservicesids Get the names of services in the Registry and return Calculated SID
getsids Print the SIDs owning each process
handles Print list of open handles for each process
hashdump Dumps passwords hashes (LM/NTLM) from memory
hibinfo Dump hibernation file information
hivedump Prints out a hive
hivelist Print list of registry hives.
hivescan Pool scanner for registry hives
hpakextract Extract physical memory from an HPAK file
hpakinfo Info on an HPAK file
idt Display Interrupt Descriptor Table
iehistory Reconstruct Internet Explorer cache / history
imagecopy Copies a physical address space out as a raw DD image
imageinfo Identify information for the image
impscan Scan for calls to imported functions
joblinks Print process job link information
kdbgscan Search for and dump potential KDBG values
kpcrscan Search for and dump potential KPCR values
ldrmodules Detect unlinked DLLs
lsadump Dump (decrypted) LSA secrets from the registry
machoinfo Dump Mach-O file format information
malfind Find hidden and injected code
mbrparser Scans for and parses potential Master Boot Records (MBRs)
memdump Dump the addressable memory for a process
memmap Print the memory map
messagehooks List desktop and thread window message hooks
mftparser Scans for and parses potential MFT entries
moddump Dump a kernel driver to an executable file sample
modscan Pool scanner for kernel modules
modules Print list of loaded modules
multiscan Scan for various objects at once
mutantscan Pool scanner for mutex objects
notepad List currently displayed notepad text
objtypescan Scan for Windows object type objects
patcher Patches memory based on page scans
poolpeek Configurable pool scanner plugin
printkey Print a registry key, and its subkeys and values
privs Display process privileges
procdump Dump a process to an executable file sample
pslist Print all running processes by following the EPROCESS lists
psscan Pool scanner for process objects
pstree Print process list as a tree
psxview Find hidden processes with various process listings
qemuinfo Dump Qemu information
raw2dmp Converts a physical memory sample to a windbg crash dump
screenshot Save a pseudo-screenshot based on GDI windows
servicediff List Windows services (ala Plugx)
sessions List details on _MM_SESSION_SPACE (user logon sessions)
shellbags Prints ShellBags info
shimcache Parses the Application Compatibility Shim Cache registry key
shutdowntime Print ShutdownTime of machine from registry
sockets Print list of open sockets
sockscan Pool scanner for tcp socket objects
ssdt Display SSDT entries
strings Match physical offsets to virtual addresses (may take a while, VERY verbose)
svcscan Scan for Windows services
symlinkscan Pool scanner for symlink objects
thrdscan Pool scanner for thread objects
threads Investigate _ETHREAD and _KTHREADs
timeliner Creates a timeline from various artifacts in memory
timers Print kernel timers and associated module DPCs
truecryptmaster Recover TrueCrypt 7.1a Master Keys
truecryptpassphrase TrueCrypt Cached Passphrase Finder
truecryptsummary TrueCrypt Summary
unloadedmodules Print list of unloaded modules
userassist Print userassist registry keys and information
userhandles Dump the USER handle tables
vaddump Dumps out the vad sections to a file
vadinfo Dump the VAD info
vadtree Walk the VAD tree and display in tree format
vadwalk Walk the VAD tree
vboxinfo Dump virtualbox information
verinfo Prints out the version information from PE images
vmwareinfo Dump VMware VMSS/VMSN information
volshell Shell in the memory image
windows Print Desktop Windows (verbose details)
wintree Print Z-Order Desktop Windows Tree
wndscan Pool scanner for window stations
yarascan Scan process or kernel memory with Yara signatures
ROUTEROS

USB流量数据取证

关于鼠标流量取证,每个数据包的数据区有四个字节。第一个字节代表按钮。取0x00时,表示没有按钮。为0x01时,表示左键,当它是0x02时,表示当前按钮是右键,第二个字节可以被认为是带符号的字节类型,最高位是符号位,当该值为正时,表示鼠标水平向右移动多少像素,当它为负数时,表示向左移动了多少像素。第三个字节类似于第二个字节,代表垂直向上和向下移动的偏移量,我们可以先看一个数据包

取证闲谈_

可以看到认证等的信息,我们也可以从里面看到这个设备的信息,应该是罗技的鼠标,然后我们用tshark对usb数据进行提取

1
tshark -r capture.pcapng -T fields -e usb.capdata > data2.txt
STYLUS

取证闲谈_

可以看到数据是四个字节的,那么我们基本可以判断是usb鼠标流量,然后将第二个和第三个字节转换为坐标,并生成一个坐标文件

取证闲谈_

取证闲谈_

最后将数据绘制到 Gnuplot 中,就可以复原鼠标行动轨迹

取证闲谈_

当然对于鼠标usb的取证也有一些脚本可以使用,比如 https://github.com/WangYihang/UsbMiceDataHacker

取证闲谈_

取证闲谈_

对于键盘流量取证,键盘数据包的数据长度为8个字节,和击键信息被集中在第三个字节,每次key stroke都会产生一个keyboard event usb packet,通过下面这张图可以找到这个值与具体键位的对应关系

取证闲谈_

windows系统下Bitlocker加密问题

Windows专业版/企业版/教育版的操作系统支持开启和使用Bitlocker加密,而家庭版不支持,不过家庭版可以通过”设备加密”那里启动磁盘保护,启动Bitlocker的方式为:控制面板->Bitlocker驱动器加密->启用Bitlocker

取证闲谈_

对于加密,有三种解锁方式可选,分别是使用密码解锁、使用智能卡解锁以及在此计算机上自动解锁,不过有些系统版本只显示两种,比如我的

取证闲谈_

取证闲谈_

Bitlocker加密后的表现,会显示有一把锁标志

取证闲谈_

如果想查属于哪种加密类型,可通过manage-bde管理工具来查看Bitlocker保护类型

1
manage-bde-status x:
FORTRAN

取证闲谈_

被Bitlocker保护的驱动器,其DBR特征非常明显,通过XWF或者winhex可查看标志头位,典型特征:“FVE-FS”

取证闲谈_

而不同磁盘的标志头位是”NTFS”

取证闲谈_

对于启用Bitlocker保护的硬盘在进行证据固定时不可做全盘镜像,因为做下来的镜像还是加密状态,如果以物理驱动器的方式将整块硬盘添加到案件中,是可以明显看到硬盘处于Bitlocker加密状态

取证闲谈_

取证闲谈_

但是如果以添加逻辑驱动器的形式将分区添加到案件中,是可以解析出完整的分区结构和目录的,所以在不知道密码或者恢复密钥的情况下,是无法对硬盘镜像进行解密的

取证闲谈_

那我们怎么得到恢复密钥?在系统下可直接使用manage-bde将加密卷的恢复密钥读取出来

1
manage-bde -protectors -get x:
ROUTEROS

取证闲谈_

有时候,常规手段不行那就上强度,爆破!推荐Passware Kit Forensic

取证闲谈_

取证闲谈_

取证闲谈_

或者也可以从内存中提取密钥,现在假设一个情况: 涉案机器处于开机状态且允许进入桌面,这个时候内存中会包含大量有价值的数据,比如软件进程,网络连接情况还有历史系统命令操作记录等等,易失性数据要优先固定留存,方便后面的取证工作,这个时候我们通过分析内存镜像尝试寻找Bitlocker的密钥数据,可以借助Elcomsoft Forensic Disk Decryptor工具,它支持导出内存镜像中的各种密钥数据,当然也可以直接进行破解任务

取证闲谈_

取证闲谈_

取证闲谈_

使用需知

由于传播、利用此文所提供的信息而造成的任何直接或者间接的后果及损失,均由使用者本人负责,文章作者不为此承担任何责任。

封面图片来源网络,如有侵权联系必删。

原文始发于微信公众号(天启实验室):取证闲谈_

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年3月27日18:11:52
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   取证闲谈_http://cn-sec.com/archives/2609501.html

发表评论

匿名网友 填写信息