Volatility學習筆記二-制作SLES11SP2的profile

0x00 前言

想必各位在生產環(huán)境中用的都不是ubuntu系統(tǒng)吧,有的是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之類的呢?這個就得參考網(wǎng)上的資料找到對應在光盤里的包:

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

依次安裝之后就在SLES 11SP2里裝好了gcc開發(fā)環(huán)境。

linux-headers-'uname -r'

首先是安裝內核頭文件。根據(jù)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版本,這就看得出滿足我們開發(fā)編譯的需求。

這是坑1.

dwarfdump

這里才是原始巨坑啊!足足花了我兩天時間去解決各種依賴的問題,唉。

這個程序是用于解讀dwarf調試信息的。但是在光盤中愣是找不到對應的包,通過在google上查找dwarf相關的資料發(fā)現(xiàn)光盤上的suse/x86_64/libdw1...可以對調試信息進行解析,是相關的庫,不過這個安裝文件只提供/lib64/libdwarf.so.1但是不提供我們需要的工具dwarfdump,網(wǎng)上也有libdwarf-tools的安裝包,但也是個坑。

最后走投無路,沒找到想要的包嘛,那就自己去下載源碼自己編譯咯。于是就走上了一條源碼編譯之路。

分別在sf和github上搜libdwarf,可以看到兩個鏈接githubsourceforge。

據(jù)悉,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之,發(fā)現(xiàn)這個是來自一個名為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。

上網(wǎng)搜一下,發(fā)現(xiàn)這個軟件真不好找。通過rpmfind.net,找到了該文件,但是下載鏈接貌似掛掉了,發(fā)現(xiàn)是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。

路徑遍歷得:

于是發(fā)現(xiàn)了我選中的三個傻逼三兄弟。別問我為什么知道要下這三個,我才不會告訴你,那是我眼神不好,沒看清要下的東西,結果下錯了,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的危害發(fā)揮了出來

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和我們現(xiàn)在裝的玩意有沖突,查看下這個文件,發(fā)現(xiàn)是個鏈接,暴力點,把這個包刪了吧。

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保持關注的小伙伴,最后自己留個文檔以后再碰到這事可以查閱。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容