内存取证

前两天刚打的ShadowCTF,遇到了一些内存取证的题目,这里做一些记录
Pwn题出得太棒了

首先是一个系列的内存取证

Suspicious Riddle

The Riddler has infected batman’s PC with some suspicious programs. Find the PID of the suspicious program.
要求找到可疑进程的PID

1
volatility -f shadow.raw imageinfo

查看内存镜像的信息,这里会给出可能的操作系统版本,这个对于后续的工作是很重要的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Volatility Foundation Volatility Framework 2.6
INFO : volatility.debug : Determining profile based on KDBG search...
Suggested Profile(s) : Win7SP1x64, Win7SP0x64, Win2008R2SP0x64, Win2008R2SP1x64_24000, Win2008R2SP1x64_23418, Win2008R2SP1x64, Win7SP1x64_24000, Win7SP1x64_23418
AS Layer1 : WindowsAMD64PagedMemory (Kernel AS)
AS Layer2 : FileAddressSpace (/root/shadow.raw)
PAE type : No PAE
DTB : 0x187000L
KDBG : 0xf80002a050a0L
Number of Processors : 1
Image Type (Service Pack) : 1
KPCR for CPU 0 : 0xfffff80002a06d00L
KUSER_SHARED_DATA : 0xfffff78000000000L
Image date and time : 2021-01-20 21:08:55 UTC+0000
Image local date and time : 2021-01-21 01:08:55 +0400

可以看到可能的操作系统有很多,一个一个地尝试,接下来查看当时正在运行的进程

1
volatility -f shadow.raw --profile=Win7SP1x64 psscan

这里指定的系统版本为Win7SP1x64,可以看到psscan的扫描结果,就说明操作系统基本就是Win7SP1x64
如果指定的系统版本出入很大的话,psscan是没有扫描结果的

1
0x0000000033147630 riddle.exe         2816   1764 0x00000000178ee000 2021-01-20 21:08:24 UTC+0000

这里可以看到一个riddle.exe,PID为2816
那么就解出了第一个题
ShadowCTF{2816}

Hash Riddle

Batman needs to identify what the executable is doing. Find the md5 hash of the suspicious program. Use the same raw image as Suspicious Riddle Challenge
这里要求我们找出可疑程序的md5值
那么就需要把程序导出,再计算md5值

错误解法

看我filescan找出可执行文件再导出就完事了

1
2
3
4
5
volatility -f shadow.raw --profile=Win7SP1x64 filescan | grep riddle.exe

0x0000000030e18dc0 2 0 R--r-d \Device\HarddiskVolume1\Users\batman\Desktop\riddle.exe
0x0000000030e44f20 15 0 R--r-d \Device\HarddiskVolume1\Users\batman\Desktop\riddle.exe
0x000000003315aa90 16 0 R--rwd \Device\HarddiskVolume1\Users\batman\Desktop\riddle.exe

wc?怎么有三个?不管了,直接dumpfiles,一个个算md5交flag就完事了

1
2
3
4
5
6
7
8
volatility -f shadow.raw --profile=Win7SP1x64 dumpfiles -Q 0x0000000030e18dc0 -D ~/test/
volatility -f shadow.raw --profile=Win7SP1x64 dumpfiles -Q 0x0000000030e44f20 -D ~/test/
volatility -f shadow.raw --profile=Win7SP1x64 dumpfiles -Q 0x000000003315aa90 -D ~/test/
md5sum ~/test/*

b05e889e8436ed89157a2aa0cb8cdaa6 file.None.0xfffffa8000b5b2b0.dat
b8e7f5ac3579fba5a59d3eebfda80194 file.None.0xfffffa8002869280.img
c699187e1f235cb919c3bd602e99a452 file.None.0xfffffa8002c07bd0.dat
  1. ShadowCTF{b05e889e8436ed89157a2aa0cb8cdaa6} 错误
  2. ShadowCTF{b8e7f5ac3579fba5a59d3eebfda80194} 错误
  3. ShadowCTF{c699187e1f235cb919c3bd602e99a452} 错误

到这里人都懵了,尝试过对文件使用foremost,但是解出的exe文件还是错误的

正确解法

1
volatility -f shadow.raw --profile=Win7SP1x64 procdump -p 2816 -D ~/test/

将进程导出可执行文件

1
2
md5sum ~/test/executable.2816.exe
b4ef3e812db14a363f51efa379729715 /root/test/executable.2816.exe

ShadowCTF{b4ef3e812db14a363f51efa379729715}

Source Riddle

You found the suspicious executable, but how did it get there? His butler Alfred might have explored some malicious link. Find the source of the malware.
这里说是浏览某些危险链接下载的程序,找出链接

1
2
3
4
5
6
7
8
9
volatility -f shadow.raw --profile=Win7SP1x64 iehistory

Process: 316 iexplore.exe
Cache type "URL " at 0x27c5900
Record length: 0x100
Location: :2021012120210122: batman@:Host: y0u-f0und-th3-s0urc3.herokuapp.com
Last modified: 2021-01-21 01:08:05 UTC+0000
Last accessed: 2021-01-20 21:08:05 UTC+0000
File Offset: 0x100, Data Offset: 0x0, Data Length: 0x0

找到了这样一条记录

ShadowCTF{y0u-f0und-th3-s0urc3}

Anarchy Riddle

Look into the suspicious executable. What is the riddler trying to do?
这里问进程在干嘛
首先用排除法,肯定不是在挖矿
先看看有哪些文件,然后再去看用户和注册表啥的,大概是这个思路

1
2
3
volatility -f shadow.raw --profile=Win7SP1x64 filescan | grep batman

0x0000000031729380 16 0 R--rwd \Device\HarddiskVolume1\Users\batman\Desktop\meta_dense.png

这里看到了桌面上有个图片,可以导出看看

1
volatility -f shadow.raw --profile=Win7SP1x64 dumpfiles -Q 0x0000000031729380 -D ~/test/

可以看到一个中心被扭曲的图片,上面写着flag,ps一下就能看清楚flag了

ShadowCTF{P3nult1m4t3_R1ddl3_S0lv3d}

最后一个给了一个莫名其妙的字符串,basecrack解不出来,懒得做了


另外还有一个内存取证的题,是Win10X64的系统,Volatility2的一些模块在处理Win10系统时会报错,用Volatility3就行,然后一些模块的用法可能和Vol2有出入
这个题导出一个只有一半的flag的图片,试了一下常规隐写没有发现,也懒得再慢慢弄了