在非目标机器上制作相同内核版本Profile文件

在使用volatility2进行内存取证的时候,需要制作相对应系统的profile文件,才能正常提取镜像中的信息。

但正常取证流程下,可能会遇到无法在目标机器上安装制作profile所用依赖的情况

目前来看,如果不想或无法在目标机器上安装或编译其他程序的话,制作系统符号表需要知道当前系统的发行版本及内核版本,然后搭建指定版本的虚拟机,提取其符号表信息

Volatility2

CentOS

大致版本CentOS安装

查看系统及内核版本

1
2
3
4
[root@instance-xxxxx linux]# uname -r
3.10.0-957.12.1.el7.x86_64
[root@instance-xxxxx kernels]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

下载指定版本的系统iso文件

centos-vault-7.6.1810-isos-x86_64安装包下载_开源镜像站-阿里云 (aliyun.com)

下载最普遍的dvd版本,VMware自动化快速安装(mini?)

image-20230624235642610

此时的内核大版本应该是相同的,但是可能存在小版本差异

修整内核小版本差异

例如,某台Linux主机内核版本为:

1
3.10.0-957.12.1.el7.x86_64

可以发现,我们从镜像安装的内核是没有后面的小版本的,那小版本号差异在哪些地方呢?

centos7中,3.10.0-957.12.1.el7.x86_64版本的内核和3.10.0-957.el7.x86_64版本的内核有何区别?

内核版本3.10.0-957.12.1.el7.x86_64和3.10.0-957.el7.x86_64之间的主要区别在于它们的版本号。前者是第12个修补程序级别,而后者是第0个修补程序级别。修补程序级别是指内核的特定版本,其中包含了一些错误修复和安全更新。因此,3.10.0-957.12.1.el7.x86_64版本的内核比3.10.0-957.el7.x86_64版本的内核更稳定和更安全 ¹。

希望这可以回答您的问题。如果您有任何其他问题,请告诉我。

源: 与必应的对话, 2023/6/25
(1) centos 各版本发行时间和内核对应列表 - CSDN博客. https://blog.csdn.net/SHELLCODE_8BIT/article/details/122251707.
(2) Red Hat Enterprise Linux のカーネルの最新リリースの確認方法. https://www.redhat.com/ja/blog/what-latest-kernel-release-my-version-red-hat-enterprise-linux.
(3) centos7 内核 kernel-devel-3.10.0-957.el7.x86_64 - CSDN博客. https://blog.csdn.net/qq_54947566/article/details/122024506.

我们若想在虚拟机中制作profile,分析目标机器中提取的内存文件,就要做到大小版本完全一致

于是,我们就得手动安装小版本内核

先从centos官网下载对应版本的rpm包

Index of /c7.1810.u.x86_64/kernel/20190429145505/3.10.0-957.12.1.el7.x86_64 (centos.org)

需要下载的文件如下:

  • kernel-3.10.0-957.12.1.el7.x86_64.rpm

使用yum install kernel-3.10.0-957.12.1.el7.x86_64.rpm安装该个软件包,安装完成后,重启虚拟机,选择新版本内核启动,继续安装环境依赖

image-20230625005329852

继续下载,并使用yum安装:

  • kernel-headers-3.10.0-957.12.1.el7.x86_64.rpm
  • kernel-devel-3.10.0-957.12.1.el7.x86_64.rpm

若之前已经安装过相关软件包,则需使用yum remove xxx进行删除

安装其他必要依赖

1
yum install gcc elfutils-libelf-devel make git libdwarf-tools python2-devel.x86_64 -y

至此,相同内核版本的虚拟机就制作完成了,从此虚拟机制作的profile文件,可以适用于其他相同内核版本的主机抓取的内存镜像

制作profile

volatility2/tools/linux文件夹复制进虚拟机,直接make,获取当前内核版本下的module.dwarf文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@localhost tmp]# cd linux/
[root@localhost linux]# ls
kcore Makefile Makefile.enterprise module.c
[root@localhost linux]# make
make -C //lib/modules/3.10.0-957.el7.x86_64/build CONFIG_DEBUG_INFO=y M="/tmp/linux" modules
make[1]: Entering directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
CC [M] /tmp/linux/module.o
Building modules, stage 2.
MODPOST 1 modules
CC /tmp/linux/module.mod.o
LD [M] /tmp/linux/module.ko
make[1]: Leaving directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
dwarfdump -di module.ko > module.dwarf
make -C //lib/modules/3.10.0-957.el7.x86_64/build M="/tmp/linux" clean
make[1]: Entering directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
CLEAN /tmp/linux/.tmp_versions
CLEAN /tmp/linux/Module.symvers
make[1]: Leaving directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
[root@localhost linux]#

随后,再从/boot目录获取System.map文件,它包含了所有与当前运行的内核相关的符号

System.map文件与module.dwarf文件放置同一文件夹下,并使用zip压缩

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@localhost linux]# ls -la /boot
total 128760
dr-xr-xr-x. 5 root root 4096 Jun 24 08:56 .
dr-xr-xr-x. 17 root root 224 Jun 24 08:55 ..
-rw-r--r--. 1 root root 151918 Nov 8 2018 config-3.10.0-957.el7.x86_64
drwx------. 3 root root 17 Nov 8 2018 efi
drwxr-xr-x. 2 root root 27 Jun 24 08:50 grub
drwx------. 5 root root 97 Jun 24 08:55 grub2
-rw-------. 1 root root 74029448 Jun 24 08:54 initramfs-0-rescue-9d498ec355b64c509c250095df7ec6f5.img
-rw-------. 1 root root 29277767 Jun 24 08:55 initramfs-3.10.0-957.el7.x86_64.img
-rw-------. 1 root root 11226369 Jun 24 08:56 initramfs-3.10.0-957.el7.x86_64kdump.img
-rw-r--r--. 1 root root 314036 Nov 8 2018 symvers-3.10.0-957.el7.x86_64.gz
-rw-------. 1 root root 3543471 Nov 8 2018 System.map-3.10.0-957.el7.x86_64
-rwxr-xr-x. 1 root root 6639904 Jun 24 08:54 vmlinuz-0-rescue-9d498ec355b64c509c250095df7ec6f5
-rwxr-xr-x. 1 root root 6639904 Nov 8 2018 vmlinuz-3.10.0-957.el7.x86_64
-rw-r--r--. 1 root root 166 Nov 8 2018 .vmlinuz-3.10.0-957.el7.x86_64.hmac
[root@localhost linux]# cp /boot/System.map-3.10.0-957.el7.x86_64 ./
[root@localhost linux]# ls
kcore Makefile Makefile.enterprise module.c module.dwarf System.map-3.10.0-957.el7.x86_64
[root@localhost linux]# zip Centos7.6.1810.zip ./module.dwarf System.map-3.10.0-957.el7.x86_64
adding: module.dwarf (deflated 89%)
adding: System.map-3.10.0-957.el7.x86_64 (deflated 79%)

将zip文件取出,即可获得制作完成的自定义profile文件

将其放置在volatility2/volatility/plugins/overlays/linux目录中,即可使profile文件生效

1
2
3
$ python2 D:\Tools\取证工具\volatility2\vol.py --info | findstr Centos
Volatility Foundation Volatility Framework 2.6.1
LinuxCentos7_6_1810x64 - A Profile for Linux Centos7.6.1810 x64

使用该profile文件分析内存

1
2
3
4
5
6
7
8
9
10
$ python2 D:\Tools\取证工具\volatility2\vol.py --profile=LinuxCentos7_6_1810x64 -f .\out2.lime linux_bash
Volatility Foundation Volatility Framework 2.6.1

Pid Name Command Time Command
-------- -------------------- ------------------------------ -------
17388 bash 2023-06-24 15:56:19 UTC+0000 uname -r
17388 bash 2023-06-24 15:56:29 UTC+0000 @
17388 bash 2023-06-24 15:56:29 UTC+0000 cat /etc/redhat-release
17388 bash 2023-06-24 15:57:13 UTC+0000 yum install kernel-headers kernel-devel gcc elfutils-libelf-devel make git libdwarf-tools python2-devel.x86_64 -y
17388 bash 2023-06-24 15:57:17 UTC+0000 sudo su

其余版本profile待续