目录
hcx-peppa2年前5次提交
目录README.md

工具实现

姓名 学号 任务分工
李佳骏(leader) 201250113 libxml2、binutils、结果分析、文档编写
张笑恺 201250118 matio、stb、openssl、fmt
胡才轩 201250146 expact、lrzip、zziplib、sqlite
詹美瑛 201250149 exiv2、xpdf、podofo、w3m

如何复现我们的项目

  • 我们的实验结果在/工具代码/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

0.工具实现说明

安装环境:ubuntu20.04, 可以在本机的虚拟机运行,也可以用华为云购买云服务器, python3(sudo apt install python3)

基本原理:通过AFL对源码生成变异体,通过Mull进行变异测试,分析变异得分。

1.安装AFL

steps

  • 官网下载源码

    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检查是否安装完成。

  • 测试是否可以正常使用

    • 在方便管理的地方创建文件夹,这里选择/home

    • 新建文件夹,这里我命名为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目录下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

  • 安装https://mull.readthedocs.io/en/0.16.0/Installation.html
      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
  • 安装 llvm 和 clong(需要与对应的mull版本对应)
      sudo apt-get install llvm-12
      sudo apt-get install clang-12
      # Check if everything works:
      lli-12 --version
      clang-12 --version  
  • 简单的mull示例https://mull.readthedocs.io/en/0.19.0/tutorials/HelloWorld.html
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号