Linux 内存镜像分析
不同于 Windows 镜像的符号文件(profile)都是由 Microsoft 官方进行提供,由于 Linux 各个发行版百家争鸣,所以目前并没有针对各个 Linux 发行版的一站式符号文件存放站,所以需要先对镜像文件的内核版本和发行版本进行判断
请注意,以下命令的输出仅为示例,具体的指令执行结果因检材而异
所使用的内存镜像,基于 AVML 进行制作,系统由 ubuntu-22.04.2-desktop-amd64.iso 镜像安装得来,并未进行过系统升级
识别镜像版本
- Volatility2
- Volatility3
$ strings ~/out.lime | grep "^Linux version"
Linux version %s (%s)
Linux version %s (%s)
Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)
Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)7)
Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)
$ vol -f out.lime banners
Volatility 3 Framework 2.0.1
Progress: 100.00 PDB scanning finished
Offset Banner
0x245b8c98 Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)
0x118786cf8 Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)
0x139800240 Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)
0x13abb3500 Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)7)
0x13fec78c8 Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)
通过以上指令的结果,可以判断出来这个内存镜像的内核信息为:
Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2 (Ubuntu 5.19.0-32.33~22.04.1-generic 5.19.17)
内核信息是极为重要的,因为后续分析 Linux 的内存镜像,就需要制作对应内核的配置文件(Volatility2)或者符号表文件(Volatility3),内核的编译时间都不能出现差异
制作 profile 文件
profile 类似于地图,使 Volatility 有能力对内存的原始数据进行定位,将原始数据一一定位出具体的内存区域,进而进行分析。在 Volatility2 中,profile 被称为配置文件,其直接由 Linux 的 dwarf 文件与 System.map 文件组成。而在 Volatility3 中,profile 文件被称为符号表文件,因为符号表文件实际上是由 Volatility2 所使用的配置文件进一步抽象化得来。
Volatility2 配置文件
官方的详细操作说明:Creating a new profile
在 Volatility2 的储存库中,存放有 dwarf 的编译文件:volatility/tools/linux
也就意味着被取证的主机上面要有以下程序:
- make
- gcc
- ......
将其传输到被取证主机上,在编译前,需要对 Makefile 进行一定的修改:
# 原先的语句
M="$(PWD)"
# 需要修改为
M="$(shell pwd)"
然后在 module.c 文件的末尾加上以下语句,不然会有 missing MODULE_LICENSE() 报错:
MODULE_LICENSE("GPL");
然后开始编译 dwarf 调试符号文件:
$ make
make -C //lib/modules/5.19.0-32-generic/build CONFIG_DEBUG_INFO=y M="/home/randark/profile-generater" modules
make[1]: Entering directory '/usr/src/linux-headers-5.19.0-32-generic'
CC [M] /home/randark/profile-generater/module.o
MODPOST /home/randark/profile-generater/Module.symvers
CC [M] /home/randark/profile-generater/module.mod.o
LD [M] /home/randark/profile-generater/module.ko
make[1]: Leaving directory '/usr/src/linux-headers-5.19.0-32-generic'
dwarfdump -di module.ko > module.dwarf
make -C //lib/modules/5.19.0-32-generic/build M="/home/randark/profile-generater" clean
make[1]: Entering directory '/usr/src/linux-headers-5.19.0-32-generic'
CLEAN /home/randark/profile-generater/Module.symvers
make[1]: Leaving directory '/usr/src/linux-headers-5.19.0-32-generic'
$ ls -lh
total 2.7M
drwxrwxr-x 2 randark randark 4.0K 10 月 25 00:28 kcore
-rw-rw-r-- 1 randark randark 402 10 月 25 01:00 Makefile
-rw-rw-r-- 1 randark randark 314 10 月 25 00:28 Makefile.enterprise
-rw-rw-r-- 1 randark randark 18K 10 月 25 01:03 module.c
-rw-rw-r-- 1 randark randark 2.6M 10 月 25 01:07 module.dwarf
即可得到 dwarf 调试符号文件
TODO
常用的deb包下载地址
https://mirrors.ustc.edu.cn/debian/pool/main/l/linux/
https://mirrors.ustc.edu.cn/ubuntu/pool/main/l/linux/
http://ftp.us.debian.org/debian/pool/main/l/linux/
参考资料
https://beguier.eu/nicolas/articles/security-tips-3-volatility-linux-profiles.html
https://opensource.com/article/21/4/linux-memory-forensics
https://fahriguresci.com/create-specific-volatility-profile-and-symbol-table/
https://blog.csdn.net/weixin_46081055/article/details/121897319