The Art of Memory Forensics-Windows取证(Virut样本取证)

1、前言

The Art of Memory Forensics真是一本很棒的书籍,其中使用volatility对内存进行分析的描述可以辅助我们对更高级类的木马进行分析和取证,这里对书中的命令进行了笔记记录。

2、volatility-Windows命令

与分析Linux镜像相似,而Windows系统的profile都是volatility自带的,无需再制作。

549050-20180513003323044-881185067.png

  • 选择元数据 imageinfo

查看正在分析的内存样本的摘要信息。显示主机所使用的操作系统版本、服务包以及硬件结构(32位或64位)、页目录表的起始地址和该获取该内存镜像的时间等信息。显示出当前所支持的元数据系统。

549050-20180513003431378-564682476.png

  • 结束进程分析 psscan

使用PSSCAN命令。可以找到以前终止的进程(非活动)和被rootkit隐藏或未链接的进程。输出显示ping.exe、ipconfig.exe两个进程启动与退出时间。

549050-20180513003515281-250040520.png

549050-20180513003518334-1461196847.png

  • 进程列表 pslist

列出系统进程,显示偏移量、进程名称、进程ID、父进程ID、线程数、句柄的数量,以及进程启动和退出时的日期/时间。

549050-20180513003554416-374781815.png

  • 进程树 pstree

查看以树形形式列出的进程,与pslist显示的技术一样,但不会显示隐藏或未链接的进程。子进程使用缩进和句点表示。

549050-20180513003643218-2108224139.png

  • 检测横向运动 getsids

查看与进程关联的SIDs(安全标识符),识别恶意升级特权的进程,以及哪些进程属于特定的用户。例子中以explorer.exe为示例,其中一个SID (S-1-5-21-[snip]-1115)没有显示帐户名称。
EXE是管理员的成员组。在这个特殊的场景,攻击者组合了一个毒葛(PI)远控。(RAT)使用一个Pass the Hash (PtH)攻击。

549050-20180513004106274-584822447.png

549050-20180513003928095-1759166758.png

  • 识别远程映射驱动器

许多攻击者都依赖于像net view和net use这样的命令来探索周围环境。通过远程驱动器功能获取对服务器的读访问权限后在内网进行横向运动。

549050-20180513010908322-855442719.png

  • 识别远程映射驱动器-handles

在内存中找到远程映射驱动器的证据,可通过查找文件句柄实现。使用handles命令可查看文件、注册表键、互斥锁、命名管道、事件、窗口站、桌面、线程和所有其他类型的可保存执行对象。

549050-20180513004350275-1400582666.png

549050-20180513004358095-608902836.png

  • 识别远程映射驱动器

另一种检测远程映射共享的方法,可以结合使用。通过symlinkscan插件检查符号链接。

549050-20180513004422143-883540644.png

  • 进程内存查看 memmap

memmap命令显示了哪些页面是内存驻留的,给定一个特定的进程DTB。可显示页面的虚拟地址、页面相应的物理偏移量以及页面的大小。这个命令生成的映射信息来自底层地址空间的get_available_address方法。

549050-20180513004444007-1594822142.png

  • 进程内存提取 memdump

要在一个进程中提取所有内存驻留页面,可使用memdump命令将系统进程的可寻址内存提取到单个文件之中。

549050-20180513004520024-637752518.png

  • Yara规则扫描内存

Yara是Victor M. Alvarez (http://plusvic.github.io/yara)的一款匹配特征数据的工具。

在任意数据集内的模式匹配。Yarascan命令可以通过虚拟内存进行扫描,可以指定PID扫描,扫描规则除了使用字符也可以使用匹配规则文件。

549050-20180513004542281-684564840.png

549050-20180513004551420-1013101062.png

549050-20180513004605169-1631003492.png

549050-20180513004608878-1681199443.png

  • 环境变量 envars

使用envars命令可以显示进程的环境变量,将显示安装的cpu数量和硬件架构、进程的当前目录、临时目录、会话名称、计算机名称、用户名等相关信息。

549050-20180513004729635-701940983.png

  • 网络套接字 netscan

扫描32位和64位Windows Vista、Windows 2008服务器和Windows 7内存转储中的网络构件,可以使用netscan命令。显示TCP端点、TCP监听器、UDP端点和UDP侦听器。区分IPv4和IPv6,打印本地和远程IP、本地和远程端口、套接字被绑定的时间或连接何时建立,以及当前状态(仅用于TCP连接)。

549050-20180513004805378-1823230376.png

  • 内存中的DLL列表 dlllist

使用dlllist命令可以显示进程加载的dll,通过遍历由PEB的InLoadOrderModuleList指向的_LDR_DATA_TABLE_ENTRY结构的doubly链接列表。当进程调用LoadLibrary(或诸如LdrLoadDll之类的一些衍生工具)时,DLL会添加到这个列表中,直到调用FreeLibrary,引用计数为0时才会被删除。

549050-20180513004847138-441721729.png

  • 内存中的DLL导出 dlldump

要从进程的内存空间中提取DLL并将其转储到磁盘进行分析,可以使用dlldump命令。从一个特定的进程转储所有dll(使用pid= pid)

549050-20180513005001971-318531879.png

  • 进程PE提取 procdump

使用procdump命令可以转储进程的可执行文件,通过--unsafe 或者 -u 标记来绕过解析PE头时使用的某些完整性检查。某些恶意软件会故意在PE报头中伪造大小字段,这样内存转储工具就会失败。

549050-20180513005049542-1354877961.png

  • 隐藏\注入代码检测 malfind

malfind命令基于VAD标记和页面权限等特性,帮助在用户模式内存中找到隐藏或注入的代码。

549050-20180513005142193-790176328.png

549050-20180513005147562-184053090.png

  • 注册表列表 hivelist

使用hivelist扫描注册表,然后打印物理和虚拟偏移量、路径。通过这个命令查找某些恶意软件存在的注册表键。

549050-20180513005222013-1975172636.png

  • 注册表值打印 printkey

大部分恶意代码都会对注册表操作,可以通过printkey打印出某些注册表键值,以下命令为打印出自启动项。

549050-20180513005301314-124951303.png

  • 转储密码哈希 hashdump

使用hashdump命令可以从内存样本中转储帐户密码哈希(LM/NTLM),查看密码是否已经受到篡改。

549050-20180513005332473-1046191956.png

  • 检测网络连接 connscan

使用connscan命令可以打印出正在建立连接的TCP和物理偏移地址

549050-20180513005409515-326458761.png

549050-20180513005414935-1394253504.png

  • 检测原始套接字 sockets

使用sockets可以打印出原始套接字的信息(TCP、UDP)

549050-20180513005440089-1137247201.png

  • 逆推netstat.exe结果 Netscan

使用netscan命令可以倒推出Windows系统中netstat.exe的结果。

549050-20180513005513888-1094298862.png

  • Internet History - iehistory

使用iehistory可恢复Internet Explorer缓存数据,查看受害主机访问过的历史记录。

549050-20180513005544523-899841577.png

  • DNS缓存恢复 filescan\dumpfiles

当应用程序使用DnsQuery,恶意代码经常破坏hosts文件以防止访问某些安全网站或者劫持流量。可以通过filescan命令查找到的物理偏移量。再通过dumpfile命令将文件的内容提取到磁盘。

549050-20180513005612812-1425784041.png

  • 活动模块列表 modules

使用modules命令可以打印出系统中加载模块的列表,可借助于此命令查找某些具有特定名称的rootkit模块。

549050-20180513005644455-1836720100.png

  • 提取内核模块 moddump

要提取所有当前加载的模块,只需提供所需输出的路径。

549050-20180513005719701-2039001734.png

  • 检测可疑线程 threads

Threads命令可以识别试图隐藏在进程中的线程。通过枚举加载的模块查询双链表并记录它们的基础地址和大小。然后扫描系统线程检查线程启动地址值是否在模块的范围内。

549050-20180513005756235-1104751682.png

3、示例分析-virut感染性病毒

virut是一款具有很强感染能力的一款病毒,通过感染正常进程空间,然后对注册表防火墙键值设定使受感染进程放行不拦截。

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List]
"C:\\Windows\\system32\\wininit.exe"="C:\\Windows\\system32\\wininit.exe:*:enabled:@shell32.dll,-1"
"C:\\Windows\\system32\\winlogon.exe"="C:\\Windows\\system32\\winlogon.exe:*:enabled:@shell32.dll,-1"

使用dumpit.exe对受害主机的内存提取,受感染进程winlogon.exe进程PID为604。

549050-20180513010218675-1832424248.png

使用volatility中的memdump命令对winlogon.exe进程空间数据进行提取,保存文件为604.dmp。

549050-20180513010250357-897331194.png

在已得知C&C域名为ilo.brenz[.]pl的情况下。通过字符串搜索可在进程内存数据中搜索到C&C域名,证明正常进程空间已经受到病毒的感染。

549050-20180513010306054-1419634833.png

除了使用memdump外,还可以使用yarascan命令直接对字符串进行扫描。

549050-20180513010515376-1634039622.png

Shellcode提取思路

这个病毒既然是感染性病毒,那么可以对受感染的病毒进行分析,然后提取特征字符串,dump的时候通过特征字符串+偏移定位的形式来提取。

转载于:https://www.cnblogs.com/17bdw/p/9030715.html

The Art of Memory Forensics: Detecting Malware and Threats in Windows, Linux, and Mac Memory Memory forensics provides cutting edge technology to help investigate digital attacks Memory forensics is the art of analyzing computer memory (RAM) to solve digital crimes. As a follow-up to the best seller Malware Analyst's Cookbook, experts in the fields of malware, security, and digital forensics bring you a step-by-step guide to memory forensics--now the most sought after skill in the digital forensics and incident response fields. Beginning with introductory concepts and moving toward the advanced, The Art of Memory Forensics: Detecting Malware and Threats in Windows, Linux, and Mac Memory is based on a five day training course that the authors have presented to hundreds of students. It is the only book on the market that focuses exclusively on memory forensics and how to deploy such techniques properly. Discover memory forensics techniques: How volatile memory analysis improves digital investigations Proper investigative steps for detecting stealth malware and advanced threats How to use free, open source tools for conducting thorough memory forensics Ways to acquire memory from suspect systems in a forensically sound manner The next era of malware and security breaches are more sophisticated and targeted, and the volatile memory of a computer is often overlooked or destroyed as part of the incident response process. The Art of Memory Forensics explains the latest technological innovations in digital forensics to help bridge this gap. It covers the most popular and recently released versions of Windows, Linux, and Mac, including both the 32 and 64-bit editions.
Memory forensics provides cutting edge technology to help investigate digital attacks Memory forensics is the art of analyzing computer memory (RAM) to solve digital crimes. As a follow-up to the best seller Malware Analyst's Cookbook, experts in the fields of malware, security, and digital forensics bring you a step-by-step guide to memory forensics—now the most sought after skill in the digital forensics and incident response fields. Beginning with introductory concepts and moving toward the advanced, The Art of Memory Forensics: Detecting Malware and Threats in Windows, Linux, and Mac Memory is based on a five day training course that the authors have presented to hundreds of students. It is the only book on the market that focuses exclusively on memory forensics and how to deploy such techniques properly. Discover memory forensics techniques: How volatile memory analysis improves digital investigations Proper investigative steps for detecting stealth malware and advanced threats How to use free, open source tools for conducting thorough memory forensics Ways to acquire memory from suspect systems in a forensically sound manner The next era of malware and security breaches are more sophisticated and targeted, and the volatile memory of a computer is often overlooked or destroyed as part of the incident response process. The Art of Memory Forensics explains the latest technological innovations in digital forensics to help bridge this gap. It covers the most popular and recently released versions of Windows, Linux, and Mac, including both the 32 and 64-bit editions.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值