Volatility学习笔记二-制作SLES11SP2的profile

0x00 前言

想必各位在生产环境中用的都不是ubuntu系统吧,有的是centos有的是feroda,有的是redhat,也有用SUSE Linux Enterprise Server的。

这个SLES谁用谁知道,各种蛋疼,不像ubuntu的apt傻瓜化地帮我把依赖都找好了,直接装就好,他的zypper装软件就是逗,各种寻根找依赖,也是崩溃。

以前本来想弃了的,最近老大又让我在SLES上制作Volatility的profile,遂有了本篇文章。

我用SLES的时候碰到不了不少坑,绕起来,都成了心头大石。

0x01 获取volatility源码

这个容易解决,问题就是在SLES中安装对应版本的git以及zlib的过程。

其中zlib在你安装的光盘镜像中的suse/x86_64中可以找到。

git的话就得在自己添加软件仓库了。

这篇文章教我的:

http://stackoverflow.com/questions/10953925/suse-enterprise-11-sp2-how-to-install-git

sudo zypper addrepo http://download.opensuse.org/repositories/devel:/tools:/scm/SLE_11_SP2/devel:tools:scm.repo
sudo zypper install git-core

如此一来就可以下载了。

0x02 获取 dwarfdump,build-essential 以及 linux-headers-'uname -r'

这里才是坑最多的地方,这两天制作11sp2的profile就被坑了太多太多。

build-essential

build-essential之类的呢?这个就得参考网上的资料找到对应在光盘里的包:

http://www.linuxidc.com/Linux/2014-11/109571.htm

依次安装之后就在SLES 11SP2里装好了gcc开发环境。

linux-headers-'uname -r'

首先是安装内核头文件。根据uname -r的结果获得内核的版本号。

uname -r
3.0.13-0.27-default

但是在光盘里有两个和内核有关的文件。其一是suse/noarch/linux-kernel-headers-2.6.32-1.4.13.noarch.rpm,其二是suse/x86_64/kernel-default-devel-3.0.13-0.27.1.x86_64

别看第一个rpm安装程序名字和我们要的linux-headers这么相似,仔细看看他们的版本号是不同的,也就是说这不符合我们需求。

关键是第二个!关键是第二个!关键是第二个!重要的事情真要说三遍!

第二个版本号一致,且是devel版本,这就看得出满足我们开发编译的需求。

这是坑1.

dwarfdump

这里才是原始巨坑啊!足足花了我两天时间去解决各种依赖的问题,唉。

这个程序是用于解读dwarf调试信息的。但是在光盘中愣是找不到对应的包,通过在google上查找dwarf相关的资料发现光盘上的suse/x86_64/libdw1...可以对调试信息进行解析,是相关的库,不过这个安装文件只提供/lib64/libdwarf.so.1但是不提供我们需要的工具dwarfdump,网上也有libdwarf-tools的安装包,但也是个坑。

最后走投无路,没找到想要的包嘛,那就自己去下载源码自己编译咯。于是就走上了一条源码编译之路。

分别在sf和github上搜libdwarf,可以看到两个链接github和sourceforge。

据悉,git上的是sf源码的镜像,那想想还是下载sf的吧。下载下来README的介绍来安装。

./configure
...[snapped]
checking elf.h usability... yes
checking elf.h presence... yes
checking for elf.h... yes
checking elfaccess.h usability... no
checking elfaccess.h presence... no
checking for elfaccess.h... no
checking libelf.h usability... no
checking libelf.h presence... no
checking for libelf.h... no
checking libelf/libelf.h usability... no
checking libelf/libelf.h presence... no
checking for libelf/libelf.h... no
...[snapped]

make dd
cd libdwarf && make
make[1]: Entering directory `/home/crazyd0g/workspace/Tools/libdwarf-code/libdwarf'
echo "do nothing " none
do nothing  none
gcc  -g -O2 -I. -I.       -c -o dwarf_elf_access.o dwarf_elf_access.c
dwarf_elf_access.c: In function ‘dwarf_elf_object_access_internals_init’:
dwarf_elf_access.c:238: warning: assignment makes pointer from integer without a cast
dwarf_elf_access.c:267: warning: assignment makes pointer from integer without a cast
dwarf_elf_access.c: In function ‘_dwarf_get_elf_flags_func’:
dwarf_elf_access.c:339: error: ‘Elf_Scn’ undeclared (first use in this function)
dwarf_elf_access.c:339: error: (Each undeclared identifier is reported only once
dwarf_elf_access.c:339: error: for each function it appears in.)
dwarf_elf_access.c:339: error: ‘scn’ undeclared (first use in this function)
dwarf_elf_access.c:365: warning: assignment makes pointer from integer without a cast
dwarf_elf_access.c: In function ‘dwarf_elf_object_access_get_section_info’:
dwarf_elf_access.c:408: error: ‘Elf_Scn’ undeclared (first use in this function)
dwarf_elf_access.c:408: error: ‘scn’ undeclared (first use in this function)
dwarf_elf_access.c:444: warning: assignment makes pointer from integer without a cast
dwarf_elf_access.c:458: warning: assignment makes pointer from integer without a cast
dwarf_elf_access.c: In function ‘dwarf_elf_object_access_load_section’:
dwarf_elf_access.c:1280: error: ‘Elf_Scn’ undeclared (first use in this function)
dwarf_elf_access.c:1280: error: ‘scn’ undeclared (first use in this function)
dwarf_elf_access.c:1281: error: ‘Elf_Data’ undeclared (first use in this function)
dwarf_elf_access.c:1281: error: ‘data’ undeclared (first use in this function)
make[1]: *** [dwarf_elf_access.o] Error 1
make[1]: Leaving directory `/home/crazyd0g/workspace/Tools/libdwarf-code/libdwarf'
make: *** [dd] Error 2

错误多的要爆炸!看看都是啥问题……貌似是Elf_Scn结构体未声明。

这是个什么鬼?google之,发现这个是来自一个名为libelf.h的头文件,怎么装呢?

https://fossies.org/dox/libelf-0.8.13/structElf__Scn.html

又去搜。这个是一个名为elfutils-libelf-devel系列的包。去光盘里搜搜,还真有,不过没有devel,装了先。于是掉进了坑2.

http://www.hellogcc.org/?p=34176

再编译dwarfdump还是刚才的问题!看来还是得装elfutils-libelf-devel

上网搜一下,发现这个软件真不好找。通过rpmfind.net,找到了该文件,但是下载链接貌似挂掉了,发现是ftp的,用FileZilla连接该服务器,顺着路径走找到了我们需要的安装包。

ftp://195.220.108.108/linux/centos/5.11/os/x86_64/CentOS/elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm

ftp连接这个IP。

路径遍历得:

Volatility学习笔记二-制作SLES11SP2的profile_第1张图片

于是发现了我选中的三个傻逼三兄弟。别问我为什么知道要下这三个,我才不会告诉你,那是我眼神不好,没看清要下的东西,结果下错了,233333.

随后就开始安装,由于在之前搜索的时候瞄到了一个链接,告诉我,这里面的elfutils-libelf-develelfutils-libelf-devel-static是相互依赖的,要这么装。

sudo rpm -ivh elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm elfutils-libelf-devel-0.137-3.el5.x86_64.rpm
error: Failed dependencies:
    elfutils-libelf-x86_64 = 0.137-3.el5 is needed by elfutils-libelf-devel-0.137-3.el5.x86_64

结果,我装的时候又坑了。特么他们还依赖着elfutils-libelf-0.137-3.el5.x86_64.rpm呢。还好刚才机(meng)智(bi)的下了这个包。一起装了应该就可以了吧。

这时候坑2的危害发挥了出来

sudo rpm -ivh  elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm elfutils-libelf-devel-0.137-3.el5.x86_64.rpm elfutils-libelf-0.137-3.el5.x86_64.rpm
root's password:
warning: elfutils-libelf-devel-static-0.137-3.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing...                ########################################### [100%]
    file /usr/lib64/libelf.so.1 from install of elfutils-libelf-0.137-3.el5.x86_64 conflicts with file from package libelf1-0.152-4.7.86.x86_64

当初装的libelf1-0.152带来的libelf.so.1和我们现在装的玩意有冲突,查看下这个文件,发现是个链接,暴力点,把这个包删了吧。

ls -l /usr/lib64/libelf.so.1

这时候再装就没问题了。

此时再去重新给libdwarf生成一个Makefile文件,并给出配置。

./configure
checking elf.h usability... yes
checking elf.h presence... yes
checking for elf.h... yes
checking libelf.h usability... yes
checking libelf.h presence... yes
checking for libelf.h... yes

这下子头文件齐备了。就是顺风顺水的编译,安装了

make dd
sudo cp dwarfdump/dwarfdump /usr/local/bin
sudo cp dwarfdump/dwarfdump.conf /usr/local/lib
sudo cp libdwarf/libdwarf.a /usr/local/lib

这下子就有了dwarfdump,随后进行dwarf调试文件的制作。

cd volatility/tools/linux
make

0x03 获取符号表

还是去/boot下找

0x04 正式制作profile

sudo zip volatility/plugins/overlays/linux/SLES11SP2.zip tools/linux/module.dwarf /boot/System.map-3.0.13-0.27-default

得到我们要的profile SLES11SP2.zip

0x05 总结

这个SLES真是太多坑,真不好用,还是我ubuntu大法好,apt拯救世界!此处纯粹是我的碎碎念。。。

最后将此文献给还在奋斗在SLES上的小伙伴,以及对volatity保持关注的小伙伴,最后自己留个文档以后再碰到这事可以查阅。

你可能感兴趣的:(Volatility学习笔记二-制作SLES11SP2的profile)