MiguoQAQ
文章5
标签2
分类0

文章归档

Forensics 学习 No.1

Forensics 学习 No.1

Forensics学习No.1-内存取证工具volatility#

volatility安装,环境配置及其插件安装#

volatility安装#

1
2
3
4
参考文档:
https://cloud.tencent.com/developer/article/2375403
https://blog.csdn.net/weixin_44895005/article/details/123917324
https://bbs.huaweicloud.com/blogs/399904

配置环境:kali linux2023

python环境:python2

安装源码:https://github.com/volatilityfoundation/volatility 针对python2

在安装之前,需要配置下本地的pip2环境,因为在kali2023里面,pippip3都是python3的,并没有给python2配置pip,所以需要自己单独安装下,不然后面配置的环境都跑到python3里面去了。

所以在这里单独配置pip2

1
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
1
sudo python2 get-pip.py

安装完之后,使用pip2看下当前的版本信息:

然后准备安装volatility:去下载https://github.com/volatilityfoundation/volatility,然后进入volatility目录内直接安装:

1
python2 setup.py install

继续安装必须的模块:

  • crypto模块

    1
    pip2 install pycryptodome -i https://pypi.tuna.tsinghua.edu.cn/simple

    如果出现类似报错:Command errored out with exit status 1: python setup.py egg_info Check the logs for full command

    那么需要升级一下pip2

    1
    pip2 install --upgrade setuptools

    然后再次进行安装即可。

  • distorm3模块

    依赖:

    1
    pip2 install pycryptodome

    在这里需要先将模块下载下来:https://github.com/vext01/distorm3

    将模块存入volatility目录内,然后进入distorm3目录内使用命令行安装:

    1
    python2 setup.py install
  • construct库

    1
    pip2 install construct 

此时基础的模块就算安装好了,可以在任意目录下输入vol.py

如果出现这个,就说明安装好了

volatility插件安装#

  • 安装mimikatz插件

    https://raw.githubusercontent.com/RealityNet/hotoloti/master/volatility/mimikatz.py

    需要将这个文件移动到python2volatility的插件目录下:

    1
    2
    3
    4
    cd /usr/lib/python2.7/dist-packages
    mkdir volatility
    cd volatility
    mkdir plugins

    然后将这个文件复制过去:

    1
    cp mimikatz.py /usr/lib/python2.7/dist-packages/volatility/plugins/

    最后对于文件赋予权限:

    1
    chmod 777 *

    现在可以尝试一下了,这里需要注意一下,一定要在保存的目录内使用--plugin=./参数调用插件(在其他地方调用会出现找不到插件的错误)

    1
    vol.py --plugin=./ -f '/home/kali/Desktop/学取证咯.raw' --profile=Win7SP1x64  mimikatz
  • 安装yara插件

    一定要通过手动下载然后转移到kali内!!不要使用pip,apt-get等方式获取!

    下载yara:https://virustotal.github.io/yara/(下载4.2.3版本)

    下载yara-python:https://github.com/VirusTotal/yara-python(下载4.2.3版本)

    (本人实验只有对应的4.2.3版本可以正常运行,版本过高会有不兼容问题,具体错误报告见https://github.com/volatilityfoundation/volatility/issues/869

    1
    2
    3
    参考文章(官方文档):
    https://yara.readthedocs.io/en/v4.2.3/gettingstarted.html
    https://github.com/VirusTotal/yara-python/blob/master/README.rst

    本文只摘取官方文档中部分基础内容,建议阅读官方文档进行安装

    安装yara所需的模块/库

    1
    2
    3
    sudo apt-get install automake libtool make gcc pkg-config
    sudo apt-get install libjansson-dev
    sudo apt install libmagic-dev

    下载yara4.2.3压缩包后按照标准方式编译并安装YARA:

    1
    2
    3
    4
    5
    6
    tar -zxf yara-4.2.3.tar.gz
    cd yara-4.2.3
    ./bootstrap.sh
    ./configure
    make
    sudo make install

    运行测试用例以确保一切正常:

    1
    make check

    这时可以通过运行

    1
    yara --version

    来测试yara

    编译yara-python-4.2.3(解压缩到yara-4.2.3目录内,在yara-4.2.3目录内安装)

    1
    2
    3
    tar -zxf yara-python-4.2.3.tar.gz
    cd yara-python-4.2.3
    python2 setup.py build

    此时将yara-4.2.3文件夹内文件拷贝一份,复制到yara-python-4.2.3文件夹内的yara文件夹中,去除yara-python-4.2.3文件夹

    这个时候安装yara-python-4.2.3

    1
    sudo python2 setup.py install

    如果您想动态链接共享libyara库,请使用:

    1
    python2 setup.py build --dynamic-linking

    这时可以使用

    1
    2
    3
    python2
    import yara
    print(yara.__version__)

    来测试yara-python

    最后尝试使用volatility中的yarascan

    1
    vol.py -f '/home/kali/Desktop/学取证咯.raw' --profile=Win7SP1x64 yarascan -p 2304,2392 -Y "/(URL|REDR|LEAK)/"

    能扫出结果就说明yara以及yarapython安装成功

  • PyCrypto(加密工具集):

    1
    pip2 install pycrypto
  • PIL(图片处理库):

    1
    pip2 install Pillow
  • OpenPyxl(读写excel文件):

    1
    pip2 install openpyxl
  • ujson(JSON解析):

    1
    pip2 install ujson

官方帮助#

输入vol.py --h 查看官方做出的帮助

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
Volatility Foundation Volatility Framework 2.6.1
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=/root/.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=/root/.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 HKLM\SECURITY\Policy\PolAdtEv
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

命令格式#

1
2
3
4
5
6
7
8
9
10
11
volatility -f [image] --profile=[profile] [plugin]

volatility -f [对象] --profile=[操作系统] [插件参数]

在分析之前,需要先判断当前的镜像信息,分析出是哪个操作系统 命令imageinfo即可获取镜像信息。

Volatility -f xxx.vmem imageinfo

在查到操作系统后如果不确定可以使用以下命令查看

volatility - f xxx.vmem --profile= [操作系统] volshell

常用命令#

1
2
3
4
5
6
7
8
9
10
11
12
13
123.raw为镜像文件,

test.xxx为外部保存文件,

文件路径均默认使用/home/kali/Desktop/,

Win7SP1x64为系统版本,

0xffff111111为虚拟内存地址,

0x0000111111为物理内存地址

'/home/kali/Desktop/exes'是生成文件存放目录
查看镜像文件系统摘要信息:#
1
volatility -f home/kali/Desktop/123.raw imageinfo

筛选: | greb abc

用户相关#

查看用户名和密码(hash值)#
1
volatility -f home/kali/Desktop/123.raw --profile=Win7SP1x64 hashdump
从注册表中查看密码:#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 lsadump
使用mimikatz插件查看密码(需要进入插件目录)#
1
vol.py --plugin=./ -f home/kali/Desktop/123.raw --profile=Win7SP1x64  mimikatz

cmd相关#

查看cmd使用情况#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 cmdscan
查看cmd详细情况#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 cmdline
抓取控制台下执行的命令以及回显数据#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 consoles

进程相关#

扫描内存中的进程#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 psscan
列举全部进程#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 pslist
查看进程结构图#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 pstree
查看隐藏进程#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 psxview
找出隐藏在内存中的dll文件和代码#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 malfind
列出每个进程已加载的dll#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 dlllist -n 111.exe

其中111.exe为进程名

将进程程序提取出来#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 memdump -p 1111 -D '/home/kali/Desktop/exes'

其中1111,2222为进程pid

显示内存中多种事件的时间线#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 timeliner
显示进程的环境变量#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 envar
显示进程的运行权限#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 privs
导出当前进程的可执行文件#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 procdump -p 1111 -D '/home/kali/Desktop/exes'

其中1111,2222为进程pid

最大程序提取信息#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 timeliner
程序版本信息#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 verinfo
通过yarascan来定义YARA规则进行搜索#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 yarascan -p 1111,2222 -Y "/(URL|REDR|LEAK)/"

其中1111,2222为进程pid,"/(URL|REDR|LEAK)/"为yarascan自定义规则

文件相关#

扫描文件#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 filescan
提取文件#
1
2
3
4
5
6
7
8
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64  dumpfiles -Q 0x0000111111 --dump-dir='/home/kali/Desktop/exes'
-n, --name #在转储出来的文件的文件名中加入原来的文件名
-u, --unsafe #放松安全约束来获取更多信息
-r, --regex #转储符合正则表达式的文件
-i, --ignore-case #在正则表达式中忽略大小写
导出的文件名有三种后缀
.img .dat .vacb
其中.dat文件可以直接修改后缀为原文件后缀使用
抓取删除的文件#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 mftparser
扫描内存中潜在的主引导记录#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 mbrparser
扫描在内存中潜在NTFS主文件表记录(MFT)#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 mftparser

就算删除了文件,在MFT中这条记录会被标记为free,但是实际文件是仍然没有被真正删除的,只要原来的文件没有被新文件覆盖,就可以完整恢复被删除的文件。在mftparser的$DATA就可以看见文件的数据了

检测和分析内存中的恶意软件特征#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 malfind
从内存文件中找到异常程序植入到系统的开机自启痕迹#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64shimcache

注册表相关#

打印 userassist 注册表项和信息,查看运行程序相关记录#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 userassist
查看注册表蜂巢文件,显示内存中的注册表配置单元和对应的路径#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 hivelist
可以对蜂巢根目录进行dump,查看注册表键名子项#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 -o 0xffff111111 hivedump 

导出的注册表的后缀为.reg,但是不能直接挂载,可以用WRR转换成Windows可以挂载的格式或直接阅读

查看注册表键值#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 -o 0xffff111111 printkey -K "ControlSet001\Control"

"ControlSet001\Control"是注册表子项

通常主机名位置:ControlSet001\Control\ComputerName\ComputerName

通常用户名位置:SAM\Domains\Account\Ueers\Names

导出shellbags注册表项#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 shellbags

关于shellbags注册表项:是一组用来记录文件夹(包括挂载网络驱动器文件夹和挂载设备的文件夹)的名称、大小、图标、视图、位置的注册表项。每次对文件夹的操作,shellBags的信息都会更新,而且包含时间戳信息。是Windows系统改善用户体验的功能之一。即使删除文件夹后,shellBags仍然会保留文件夹的信息

将内存中的注册表配置单元导出至磁盘#
1
2
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 dumpregistry -D '/home/kali/Desktop/exes' #导出所有注册表到磁盘
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 dumpregistry -o 0xffff111111 -D '/home/kali/Desktop/exes' #导出对应虚拟偏移所在的单个注册表

网络相关#

扫描全部网络连接#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 netscan
检索已建立的网络连接状态,显示活跃的TCP连接(/win7sp1x64不可用)#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x86 connections
查看网络连接状态,显示所有的TCP连接(/win7sp1x64不可用)#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x86 connscan
显示所有的套接字连接(/win7sp1x64不可用)#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x86 sockets
扫描标签池查找_ADDRESS_OBJECT结构体(/win7sp1x64不可用)#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x86 sockscan

windows系统相关#

查看桌面截图并存储(只有线框图和标题)#
1
'/home/kali/Desktop/exes'vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 screenshot --dump-dir='/home/kali/Desktop/exes'
查看notepad文件(只能查看进程中的notepad.exe中的内容)#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 notepad
查看内存中Windows剪切板中的内容#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 clipboard
打印系统所有桌面窗口的信息#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 windows
以树状形式打印系统所有的窗口简略信息#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 wintree
查看编辑控件信息#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 editbox
查看ie浏览器历史浏览记录#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 iehistory
扫描windows的服务#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 svcscan
查看环境变量#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 envars
内存映像交互访问命令行工具#
1
vol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64vvol.py -f home/kali/Desktop/123.raw --profile=Win7SP1x64 volshell

linux相关#

查看linux_bash命令#
1
vol.py -f dump.mem --profile=LinuxCentos7_3_10_1062x64 linux_bash
分析Linux系统中的进程和进程环境#
1
vol.py -f dump.mem --profile=LinuxCentos7_3_10_1062x64 linux_psaux
查看linux系统的dmesg缓冲区中日志消息#
1
vol.py -f dump.mem --profile=LinuxCentos7_3_10_1062x64 linux_dmesg
检查Linux系统调用表是否被修改过#
1
vol.py -f dump.mem --profile=LinuxCentos7_3_10_1062x64 linux_check_syscall | grep HOOKED
本文作者:MiguoQAQ
本文链接:https://miguoqaq.github.io/2024/02/06/No-1/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可
本站总访问量
本站访客数人次