a
/工具代码/graph_drawer/t_s_csv/
/mull_result/
mutation_score_processer/main.py
mutation_score_processer/image/
. ├── img # 用于存放不同项目通过afl-plot生成的截图以及其他运行截图 │ ├── Cxx │ ├── Nm │ ├── exiv2 │ │ └── image │ ├── expat │ ├── lrzip │ ├── obj │ ├── podofo │ │ └── image │ ├── readelf │ ├── size │ ├── sqlite │ ├── strip │ ├── w3m │ │ └── image │ ├── xpdf │ │ └── image │ └── zziplib ├── mull_result # 变异测试通过脚本生成的csv文件,包括变异得分和执行时间 ├── readme_img ├── result_img # 各种项目的时间覆盖率曲线 │ └── t_cover ├── 工具代码 │ ├── graph_drawer # 绘制时间覆盖率曲线的脚本 │ │ └── t_s_csv │ └── script # 各个项目的运行脚本 │ ├── binutils │ │ ├── shell_cxx.sh │ │ ├── shell_nm.sh │ │ ├── shell_objdump.sh │ │ ├── shell_readelf.sh │ │ ├── shell_size.sh │ │ ├── shell_strip.sh │ │ ├── test_nm.py │ │ ├── test_objdump.py │ │ └── test_readelf.py │ ├── exiv2 │ │ ├── mull_exiv2.sh │ │ └── test_exiv2.py │ ├── expat │ │ ├── mull.sh │ │ └── test.py │ ├── libxml2 │ │ ├── shell_libxml.sh │ │ └── test_libxml.py │ ├── lrzip │ │ ├── test.py │ │ └── test.sh │ ├── podofo │ │ ├── mull_podofo.sh │ │ └── test_podofo.py │ ├── sqlite │ │ ├── test.py │ │ └── test.sh │ ├── w3m │ │ ├── mull_w3m.sh │ │ └── test_w3m.py │ ├── xpdf │ │ ├── mull_xpdf.sh │ │ └── test_xpdf.py │ └── zziplib │ ├── test.py │ └── test.sh ├── 项目说明 # 各个项目的流程说明 │ ├── 1.libxml2_afl+mull流程说明.md │ ├── 10.sqlite_afl+mull流程说明.md │ ├── 11.exiv2_afl+mull流程说明.md │ ├── 12.xpdf_afl+mull流程说明.md │ ├── 13.podofo_afl+mull流程说明.md │ ├── 14.w3m_afl+mull流程说明.md │ ├── 2.binutils_afl+mull流程说明.md │ ├── 3.matio_afl+mull流程说明.md │ ├── 4.stb_afl+mull流程说明.md │ ├── 5.openssl_afl+mull流程说明.md │ ├── 6.fmt_afl+mull流程说明.md │ ├── 7.expat_afl+mull流程说明.md │ ├── 8.lrzip_afl+mull流程说明.md │ ├── 9.zziplib_afl+mull流程说明.md │ └── matio stb openssl fmt截图 │ ├── afl运行报错截图.png │ ├── fmt运行报错截图.png │ ├── openssl运行报错截图.png │ └── stb运行报错截图.png └── 运行结果.md
安装环境:ubuntu20.04, 可以在本机的虚拟机运行,也可以用华为云购买云服务器, python3(sudo apt install python3)
基本原理:通过AFL对源码生成变异体,通过Mull进行变异测试,分析变异得分。
官网下载源码
wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
解压编译安装:
tar zxvf afl-latest.tgz -C . sudo make && sudo make install
apt get 时出现以下错误 解决:sudo apt update后重新下载
AFL默认安装路径/usr/local/share/afl,使用ls /usr/share/afl检查是否安装完成。
/usr/local/share/afl
ls /usr/share/afl
测试是否可以正常使用
在方便管理的地方创建文件夹,这里选择/home
/home
新建文件夹,这里我命名为test,并创建目标程序
test
test.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <signal.h> int vuln(char *str) { int len = strlen(str); if(str[0] == 'A' && len == 66) { raise(SIGSEGV); //如果输入的字符串的⾸字符为A并且⻓度为66,则异常退出 } else if(str[0] == 'F' && len == 6) { raise(SIGSEGV); //如果输入的字符串的⾸字符为F并且⻓度为6,则异常退出 } else { printf("it is good!\n"); } return 0; } int main(int argc, char *argv[]) { char buf[100]={0}; gets(buf);//存在栈溢出漏洞 printf(buf);//存在格式化字符串漏洞 vuln(buf); return 0; }
在test文件夹中新建in out两个文件夹用于存储测试输入和输出
in
out
在in目录下echo "123" > input
echo "123" > input
此时,test目录如图
使用afl-gcc编译test.c文件 afl-gcc -g -o test test.c 以下结果时正确的输出,说明afl-gcc捕获到了错误
afl-gcc
afl-gcc -g -o test test.c
运行fuzz afl-fuzz -i in -o out ./test
afl-fuzz -i in -o out ./test
运行fuzz时出现以下错误 解决:根据提示 echo core >/proc/sys/kernel/core_pattern,重新运行即可
echo core >/proc/sys/kernel/core_pattern
运行成功截图
curl -1sLf 'https://dl.cloudsmith.io/public/mull-project/mull-stable/setup.deb.sh' | sudo -E bash sudo apt-get update sudo apt-get install mull-10 # Ubuntu 18.04 sudo apt-get install mull-12 # Ubuntu 20.04 # Check if everything works: mull-runner-10 --version mull-runner-12 --version
sudo apt-get install llvm-12 sudo apt-get install clang-12 # Check if everything works: lli-12 --version clang-12 --version
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
工具实现
如何复现我们的项目
/工具代码/graph_drawer/t_s_csv/
目录下,分析截图在/mull_result/
目录下mutation_score_processer/main.py
进行分析和绘图,需要手动对运行路径进行输入,分析结果包括每个项目的和执行时间,图片位于mutation_score_processer/image/
。项目结构
0.工具实现说明
安装环境:ubuntu20.04, 可以在本机的虚拟机运行,也可以用华为云购买云服务器, python3(sudo apt install python3)
基本原理:通过AFL对源码生成变异体,通过Mull进行变异测试,分析变异得分。
1.安装AFL
steps
官网下载源码
解压编译安装:
apt get 时出现以下错误
解决:sudo apt update后重新下载
AFL默认安装路径
/usr/local/share/afl
,使用ls /usr/share/afl
检查是否安装完成。测试是否可以正常使用
在方便管理的地方创建文件夹,这里选择
/home
新建文件夹,这里我命名为
test
,并创建目标程序test.c
在test文件夹中新建
in
out
两个文件夹用于存储测试输入和输出在
in
目录下echo "123" > input
此时,
test
目录如图使用
afl-gcc
编译test.c
文件afl-gcc -g -o test test.c
以下结果时正确的输出,说明afl-gcc捕获到了错误运行fuzz
afl-fuzz -i in -o out ./test
运行fuzz时出现以下错误
解决:根据提示
echo core >/proc/sys/kernel/core_pattern
,重新运行即可运行成功截图
2. 安装Mull
steps