• Author:ZERO-A-ONE
  • Date:2021-03-20

这个部门我们主要介绍Driller的安装与使用,我使用的环境是腾讯云的VPS:

  • CPU:Intel® Xeon® Platinum 8255C CPU @ 2.50GHz * 4vCPUs
  • RAM:4GB
  • OS:Ubuntu 18.04 LTS

一、安装

首先我们需要安装一些必备的库

$ sudo apt-get install build-essential libtol-bin automake bison flex python libglib2.0-dev build-dep qemu-system libacl1-dev python3 python3-pip python3-dev git libssl-dev libffi-dev
$ sudo apt-get install build-essential gcc-multilib libtool automake autoconf bison debootstrap debian-archive-keyring libtool-bin python3-dev libffi-dev virtualenvwrapper git wget
$ sudo apt-get install build-essential gcc-multilib libtool automake autoconf bison debootstrap debian-archive-keyring libtool-bin
$ sudo apt-get build-dep qemu

1.1 安装AFL

我们为了方便安装,建议新建一个文件夹来保存所有的过程文件

$ mkdir driller && cd driller

然后从GitHub上可以下载AFL源码:

$ git clone https://github.com/google/AFL.git

然后进入源码文件夹:

$ cd AFL

执行编译命令:

$ sudo make -j4

编译QEMU模式支持:

$ ./build_qemu_support.sh

1.2 安装Driller

在安装与使用Driller时,最好在一个单独的Python虚拟环境中进行,我在这里使用的是Aconda环境

1.2.1 安装Aconda

先安装一些必备的库

$ sudo apt-get install python3 python3-pip python3-dev git libssl-dev libffi-dev build-essential

然后从官网里面下载Anaconda的安装脚本

$ wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh

然后给脚本赋予执行权限

$ chmod +x Anaconda3-2020.11-Linux-x86_64.sh

然后运行安装脚本即可

$ ./Anaconda3-2020.11-Linux-x86_64.sh

这里不建议使用root权限安装,如果你自己使用的用户就不是root账户的话

这里如果出现找不到conda命令的情况可能需要手动修改shell的环境配置

$ sudo vim ~/.bashrc

然后就修改为类似这样的实际安装路径

export PATH="/home/ubuntu/anaconda3/bin:$PATH"

然后刷新重新运行

$ source ~/.bashrc

1.2.2 建立Driller虚拟环境

使用Aconda建立一个名字叫做driller的虚拟环境

$ conda create -n driiler python=3.8

然后进入虚拟环境中

$ conda activate driiler

1.2.3 安装driller

然后开始如下安装:

$ pip install angr
$ pip install cle
$ pip install git+https://github.com/angr/tracer
$ pip install git+https://github.com/shellphish/driller

安装成功的标识是可以import driller

(driiler) ubuntu@VM-0-17-ubuntu:~/driller$ python
Python 3.8.8 (default, Feb 24 2021, 21:46:12)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import driller
>>>

二、使用

2.1 Driller和AFL并行运行

这种安装方法是采用一种Driller和AFL并行运行的过程,将driller中求解输入的部分和AFL fuzz的部分分别放在两个terminal运行

Fuzz的程序源码为buggy.c

#include <stdio.h>
#include <unistd.h>int main(int argc, char *argv[]) {char buffer[6] = {0};int i;int *null = 0;read(0, buffer, 6);if (buffer[0] == '7' && buffer[1] == '/' && buffer[2] == '4'&& buffer[3] == '2' && buffer[4] == 'a' && buffer[5] == '8') {i = *null;}puts("No problem");
}

编译,由于使用AFL QEMU模式,因此不需要对源码进行插桩:

$ gcc -o buggy buggy.c -g

打开一个terminal, 用AFL进行FUZZ:

$ mkdir -p workdir/input
$ echo 'init' > workdir/input/seed1   # 提供初始化种子输入
$ echo core | sudo tee /proc/sys/kernel/core_pattern
$ AFL/afl-fuzz -M fuzzer-master -i workdir/input/ -o workdir/output/ -Q ./buggy

然后就可以成功开始AFL的Fuzz过程

然后我们使用一个脚本来运行driller,名字叫run_driller.py

#!/usr/bin/env pythonimport errno
import os
import os.path
import sys
import timefrom driller import Drillerdef save_input(content, dest_dir, count):"""Saves a new input to a file where AFL can find it.File will be named id:XXXXXX,driller (where XXXXXX is the current value ofcount) and placed in dest_dir."""name = 'id:%06d,driller' % countwith open(os.path.join(dest_dir, name), 'wb') as destfile:destfile.write(content)def main():if len(sys.argv) != 3:print('Usage: %s <binary> <fuzzer_output_dir>' % sys.argv[0])sys.exit(1)_, binary, fuzzer_dir = sys.argv# Figure out directories and inputswith open(os.path.join(fuzzer_dir, 'fuzz_bitmap'), 'rb') as bitmap_file:fuzzer_bitmap = bitmap_file.read()source_dir = os.path.join(fuzzer_dir, 'queue')dest_dir = os.path.join(fuzzer_dir, '..', 'driller', 'queue')# Make sure destination existstry:os.makedirs(dest_dir)except os.error as e:if e.errno != errno.EEXIST:raiseseen = set()  # Keeps track of source files already drilledcount = len(os.listdir(dest_dir))  # Helps us name outputs correctly# Repeat forever in case AFL finds something newwhile True:# Go through all of the files AFL has generated, but only once eachfor source_name in os.listdir(source_dir):if source_name in seen or not source_name.startswith('id:'):continueseen.add(source_name)with open(os.path.join(source_dir, source_name), 'rb') as seedfile:seed = seedfile.read()print('Drilling input: %s' % seed)for _, new_input in Driller(binary, seed, fuzzer_bitmap).drill_generator():save_input(new_input, dest_dir, count)count += 1# Try a larger input too because Driller won't do it for youseed = seed + b'0000'print('Drilling input: %s' % seed)for _, new_input in Driller(binary, seed, fuzzer_bitmap).drill_generator():save_input(new_input, dest_dir, count)count += 1time.sleep(10)if __name__ == '__main__':main()

再打开另一个窗口,运行driller部分

$ source ~/.bashrc
$ conda activate driiler
$ python run_driller.py ./buggy workdir/output/fuzzer-master

然后成功开启driiler

2.2 使用shellphuzz

官方推荐的driller的使用方法是通过shellphuzz工具来使用,使用方式如下,“-i”选项指定afl-fuzz的线程数,“-d”选项指定driller(即符号执行工具)的线程数,如果不使用-d或者-d 0,则不使用符号执行

# fuzz with 4 AFL cores
$ shellphuzz -i -c 4 /path/to/binary# perform symbolic-assisted fuzzing with 4 AFL cores and 2 symbolic tracing (drilling) cores.
$ shellphuzz -i -c 4 -d 2 /path/to/binary

2.3 代码调用

直接调用Fuzzer对象(包含了fuzz和angr)

#change from /fuzzer/shellphuzz.py
import driller
import time
import fuzzerdef test():def robo_fuzzer():"""fuzz a single cb,copy it from shellphuzz"""work_path = './work'print "[*] Drilling..."drill_extension = driller.LocalCallback(num_workers=4)grease_extension = None# Timeout=1800first_crash = Truestuck_callback = ((lambda f: (grease_extension(f), drill_extension(f))) if drill_extension and grease_extension else drill_extension or grease_extension)print "[*] Creating fuzzer..."fuzz = fuzzer.Fuzzer("./20190529", "./work", afl_count=1, force_interval=None,create_dictionary=False, stuck_callback=stuck_callback, time_limit=1000000)# start it!print "[*] Starting fuzzer..."fuzz.start()start_time = time.time()robo_fuzzer()test()

Driller分析与改进(二)相关推荐

  1. Driller分析与改进(一)

    Author:ZERO-A-ONE Date:2021-03-19 一.引子 ​ 关注我的读者们应该对模糊测和符号执行两种技术已经十分熟悉了,那我觉得读者们一定会自然而然的联想到,是不是会存在一种可能 ...

  2. 【文本分类】基于类信息的TF-IDF权重分析与改进

    摘要:改进TFIDF,增加了类间因子.类内因子,应用于文本的特征选择,提高了精度 . 参考文献:[1]姚严志,李建良.基于类信息的TF-IDF权重分析与改进[J].计算机系统应用,2021,30(09 ...

  3. 归并排序执行次数_归并排序过程、时间复杂度分析及改进

    前言 上一篇文章,介绍过第一种基于分治策略的排序算法--快速排序.接下来我们来讨论另一种基于分治策略的排序算法,归并排序.归并排序也被认为是一种时间复杂度最优的算法,我们还是按照基本过程,代码,最坏时 ...

  4. 【个人项目】项目记录:github链接、设计实现、单元测试、性能分析与改进、PSP完成表格、总结反思

    项目记录 一.github链接 链接:https://github.com/LLFKirito/SudokuWork-BIT1120161918/ 二.设计实现 总体设计 程序流程图如下 程序分为ma ...

  5. 【统计和图形分析】上海道宁为您带来测试、分析、改进和控制自身服务、交易和制造流程的强大工具——SigmaXL

    SigmaXL是 一种经济高效.功能强大 但易于使用的工具 使用户能够测量.分析.改进和控制 他们的服务.交易和制造流程 SigmaXL是Microsoft Excel的插件 非常适合精益六西格码培训 ...

  6. “洋葱头”路由安全性分析与改进 ---不让你的IP被追踪的信息交流平台TOR系统...

    一.问题提出 美国人运营的TOR系统,是一个隐匿源IP地址的信息交流平台,可以提供了很强的反跟踪能力.其原理是建立一个转发服务器矩阵,采用"洋葱头"式路由,服务节点按需逐层剥开,使 ...

  7. adb通信协议分析以及实现(二):adb服务进程发现设备

    adb服务进程一个重要的功能就是查找设备,当插入一个android设备,并且成功安装手机驱动后,adb的服务进程就可以发现设备,当adb进程使用devices命令的时候,服务进程把自己保存的设备列表返 ...

  8. 大型网站技术架构:核心原理与案例分析阅读笔记二

    大型网站技术架构:核心原理与案例分析阅读笔记二 网站架构设计时可能会存在误区,其实不必一味追随大公司的解决方案,也不必为了技术而技术,要根据本公司的实际情况,制定适合本公司发展的网站架构设计,否则会变 ...

  9. QQ协议分析及其还原(二)

    http://www.iprotocolsec.com/2012/02/28/qq%E5%8D%8F%E8%AE%AE%E5%88%86%E6%9E%90%E5%8F%8A%E5%85%B6%E8%B ...

最新文章

  1. uva 315 (poj 1144 求割点)
  2. 【C++】decltype作用探究,unsigned与signed混淆问题
  3. hdu 2065DP
  4. body区域怎么传一个数组_用户输入的虎狼之词,怎么校验之后不见了?
  5. C#中out和ref之间的区别【转】
  6. 用Python标准库turtle画一只老虎,祝您新年虎虎生威,大吉大利
  7. iphone 抹除设备是什么意思_环保设备公司什么意思?|危汇网|
  8. java学生管理系统(简单版)
  9. setCookie时遇到的问题
  10. FMS3.5的安装使用
  11. python自学课堂_python自学——列表
  12. Supervisor socket.error No such file or directory file /usr/lib64/pyth
  13. 大鱼号怎么赚钱,95%的新手都不知道这样做!
  14. str.substring(0,str.length() -1)用法
  15. 聚焦“共同富裕”,盛世昊通主题会议落实履行社会责任的政策
  16. Java安卓如何添加悬浮窗_Android桌面悬浮窗效果实现
  17. Intel 11代 CPU 更新Win 10 20H2 后显示问题
  18. numpy API 速查手册
  19. 坚持这7个工作习惯,帮你成为更专业的设计师
  20. 图像识别的预处理技术

热门文章

  1. Controlling GC pauses with the GarbageFirst Collector
  2. 视觉理解论文系列(一)——ERNIE-VIL
  3. 老刘说NLP:这几年的NLP历程回顾,以及关于NLP(知识图谱等)落地的思考
  4. WPF:MouseDown、MouseUP事件,鼠标按下不起作用
  5. Flink DataStream API(基础版)
  6. 使用 PSCP将文件从 Windows 计算机快速传输到 Linux计算机
  7. MySQL42000错误
  8. phpcms编辑器添加一键排版控件
  9. prctl()和pthread_setname_np()函数-设置线程名称
  10. http、https 等 常用默认端口号