Volatility - CheatSheet

支持 HackTricks

​​RootedCON西班牙 最相关的网络安全事件,也是 欧洲 最重要的事件之一。该大会的 使命是促进技术知识,是各个学科技术和网络安全专业人士的热烈交流平台。

如果你想要一些 快速而疯狂 的东西,可以并行启动多个 Volatility 插件,你可以使用:https://github.com/carlospolop/autoVolatility

python autoVolatility.py -f MEMFILE -d OUT_DIRECTORY -e /home/user/tools/volatility/vol.py # It will use the most important plugins (could use a lot of space depending on the size of the memory)

安装

volatility3

git clone https://github.com/volatilityfoundation/volatility3.git
cd volatility3
python3 setup.py install
python3 vol.py —h

volatility2

Download the executable from https://www.volatilityfoundation.org/26

Volatility 命令

访问官方文档 Volatility 命令参考

关于“list”与“scan”插件的说明

Volatility 有两种主要的插件方法,有时在其名称中反映出来。“list” 插件会尝试通过 Windows 内核结构导航,以检索诸如进程(定位并遍历内存中的 _EPROCESS 结构的链表)、操作系统句柄(定位并列出句柄表,取消引用找到的任何指针等)等信息。它们的行为或多或少类似于 Windows API,如果请求列出进程的话。

这使得“list”插件非常快速,但与 Windows API 一样容易受到恶意软件的操控。例如,如果恶意软件使用 DKOM 从 _EPROCESS 链表中取消链接一个进程,它将不会出现在任务管理器中,也不会出现在 pslist 中。

另一方面,“scan” 插件将采取类似于在内存中雕刻可能在取消引用为特定结构时有意义的内容的方法。例如,psscan 将读取内存并尝试从中创建 _EPROCESS 对象(它使用池标记扫描,搜索指示感兴趣结构存在的 4 字节字符串)。其优点是它可以挖掘已退出的进程,即使恶意软件篡改了 _EPROCESS 链表,插件仍然会找到在内存中存在的结构(因为它仍然需要存在以便进程运行)。缺点是“scan”插件比“list”插件稍慢,有时可能会产生误报(一个退出时间过长且其结构部分被其他操作覆盖的进程)。

来自: http://tomchop.me/2016/11/21/tutorial-volatility-plugins-malware-analysis/

操作系统配置文件

Volatility3

如 readme 中所述,您需要将您想要支持的 操作系统符号表 放入 volatility3/volatility/symbols 中。 各种操作系统的符号表包可在以下位置 下载

Volatility2

外部配置文件

您可以通过以下方式获取支持的配置文件列表:

./volatility_2.6_lin64_standalone --info | grep "Profile"

如果您想使用您下载的新配置文件(例如 Linux 配置文件),您需要在某处创建以下文件夹结构:plugins/overlays/linux,并将包含配置文件的 zip 文件放入此文件夹中。然后,使用以下命令获取配置文件的编号:

./vol --plugins=/home/kali/Desktop/ctfs/final/plugins --info
Volatility Foundation Volatility Framework 2.6


Profiles
--------
LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64 - A Profile for Linux CentOS7_3.10.0-123.el7.x86_64_profile x64
VistaSP0x64                                   - A Profile for Windows Vista SP0 x64
VistaSP0x86                                   - A Profile for Windows Vista SP0 x86

您可以https://github.com/volatilityfoundation/profiles 下载 Linux 和 Mac 配置文件

在前面的部分中,您可以看到配置文件名为 LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64,您可以使用它来执行类似的操作:

./vol -f file.dmp --plugins=. --profile=LinuxCentOS7_3_10_0-123_el7_x86_64_profilex64 linux_netscan

发现配置文件

volatility imageinfo -f file.dmp
volatility kdbgscan -f file.dmp

imageinfo 和 kdbgscan 之间的区别

从这里: 与仅提供配置文件建议的 imageinfo 相比,kdbgscan 旨在准确识别正确的配置文件和正确的 KDBG 地址(如果存在多个)。该插件扫描与 Volatility 配置文件相关的 KDBGHeader 签名,并应用合理性检查以减少误报。输出的详细程度和可以执行的合理性检查数量取决于 Volatility 是否能够找到 DTB,因此如果您已经知道正确的配置文件(或者如果您有来自 imageinfo 的配置文件建议),请确保使用它。

始终查看 kdbgscan 找到的进程数量。有时 imageinfo 和 kdbgscan 可以找到 多个 合适的 配置文件,但只有 有效的一个会有一些相关的进程(这是因为提取进程需要正确的 KDBG 地址)。

# GOOD
PsActiveProcessHead           : 0xfffff800011977f0 (37 processes)
PsLoadedModuleList            : 0xfffff8000119aae0 (116 modules)
# BAD
PsActiveProcessHead           : 0xfffff800011947f0 (0 processes)
PsLoadedModuleList            : 0xfffff80001197ac0 (0 modules)

KDBG

内核调试器块,在Volatility中称为KDBG,对于Volatility和各种调试器执行的取证任务至关重要。它被识别为KdDebuggerDataBlock,类型为_KDDEBUGGER_DATA64,包含重要的引用,如PsActiveProcessHead。这个特定的引用指向进程列表的头部,使得能够列出所有进程,这对于全面的内存分析是基础。

OS 信息

#vol3 has a plugin to give OS information (note that imageinfo from vol2 will give you OS info)
./vol.py -f file.dmp windows.info.Info

The plugin banners.Banners 可以在 vol3 中尝试查找 linux 横幅 在转储中。

哈希/密码

提取 SAM 哈希,域缓存凭据lsa 秘密

./vol.py -f file.dmp windows.hashdump.Hashdump #Grab common windows hashes (SAM+SYSTEM)
./vol.py -f file.dmp windows.cachedump.Cachedump #Grab domain cache hashes inside the registry
./vol.py -f file.dmp windows.lsadump.Lsadump #Grab lsa secrets

内存转储

进程的内存转储将提取当前进程状态的所有内容procdump模块将仅提取****代码

volatility -f file.dmp --profile=Win7SP1x86 memdump -p 2168 -D conhost/

​​​RootedCON西班牙 最相关的网络安全事件,也是 欧洲 最重要的活动之一。该大会的 使命是促进技术知识,是各个学科技术和网络安全专业人士的热烈交流平台。

进程

列出进程

尝试查找 可疑 进程(按名称)或 意外进程(例如 cmd.exe 作为 iexplorer.exe 的子进程)。 比较 pslist 的结果与 psscan 的结果,以识别隐藏进程可能会很有趣。

python3 vol.py -f file.dmp windows.pstree.PsTree # Get processes tree (not hidden)
python3 vol.py -f file.dmp windows.pslist.PsList # Get process list (EPROCESS)
python3 vol.py -f file.dmp windows.psscan.PsScan # Get hidden process list(malware)

Dump proc

./vol.py -f file.dmp windows.dumpfiles.DumpFiles --pid <pid> #Dump the .exe and dlls of the process in the current directory

命令行

是否执行了任何可疑的操作?

python3 vol.py -f file.dmp windows.cmdline.CmdLine #Display process command-line arguments

cmd.exe 中执行的命令由 conhost.exe(或在 Windows 7 之前的系统中为 csrss.exe)管理。这意味着如果攻击者在获取内存转储之前终止了 cmd.exe,仍然可以从 conhost.exe 的内存中恢复会话的命令历史记录。为此,如果在控制台的模块中检测到异常活动,则应转储相关 conhost.exe 进程的内存。然后,通过在此转储中搜索 strings,可以提取会话中使用的命令行。

环境

获取每个运行进程的环境变量。可能会有一些有趣的值。

python3 vol.py -f file.dmp windows.envars.Envars [--pid <pid>] #Display process environment variables

令牌权限

检查意外服务中的权限令牌。 列出使用某些特权令牌的进程可能会很有趣。

#Get enabled privileges of some processes
python3 vol.py -f file.dmp windows.privileges.Privs [--pid <pid>]
#Get all processes with interesting privileges
python3 vol.py -f file.dmp windows.privileges.Privs | grep "SeImpersonatePrivilege\|SeAssignPrimaryPrivilege\|SeTcbPrivilege\|SeBackupPrivilege\|SeRestorePrivilege\|SeCreateTokenPrivilege\|SeLoadDriverPrivilege\|SeTakeOwnershipPrivilege\|SeDebugPrivilege"

SIDs

检查每个由进程拥有的SSID。 列出使用特权SID的进程(以及使用某些服务SID的进程)可能会很有趣。

./vol.py -f file.dmp windows.getsids.GetSIDs [--pid <pid>] #Get SIDs of processes
./vol.py -f file.dmp windows.getservicesids.GetServiceSIDs #Get the SID of services

句柄

了解一个 进程拥有的句柄(已打开)指向哪些其他文件、密钥、线程、进程... 是很有用的

vol.py -f file.dmp windows.handles.Handles [--pid <pid>]

DLLs

./vol.py -f file.dmp windows.dlllist.DllList [--pid <pid>] #List dlls used by each
./vol.py -f file.dmp windows.dumpfiles.DumpFiles --pid <pid> #Dump the .exe and dlls of the process in the current directory process

每个进程的字符串

Volatility 允许我们检查一个字符串属于哪个进程。

strings file.dmp > /tmp/strings.txt
./vol.py -f /tmp/file.dmp windows.strings.Strings --strings-file /tmp/strings.txt

它还允许使用 yarascan 模块在进程中搜索字符串:

./vol.py -f file.dmp windows.vadyarascan.VadYaraScan --yara-rules "https://" --pid 3692 3840 3976 3312 3084 2784
./vol.py -f file.dmp yarascan.YaraScan --yara-rules "https://"

UserAssist

Windows 通过注册表中的一个功能 UserAssist keys 跟踪您运行的程序。这些键记录每个程序执行的次数以及最后一次运行的时间。

./vol.py -f file.dmp windows.registry.userassist.UserAssist

​​​​RootedCON西班牙 最相关的网络安全事件,也是 欧洲 最重要的活动之一。该大会 旨在促进技术知识,是各个学科技术和网络安全专业人士的热烈交流平台。

服务

./vol.py -f file.dmp windows.svcscan.SvcScan #List services
./vol.py -f file.dmp windows.getservicesids.GetServiceSIDs #Get the SID of services

网络

./vol.py -f file.dmp windows.netscan.NetScan
#For network info of linux use volatility2

注册表蜂巢

打印可用的蜂巢

./vol.py -f file.dmp windows.registry.hivelist.HiveList #List roots
./vol.py -f file.dmp windows.registry.printkey.PrintKey #List roots and get initial subkeys

获取一个值

./vol.py -f file.dmp windows.registry.printkey.PrintKey --key "Software\Microsoft\Windows NT\CurrentVersion"

转储

#Dump a hive
volatility --profile=Win7SP1x86_23418 hivedump -o 0x9aad6148 -f file.dmp #Offset extracted by hivelist
#Dump all hives
volatility --profile=Win7SP1x86_23418 hivedump -f file.dmp

文件系统

挂载

#See vol2

扫描/转储

./vol.py -f file.dmp windows.filescan.FileScan #Scan for files inside the dump
./vol.py -f file.dmp windows.dumpfiles.DumpFiles --physaddr <0xAAAAA> #Offset from previous command

主文件表

# I couldn't find any plugin to extract this information in volatility3

NTFS文件系统使用一个称为_主文件表_(MFT)的关键组件。该表为卷上的每个文件至少包含一个条目,也包括MFT本身。关于每个文件的重要细节,如大小、时间戳、权限和实际数据,都封装在MFT条目中或在MFT外部但由这些条目引用的区域中。更多细节可以在官方文档中找到。

SSL密钥/证书

#vol3 allows to search for certificates inside the registry
./vol.py -f file.dmp windows.registry.certificates.Certificates

恶意软件

./vol.py -f file.dmp windows.malfind.Malfind [--dump] #Find hidden and injected code, [dump each suspicious section]
#Malfind will search for suspicious structures related to malware
./vol.py -f file.dmp windows.driverirp.DriverIrp #Driver IRP hook detection
./vol.py -f file.dmp windows.ssdt.SSDT #Check system call address from unexpected addresses

./vol.py -f file.dmp linux.check_afinfo.Check_afinfo #Verifies the operation function pointers of network protocols
./vol.py -f file.dmp linux.check_creds.Check_creds #Checks if any processes are sharing credential structures
./vol.py -f file.dmp linux.check_idt.Check_idt #Checks if the IDT has been altered
./vol.py -f file.dmp linux.check_syscall.Check_syscall #Check system call table for hooks
./vol.py -f file.dmp linux.check_modules.Check_modules #Compares module list to sysfs info, if available
./vol.py -f file.dmp linux.tty_check.tty_check #Checks tty devices for hooks

使用 yara 扫描

使用此脚本从 github 下载并合并所有 yara 恶意软件规则: https://gist.github.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9 创建 rules 目录并执行它。这将创建一个名为 malware_rules.yar 的文件,其中包含所有恶意软件的 yara 规则。

wget https://gist.githubusercontent.com/andreafortuna/29c6ea48adf3d45a979a78763cdc7ce9/raw/4ec711d37f1b428b63bed1f786b26a0654aa2f31/malware_yara_rules.py
mkdir rules
python malware_yara_rules.py
#Only Windows
./vol.py -f file.dmp windows.vadyarascan.VadYaraScan --yara-file /tmp/malware_rules.yar
#All
./vol.py -f file.dmp yarascan.YaraScan --yara-file /tmp/malware_rules.yar

MISC

外部插件

如果您想使用外部插件,请确保与插件相关的文件夹是第一个使用的参数。

./vol.py --plugin-dirs "/tmp/plugins/" [...]

Autoruns

https://github.com/tomchop/volatility-autoruns 下载它

volatility --plugins=volatility-autoruns/ --profile=WinXPSP2x86 -f file.dmp autoruns

Mutexes

./vol.py -f file.dmp windows.mutantscan.MutantScan

符号链接

./vol.py -f file.dmp windows.symlinkscan.SymlinkScan

Bash

可以从内存中读取bash历史记录。 你也可以转储_.bash_history_文件,但它已被禁用,你会很高兴可以使用这个volatility模块。

./vol.py -f file.dmp linux.bash.Bash

时间线

./vol.py -f file.dmp timeLiner.TimeLiner

驱动程序

./vol.py -f file.dmp windows.driverscan.DriverScan

获取剪贴板

#Just vol2
volatility --profile=Win7SP1x86_23418 clipboard -f file.dmp

获取IE历史记录

#Just vol2
volatility --profile=Win7SP1x86_23418 iehistory -f file.dmp

获取记事本文本

#Just vol2
volatility --profile=Win7SP1x86_23418 notepad -f file.dmp

截图

#Just vol2
volatility --profile=Win7SP1x86_23418 screenshot -f file.dmp

主引导记录 (MBR)

volatility --profile=Win7SP1x86_23418 mbrparser -f file.dmp

主引导记录 (MBR) 在管理存储介质的逻辑分区中发挥着至关重要的作用,这些分区采用不同的 文件系统 进行结构化。它不仅保存分区布局信息,还包含作为引导加载程序的可执行代码。该引导加载程序要么直接启动操作系统的二阶段加载过程(参见 二阶段引导加载程序),要么与每个分区的 卷引导记录 (VBR) 协同工作。有关深入知识,请参阅 MBR 维基百科页面

参考文献

RootedCON西班牙 最相关的网络安全事件,也是 欧洲 最重要的活动之一。该大会 旨在促进技术知识,是各个学科的技术和网络安全专业人士的热烈交流平台。

支持 HackTricks

Last updated