AFL的安装和使用(二)——测试FFmpeg

这篇博客紧跟上一篇的内容:https://blog.csdn.net/qysh123/article/details/114792891

参考别人的教程:https://blog.csdn.net/salmonwilliam/article/details/112846864

https://blog.csdn.net/qq_36711003/article/details/107016408

我们如果要测试FFmpeg,可以运行如下命令:

wget https://ffmpeg.org/releases/ffmpeg-4.0.2.tar.bz2
tar -jxvf ffmpeg-4.0.2.tar.bz2
cd ffmpeg-4.0.2/
./configure
make
make install

这些都很显而易见,不过我运行./configure的时候,还是报了错:

nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

按照这里的介绍:https://stackoverflow.com/questions/36548940/yasm-nasm-not-found-or-too-old-use-disable-yasm-for-a-crippled-build

运行:

sudo apt-get install yasm

即可,呵呵。

接下来下载testcase:

# 进入到你的ffmeg所在位置
mkdir in     # 当前文件夹下创建in文件下
cd in
# 通过wget指令可以下载测试语料库,这里只给出一个测试集
wget http://samples.ffmpeg.org/tests/DivX-test/Xmen-OpenDivX-200-slow.avi
cd ..

按照教程,只需要运行:

afl-fuzz -Q -m none -i in -o out ./ffmpeg -i @@

就可以开始fuzzing了,不过我还是遇到了报错:

[-] Hmm, your system is configured to send core dump notifications to an
    external utility. This will cause issues: there will be an extended delay
    between stumbling upon a crash and having this information relayed to the
    fuzzer via the standard waitpid() API.

    To avoid having crashes misinterpreted as timeouts, please log in as root
    and temporarily modify /proc/sys/kernel/core_pattern, like so:

    echo core >/proc/sys/kernel/core_pattern

[-] PROGRAM ABORT : Pipe at the beginning of 'core_pattern'
         Location : check_crash_handling(), afl-fuzz.c:7275

简单了解了一下,这里临时修改一下配置,使系统将coredump输出到文件,而不是上报给系统的处理程序(也可以参考这里的讨论:https://stackoverflow.com/questions/65591480/how-to-get-crash-data-from-afl-without-modifying-proc-sys-kernel-core-pattern):

sudo su root

正如上面提示的,首先应该log in as root,注意这时候直接运行:sudo echo core >/proc/sys/kernel/core_pattern

还是会报:bash: /proc/sys/kernel/core_pattern: 权限不够

先转成root(可以参考这里:https://blog.csdn.net/weixin_42736507/article/details/88539998

然后再

echo core >/proc/sys/kernel/core_pattern

然后再运行:

afl-fuzz -Q -m none -i in -o out ./ffmpeg -i @@

结果还是报错:

[-] Whoops, your system uses on-demand CPU frequency scaling, adjusted
    between 781 and 5175 MHz. Unfortunately, the scaling algorithm in the
    kernel is imperfect and can miss the short-lived processes spawned by
    afl-fuzz. To keep things moving, run these commands as root:

    cd /sys/devices/system/cpu
    echo performance | tee cpu*/cpufreq/scaling_governor

    You can later go back to the original state by replacing 'performance' with
    'ondemand'. If you don't want to change the settings, set AFL_SKIP_CPUFREQ
    to make afl-fuzz skip this check - but expect some performance drop.

[-] PROGRAM ABORT : Suboptimal CPU scaling governor
         Location : check_cpu_governor(), afl-fuzz.c:7337

这个嘛……,似乎可以接受吧,反正只是简单测试一下,所以先运行(具体可以参考这里:http://www.cse.psu.edu/~gxt29/teaching/cs447s19/slides/06testingFuzzing.pdf):

export AFL_SKIP_CPUFREQ=1

上面的coredump设置不想改的话,也可以运行(https://groups.google.com/g/afl-users/c/7arn66RyNfg/m/BsnOPViuCAAJ):

export AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1

然后再运行上面那个命令行就可以了,就简单总结这么多。

AFL(American Fuzzy Lop)是一款非常受欢迎的模糊测试工具,可以用于发现软件程序中的漏洞和错误。而QEMU是一款开源的虚拟机监控程序,可以模拟不同的系统架构,用于测试和调试。 在进行AFL QEMU测试进制之前,我们首先需要安装AFL和QEMU这两个工具。安装完成后,我们可以通过以下步骤进行测试: 1. 准备一个待测试进制文件,可以是目标软件程序的可执行文件; 2. 使用AFL进制文件进行处理,将其变成可模糊测试的目标; 3. 设置AFL和QEMU的参数,如模糊测试的目标文件、输入样本和输出文件等; 4. 运行AFL QEMU,开始进行模糊测试AFL会根据设置的参数,生成各种变异的输入样本,并将其输入到待测试进制文件中; 5. QEMU会模拟执行这些输入样本,并监控目标程序的执行过程。它会在发现异常情况时,如程序崩溃或产生错误输出,记录下这些情况; 6. 模糊测试结束后,AFL会生成一个测试报告,包含了发现的漏洞和错误。我们可以根据这些报告,进行漏洞修复或错误修正。 通过AFL QEMU测试进制,我们可以有效地发现软件程序中的潜在问题,提高程序的安全性和稳定性。同时,由于AFL和QEMU都是开源工具,可以根据需要进行自定义设置和扩展,以满足不同测试需求。总之,AFL QEMU测试进制是一种非常有效的方法,可以帮助开发人员提升软件质量和性能。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值