在做CTF的时候会碰到 .vmem 文件需要进行分析。vmem文件是虚拟机的分页文件,它备份宿主机文件系统上的guest主内存。此文件仅在虚拟机运行时存在,或者虚拟机崩溃时存在 [1]。这时候就需要 Volatility 文件进行分析。
Volatility 有 version 2 和 version 3
注意 Volatility 2 只支持 python 2 的环境,而 Volatility 3 支持 python 3.6 以上的环境。
这里给出2 和 3 的官方 git
Volatility 2 + python 2:https://github.com/volatilityfoundation/volatility
Volatility 3 + python 3 :https://github.com/volatilityfoundation/volatility3
然而网上能找到的教程大多数是 Volatility 2 的,但我的电脑又是python 3,怎么办。
办法肯定是有的。我网上冲浪了一会儿,找到了 Volatility 2 适配 python 3 的版本。
Volatility 2 + python 3 :https://github.com/koromodako/volatility
但是在安装依赖的时候会有些麻烦。pip install -r requirements.txt在安装 distorm3 的时候需要 Microsoft C++ Build Tools。只好下了个 VS 的 C++ 14。
然后再安装依赖就好了
分析就是查看设备信息 [2]:
- python vol.py -f file.vmem imageinfo
-
这一步可以看出推荐的profile:
- Volatility Foundation Volatility Framework 2.6
- INFO : volatility.debug : Determining profile based on KDBG search...
- Suggested Profile(s) : WinXPSP2x86, WinXPSP3x86 (Instantiated with WinXPSP2x86)
- AS Layer1 : IA32PagedMemoryPae (Kernel AS)
- AS Layer2 : FileAddressSpace (/home/panardin/Challs/cridex.vmem)
- PAE type : PAE
- DTB : 0x2fe000L
- KDBG : 0x80545ae0L
- Number of Processors : 1
- Image Type (Service Pack) : 3
- KPCR for CPU 0 : 0xffdff000L
- KUSER_SHARED_DATA : 0xffdf0000L
- Image date and time : 2012-07-22 02:45:08 UTC+0000
- Image local date and time : 2012-07-21 22:45:08 -0400
-
题目有时候会问到 KDBG 的虚拟地址是什么
这时用:
- python vol.py -f file.vmem kdbgscan
-
offset 的值就是KDBG的虚拟地址
这两个命令是用来查看进程的,需要加上之前分析的profile
- python vol.py -f file.vmem --profile=WinXPSP2x86 pslist
-
-
- Volatility Foundation Volatility Framework 2.6
- Offset(V) Name PID PPID Thds Hnds Sess
- ---------- -------------------- ------ ------ ------ -------- ------
- 0x823c89c8 System 4 0 53 240 ------
- 0x822f1020 smss.exe 368 4 3 19 ------
- 0x822a0598 csrss.exe 584 368 9 326 0
- 0x82298700 winlogon.exe 608 368 23 519 0
- 0x81e2ab28 services.exe 652 608 16 243 0
- 0x81e2a3b8 lsass.exe 664 608 24 330 0
- 0x82311360 svchost.exe 824 652 20 194 0
- 0x81e29ab8 svchost.exe 908 652 9 226 0
- 0x823001d0 svchost.exe 1004 652 64 1118 0
- 0x821dfda0 svchost.exe 1056 652 5 60 0
- 0x82295650 svchost.exe 1220 652 15 197 0
- 0x821dea70 explorer.exe 1484 1464 17 415 0
- 0x81eb17b8 spoolsv.exe 1512 652 14 113 0
- 0x81e7bda0 reader_sl.exe 1640 1484 5 39 0
- 0x820e8da0 alg.exe 788 652 7 104 0
- 0x821fcda0 wuauclt.exe 1136 1004 8 173 0
- 0x8205bda0 wuauclt.exe 1588 1004 5 132 0
-
pstree 会显示进程的所属关系。
- python vol.py -f file.vmem --profile=WinXPSP2x86 pstree
-
-
- Volatility Foundation Volatility Framework 2.6
- Name Pid PPid
- -------------------------------------------------- ------ ------
- 0x823c89c8:System 4 0
- . 0x822f1020:smss.exe 368 4
- .. 0x82298700:winlogon.exe 608 368
- ... 0x81e2ab28:services.exe 652 608
- .... 0x821dfda0:svchost.exe 1056 652
- .... 0x81eb17b8:spoolsv.exe 1512 652
- .... 0x81e29ab8:svchost.exe 908 652
- .... 0x823001d0:svchost.exe 1004 652
- ..... 0x8205bda0:wuauclt.exe 1588 1004
- ..... 0x821fcda0:wuauclt.exe 1136 1004
- .... 0x82311360:svchost.exe 824 652
- .... 0x820e8da0:alg.exe 788 652
- .... 0x82295650:svchost.exe 1220 652
- ... 0x81e2a3b8:lsass.exe 664 608
- .. 0x822a0598:csrss.exe 584 368
- 0x821dea70:explorer.exe 1484 1464
- . 0x81e7bda0:reader_sl.exe 1640 1484
-
非常有用,可以查看隐藏的进程,通常是有问题的。
识别方法,某一个进程的 pslist 和 psscan 列都是 False 。
- python vol.py -f file.vmem --profile=WinXPSP2x86 psxview
-
-
- Volatility Foundation Volatility Framework 2.6
- Offset(P) Name PID pslist psscan thrdproc pspcid csrss session deskthrd ExitTime
- ---------- -------------------- ------ ------ ------ -------- ------
- 0x02498700 winlogon.exe 608 True True True True..
- 0x02511360 svchost.exe 824 True True True True..
- 0x022e8da0 alg.exe 788 True True True True..
- 0x020b17b8 spoolsv.exe 1512 True True True True..
- 0x0202ab28 services.exe 652 True True True True..
- 0x02495650 svchost.exe 1220 True True True True..
- 0x0207bda0 reader_sl.exe 1640 True True True True..
- 0x025001d0 svchost.exe 1004 True True True True..
- 0x02029ab8 svchost.exe 908 True True True True..
- 0x023fcda0 wuauclt.exe 1136 True True True True..
- 0x0225bda0 wuauclt.exe 1588 True True True True..
- 0x0202a3b8 lsass.exe 664 True True True True..
- 0x023dea70 explorer.exe 1484 True True True True..
- 0x023dfda0 svchost.exe 1056 True True True True..
- 0x024f1020 smss.exe 368 True True True True..
- 0x025c89c8 System 4 True True True True..
- 0x024a0598 csrss.exe 584 True True True True..
-
-
查看命令行输了啥。
- python vol.py -f file.vmem --profile=WinXPSP2x86 cmdline
-
-
- Volatility Foundation Volatility Framework 2.6
- ********************************************************************
- System pid: 4
- ********************************************************************
- smss.exe pid: 368
- Command line : \SystemRoot\System32\smss.exe
- ********************************************************************
- csrss.exe pid: 584
- Command line : C:\WINDOWS\system32\csrss.exe ObjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3 ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off MaxRequestThreads=16
- ********************************************************************
- winlogon.exe pid: 608
- Command line : winlogon.exe
- ********************************************************************
- services.exe pid: 652
- Command line : C:\WINDOWS\system32\services.exe
- ********************************************************************
- lsass.exe pid: 664
- Command line : C:\WINDOWS\system32\lsass.exe
- ********************************************************************
- svchost.exe pid: 824
- Command line : C:\WINDOWS\system32\svchost -k DcomLaunch
- ********************************************************************
- svchost.exe pid: 908
- Command line : C:\WINDOWS\system32\svchost -k rpcss
- ********************************************************************
- svchost.exe pid: 1004
- Command line : C:\WINDOWS\System32\svchost.exe -k netsvcs
- ********************************************************************
- svchost.exe pid: 1056
- Command line : C:\WINDOWS\system32\svchost.exe -k NetworkService
- ********************************************************************
- svchost.exe pid: 1220
- Command line : C:\WINDOWS\system32\svchost.exe -k LocalService
- ********************************************************************
- explorer.exe pid: 1484
- Command line : C:\WINDOWS\Explorer.EXE
- ********************************************************************
- spoolsv.exe pid: 1512
- Command line : C:\WINDOWS\system32\spoolsv.exe
- ********************************************************************
- reader_sl.exe pid: 1640
- Command line : "C:\Program Files\Adobe\Reader 9.0\Reader\Reader_sl.exe"
- ********************************************************************
- alg.exe pid: 788
- Command line : C:\WINDOWS\System32\alg.exe
- ********************************************************************
- wuauclt.exe pid: 1136
- Command line : "C:\WINDOWS\system32\wuauclt.exe" /RunStoreAsComServer Local\[3ec]SUSDSb81eb56fa3105543beb3109274ef8ec1
- ********************************************************************
- wuauclt.exe pid: 1588
- Command line : "C:\WINDOWS\system32\wuauclt.exe"
-
还有两个相似的插件 cmdscan 和 consoles 就不展开了。
如果你发现某个进程很可疑,需要进一步分析。只需要找到它的PID值,比如在这个例子中就是 Reader_sl.exe 这个进程,PID是1640。
- python vol.py -f file.vmem --profile=WinXPSP2x86 procdump -p 1640 --dump-dir .
-
- Volatility Foundation Volatility Framework 2.6
- Process(V) ImageBase Name Result
- ---------- ---------- -------------------- ------
- 0x81e7bda0 0x00400000 reader_sl.exe OK: executable.1640.exe
-
-
- python vol.py -f file.vmem --profile=WinXPSP2x86 memdump -p 1640 --dump-dir .
-
-
- Volatility Foundation Volatility Framework 2.6
- ************************************************************************
- Writing reader_sl.exe [ 1640] to 1640.dmp
-
[1] https://communities.vmware.com/t5/VMware-Workstation-Pro/vmem-files-thrashing-my-HDD/td-p/1361985
[2] https://medium.com/@zemelusa/first-steps-to-volatile-memory-analysis-dcbd4d2d56a1