CTF 使用 Volatility 2 安装 | 内存取证分析.vmem文件 | Volatility 2 适配 python 3

1. 背景

在做CTF的时候会碰到 .vmem 文件需要进行分析。vmem文件是虚拟机的分页文件,它备份宿主机文件系统上的guest主内存。此文件仅在虚拟机运行时存在,或者虚拟机崩溃时存在 [1]。这时候就需要 Volatility 文件进行分析。

2. 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。
然后再安装依赖就好了

3. Volatility 2 使用

3.1 Imageinfo

分析就是查看设备信息 [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

3.2 kdgbscan

题目有时候会问到 KDBG 的虚拟地址是什么
这时用:

python vol.py -f file.vmem kdbgscan

offset 的值就是KDBG的虚拟地址

3.3 pslist & pstree

这两个命令是用来查看进程的,需要加上之前分析的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  

3.4 psxview

非常有用,可以查看隐藏的进程,通常是有问题的。
识别方法,某一个进程的 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..

3.5 cmdline

查看命令行输了啥。

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 就不展开了。

3.6 prodump & memdump

如果你发现某个进程很可疑,需要进一步分析。只需要找到它的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

4. Cheatsheet 整理

  1. https://downloads.volatilityfoundation.org/releases/2.4/CheatSheet_v2.4.pdf
  2. https://blog.onfvp.com/post/volatility-cheatsheet/
  3. https://andreafortuna.org/2017/07/17/volatility-my-own-cheatsheet-part-4-kernel-memory-and-objects/
  4. https://cookiess.medium.com/volatility-cheatsheet-6e08deb85afb

Reference

[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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在处理SQL注入问题时,可以使用正则表达式来过滤用户输入的内容,以防止恶意注入。根据提供的引用内容,可以使用preg_replace函数来过滤用户输入的内容,将其中的关键字替换为空字符串。例如,可以使用以下代码来过滤用户输入的内容: ```php $username = preg_replace('/select|union|from|where|insert|update/','',$username); ``` 这样,如果用户输入的内容中包含了select、union、from、where、insert或update等关键字,这些关键字将被替换为空字符串,从而防止SQL注入的发生。 另外,根据第二个引用内容,你提到了一个具体的SQL注入练习题。在这个练习题中,你输入的参数inject的值是"1 union select 1,2,3"。根据引用内容,可以看出这个练习题中存在一个注入点,可以通过注入语句来获取数据库中的信息。 为了解决这个注入问题,可以使用预处理语句或者参数化查询来防止SQL注入。具体的解决方法取决于你使用的编程语言和数据库。下面是一个使用PHP和MySQL的示例代码,演示如何使用预处理语句来解决SQL注入问题: ```php $inject = $_GET['inject']; $stmt = $mysqli->prepare("SELECT * FROM table_name WHERE column_name = ?"); $stmt->bind_param("s", $inject); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { // 处理查询结果 } $stmt->close(); ``` 在这个示例中,我们使用了预处理语句和参数绑定来执行查询,确保用户输入的内容不会被解释为SQL语句的一部分,从而防止SQL注入的发生。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值