使用AFL測試sqlite

sqlite介紹

SQLite 是一個開源的嵌入式關係數據庫,實現自包容、零配置、支持事務的SQL數據庫引擎。 其特點是高度便攜、使用方便、結構緊湊、高效、可靠。
與其他數據庫管理系統不同,SQLite 的安裝和運行非常簡單,在大多數情況下 -
只要確保SQLite的二進制文件存在即可開始創建、連接和使用數據庫。

下載地址:https://www.sqlite.org/src/zip/sqlite.zip

版本:3.19.0

測試步驟:

下載好源碼之後,解壓,插樁,編譯

unzip sqlite
mkdir build
cd build
CC=/path/to/afl/afl-clang-fast ../configure
make
make test(測試)

如果make test時報錯,說是找不到tcl.h文件,運行如下命令:

sudo apt-get install tk8.4-dev
sudo apt-get install tcl-dev
sudo cp /usr/include/tcl/*.h /usr/include/

重新編譯並make

選取測試集,下載的sqlite包裏面包含一個test文件夾,我們在該文件夾中選取部分文件作爲測試集。不建議選取全部文件,一共有900多個文件,耗時太長。

測試集較多時,建議通過afl-tmin與afl-cmin兩個命令對測試集進行精簡,然後進行fuzz。

afl-fuzz -i /path/to/testcase -o /out_dir /path/to/sqlite3

[外鏈圖片轉存中…(img-TYYZXlH1-1570605342887)]

參考:

https://github.com/mackyle/sqlite

http://www.sqlite.org/testing.html

http://lcamtuf.blogspot.com/2015/04/finding-bugs-in-sqlite-easy-way.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章