溯源取证-内存取证篇
2023-4-14 08:34:57 Author: 哆啦安全(查看原文) 阅读量:31 收藏

今天的场景依然是windows场景,只不过此次场景分为两个镜像,本次学习主要学习如何晒别钓鱼邮件、如何提取钓鱼邮件、如何修复损坏的恶意文件、如何提取DLL动态链接库文件

本次需要使用的工具:

volatility_2.6_lin64_standalone
readpst
clamscan
olevba

本次实验使用的映像文件:
win7ecorpoffice2010-36b02ed3.vmem
ecorpwin7-e73257c4.vmem

Q1
File->ecorpoffice
What is the PID the malicious file is running under?
恶意文件运行的PID是什么?
老规矩,先看一下当前映像的系统信息

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem imageinfo

这里使用两种方式获取进程列表

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 pslist

或者

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 psscan

在 Volatility 2.6 版本中,psscan 指令和 pslist 指令都是用于扫描系统中的 PID(进程标识符) 的指令。但是,它们有一些重要的区别。
1.psscan 指令会一次性扫描系统中的所有 PID,而 pslist 指令只会列出当前正在运行的进程列表。
2.psscan 指令使用默认参数时,会列出所有检测到的进程及其相关信息,包括进程名称、PID、进程所有者、进程类型等。而 pslist 指令则只显示当前正在运行的进程列表。
3.psscan 指令支持使用多个参数,例如 -U 用于指定进程所有者,-o 用于指定输出格式等。而 pslist 指令不支持使用多个参数。
4.psscan 指令的安全性更高,因为它不会直接访问系统资源,而是通过 Volatility 提供的 API 进行进程扫描。这意味着 psscan 指令更加安全,并且不会泄漏敏感信息。

使用getsids命令统计 PID 为 1364 的进程或进程组

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 getsids -p 1364

这里其实也可以执行cmdline命令,查看一下该进程,该进程其实是在temp目录下走的,很多病毒也都是在temp目录下走的

Q2
File->ecorpoffice
What is the C2 server IP address?
C2服务器的IP地址是什么? 

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 netscan

Q3
File->ecorpoffice
What is the Teamviewer version abused by the malicious file?
被恶意文件滥用的Teamviewer版本是什么? 

strings win7ecorpoffice2010-36b02ed3.vmem| grep -F "54.174.131.235"

strings 命令用于在内存中查找字符串,而 grep 命令用于在文件中查找指定的字符串。在这里,grep 命令的参数 -F 表示使用正则表达式进行查找,并且指定要查找的字符串是在内存中的行中包含的。-F加不加都行

Q4
File->ecorpoffice
What password did the malicious file use to enable remote access to the system?
恶意文件使用了什么密码来启用对系统的远程访问

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 editbox

"editbox" 是该配置文件中与 "Win7SP1x64" 相关的编辑框数据的名称。

Q5
File->ecorpoffice
What was the sender's email address that delivered the phishing email?
发送钓鱼电子邮件的发件人的电子邮件地址是什么

我们将找到扩展名为*.eml或*.pst的文件(Outlook和Microsoft Exchange文件具有这样的扩展名,它们可以包含信件本身和文件夹,联系人,地址,附件等)。

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 filescan | grep pst$


这段命令是使用 Volatility 工具来读取一个名为 "c74-Team Spy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem" 的虚拟内存文件,并将其中与 "Win7SP1x64" 相关的文件扫描数据输出到标准输出 (stdout) 上,并通过 grep 命令筛选输出结果,只保留以 "pst$" 开头的行。

简而言之,就是过滤一下,扫一下镜像里带pst的文件

或者

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 filescan | grep -F ".pst"

eml并没有搜索结果,所以结果就是以pst为准

接下来是将这些文件转储出来,以便于我们取证
首先创建一个名为pst的文件夹
mkdir pst

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 dumpfiles -n -u -r pst$ -D pst

该命令将 pst相关的文件转储在 pst目录下
dumpfiles:提取内存映射和缓存的文件,包括-n(不覆盖已有的 dump 文件)、-u(只创建新的 dump 文件,不覆盖已有的 dump 文件) 和-r(指定 dump 文件的根目录)。
-D:指定要存储 dump 文件的路径和文件名,是 --dump-dir的简写

filescan只是扫描一下,而dumpfile则是导出

此时使用readpst工具进行读取,该工具需要手动安装

sudo apt-get update

不更新库是安装不上的哈

sudo apt-get install pst-utils

为什么说要使用readpst 工具呢,因为我们转储的文件是不便于我们阅读的,我们需要把他们转换成我们可以直接打开的文件格式,大家可以理解为“解压缩”,很明显,导出来的是二进制文件,我们看不了的

我们重点关注一下[email protected]数据

readpst -S [email protected]

此处已经成功将邮件解开,我们回到存放目录,发现已经可以阅读了

而后我们查看最后一个包的文件内容,因为这个带附件了

其实这里的题我是没答出来的,偷看了一下国外大佬的过程,也是看的云里雾里的,其实在这里是一封钓鱼邮件,按理说这个邮件里应该会显示出邮件的名称,但是我这里却没有

这里的意思,其实就是尊敬的xxx,这是您的发票  xxx银行
网上大佬的教程里,是有发票的名字的

但是解出来的文件,确实有个恶意钓鱼文件


我们去解开另外一个pst文件

几乎是如出一辙,至于为什么主要关注phillip.price用户,请回看Q1,C2木马运行的用户就是该用户

Q6
File->ecorpoffice
What is the MD5 hash of the malicious document?
恶意文档的MD5哈希是什么? 

c2dbf24a0dc7276a71dd0824647535c9

md5sum 13-bank_statement_088452.doc

Q7
File->ecorpoffice
What is the bitcoin wallet address that ransomware was demanded?
勒索软件被要求提供的比特币钱包地址是什么
这里可以使用检索的方式,也可以翻垃圾桶哈

grep -r -i bitcoin pst

该命令直接在解出来的邮件里全局所有bitcoin 关键字

可以看出来,人家威胁你,要不不给我5比特币,我就天天攻击你

Q8
File->ecorpoffice
What is the ID given to the system by the malicious file for remote access?
恶意文件为系统提供的用于远程访问的ID是什么? 

strings win7ecorpoffice2010-36b02ed3.vmem| grep "54.174.131.235"


与Q3问题一个玩法

如果观察细致的朋友,可能在上面看到过这个数字

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 editbox

好吧,在这里引用一下,其实也可以将以上的 部分流量包导出来

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpoffice/win7ecorpoffice2010-36b02ed3.vmem --profile=Win7SP1x64 memdump -p 1364 -D ./


上述命令其实是使用memdump命令捕获 pid 为 1364的内存状态,生成一个名为1364.dmp的文件,同时将生成的1364.dmp文件保存在当前目录下,以便于后续的分析

strings -el 1364.dmp | grep -A10 -B10 "54.174.131.235"


这条命令的作用是查找指定文件中包含字符串 "54.174.131.235" 的位置,并输出所有匹配的行。其中,string -el 1364.dmp 的作用是指定要查找的文件,grep -A10 -B10 "54.174.131.235" 的作用是指定要查找的字符串和显示匹配行的位置。

Q9
File->ecorpoffice
What is the IPv4 address the actor last connected to the system with the remote access tool?
参与者最后一次使用远程访问工具连接到系统的IPv4地址是什么? 

strings 1364.dmp| grep -B10 -A10 -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep "team" -B10 -A10

可以把 B10 A10 给大点

验证一下

strings -el 1364.dmp | grep -F '31.6.13.155' -B 10 -A 10

Q10
File->ecorpoffice
What Public Function in the word document returns the full command string that is eventually run on the system?
word文档中的哪个公共函数返回最终在系统上运行的完整命令字符串?

先安装个工具,用于分析Microsoft OLE2文件(也称为结构化存储,复合文件二进制格式或复合文档文件格式)例如Microsoft Office文档或Outlook消息,主要用于恶意软件分析,取证和调试。它基于olefile解析器

sudo pip3 install -U oletools

这里需要回过头去分析Q6拿到的恶意文件
13-bank_statement_088452.doc 

olevba -c 13-bank_statement_088452.doc 

我虽然上学的时候学过VB,但是早就忘光了,这里我确实没本事解密,但是此处执行的其实是一条powershell加密过的命令

Q11
File->ecorpwin7
What is the MD5 hash of the malicious document?
恶意文档的MD5哈希是什么?从此题开始进入到下一个映像

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem imageinfo

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 filescan | grep pst$

一套不解释连招,老规矩,找邮件

创建新的存放路径

导出

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 dumpfiles -n -u -r pst$ -D pst2

readpst -S [email protected]04.pst.dat

解压邮件文件

但是导出来的时候,该RTF文件损坏了,我是看不出来的

xxd 10-Important_ECORP_Lawsuit_Washington_Leak.rtf

全是GGG

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 filescan | grep rtf$

我们去重新筛选一下该文件,通过获取内存地址的方式进行导出,这样就不会损坏文件了

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 dumpfiles -Q 0x000000007d6b3850 -u -n -D pst2

其实就是加了一个-Q,用来指定文件的内存地址

这个时候依然不能直接用,文件末尾很多0

xxd -p file.None.0xfffffa80040b3260.Important_ECORP_Lawsuit_Washington_Leak.rtf.dat | sed '/000000000000000000000000000000000000000000000000000000000000/d' | sed '/0000000000000000000000000000000000000000000000000000/d' | sed 's/6131376136616631303365316533616437657d7d7d7d0000000000000000/6131376136616631303365316533616437657d7d7d7d/g' | xxd -r -p > Important_ECORP_Lawsuit_Washington_Leak.rtf

这段命令行的作用是将文件 xxxLeak.rtf.dat 中的特定字节删除,并将文件中的特定字符串替换为另一个字符串,最后将修改后的二进制文件写入新文件 xxxLeak.rtf。


或者使用 Sed 命令将文件中的任意空字符 (0x0) 替换为空字符串 (即删除所有空字符)。

sed 's/\x0//g' file.None.0xfffffa80040b3260.Important_ECORP_Lawsuit_Washington_Leak.rtf.dat > Important_ECORP_Lawsuit_Washington_Leak.rtf

计算MD5

md5sum Important_ECORP_Lawsuit_Washington_Leak.rtf

使用clamscan工具扫一下,也是告诉我们,别人利用的是CVE_2010_3333-5 Microsoft RTF栈溢出漏洞

Q12
File->ecorpwin7
What is the common name of the malicious file that gets loaded?"
被加载的恶意文件的通用名称是什么?
首先我们看一下网络连接状态

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 netscan

这个其实就挺可疑的

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 pstree | grep 288

我们查看一下该进程的进程树

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 cmdline | grep "rundll" -A 10 -B 10

转储 test.dll

mkdir dll

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 dumpfiles -n -i -r test.dll -D dll

导出文件没什么好说的

使用clamscan 进行扫描
Clamscan 是一个免费的开源杀毒软件,它使用 clamav 软件包来检测文件是否包含恶意软件。Clamscan 最初是由加州大学伯克利分校开发的,并在其 BSD 授权条款下免费提供。它支持多种文件格式和平台,并且可以在多个平台上运行。Clamscan 可以用于扫描本地计算机或远程服务器上的文件,并且可以自动检测和清除恶意软件。

clamscan -r .

md5sum file.288.0xfffffa8003791f10.test.DLL.dat

Malpedia 是一个在线的恶意软件数据库,提供有关各种恶意软件、病毒、黑客攻击和网络犯罪的信息。Malpedia 官网是 https://malpedia.caad.fkie.fraunhofer.de/library 。在该网站上,您可以找到有关各种恶意软件和攻击的详细信息,包括它们的特征、传播方式、攻击目标、预防和应对措施等。Malpedia 是由 OpenDNS 和安全公司 ESET 共同开发的,旨在为网络安全专业人士和普通人提供有关恶意软件的详细信息。

我们使用这个网站查看一下这个恶意文件的情况

Q13
File->ecorpwin7
What password does the attacker use to stage the compressed file for exfil?
攻击者使用什么密码来暂存压缩文件以进行exfil? 

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 memdump -p 288 -D ./

继续上一题,我们把svchost 进程的内存镜像导出来

一发定魂

strings -el 288.dmp| grep "password" -A10 -B10l

但是东西总是少一节,我们再次精确一下

strings -el  ecorpwin7-e73257c4.vmem| egrep -A5 -B5 "password1234"

egrep是筛选 password1234的字符串,而不是当做正则来筛选

strings -el  ecorpwin7-e73257c4.vmem| egrep "reports.rar"

我们发现 reports.rar用过之后就被删除了

Q14
File->ecorpwin7
What is the IP address of the c2 server for the malicious file?
恶意文件的c2服务器的IP地址是什么? 

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 netscan

回归到Q12问题,我们的所有推断都是没问题的,所以C2地址应该就是下图所示了

Q15
File->ecorpwin7
What is the email address that sent the phishing email?
发送钓鱼电子邮件的电子邮件地址是什么?
回顾Q11 ,我们发现了rtf恶意文件,发件人也在其中

或者

./volatility_2.6_lin64_standalone -f c74-TeamSpy/ecorpwin7/ecorpwin7-e73257c4.vmem --profile=Win7SP1x64 yarascan -Y "From:" | grep "@" -B3 -A3

这段命令行的目的是扫描指定的内存文件,并使用 Yarascan 扫描内存以查找可能的病毒或恶意软件,-Y "From::`在 Yarascan 扫描期间,忽略扫描指定字符串的内存块

Q16
File->ecorpwin7
What is the name of the deb package the attacker staged to infect the E Coin Servers?
攻击者用来感染E Coin服务器的deb包的名称是什么? 

strings -el ecorpwin7-e73257c4.vmem | grep -F '.deb'

推荐阅读

取证|伪加密zip解密方法

内存取证工具Volatility3

内存取证|Volatility大杀器

游戏黑灰产识别和溯源取证

内存取证之Volatility从0到1

溯源取证|微信数据库解密教程

Hook App取证实战数据库解密

GNU/Linux上跟踪USB设备的取证工具

App逆向之so分析方法

2023年逆向分析资料汇总


文章来源: http://mp.weixin.qq.com/s?__biz=Mzg2NzUzNzk1Mw==&mid=2247495456&idx=1&sn=a73a4455695615b2e8809952ff4dd165&chksm=ceb8aa6ef9cf237862c97a2e36f2a866408a881dde7b852262fee66e0ee98608df9da45dc3a1#rd
如有侵权请联系:admin#unsafe.sh