首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AFL hello world示例

AFL hello world示例
EN

Stack Overflow用户
提问于 2019-11-14 02:16:37
回答 2查看 1.1K关注 0票数 0

我正在试图弄清楚如何使用AFL,但我似乎不能运行一个简单的示例。下面是我的C程序:

代码语言:javascript
复制
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

char *remove_white_space(char *s)
{
    while (s && *s++)
        if (*s == ' ')
            return "moish";
    return s;
}

int main(int argc, char **argv)
{
    char buffer[256]={0};
    FILE *fl = fopen(argv[1],"rt");
    if (fl == NULL) return 0;

    assert(fscanf(fl,"%s",buffer) > 0);
    char *res = remove_white_space(buffer);
    if (strcmp(res,"a b c d") == 0)
    {
        assert(0);
    }

    fclose(fl);
    return 0;
}

我的输入种子是一个只有一行abhgsd的文本文件。下面是我所做的:

代码语言:javascript
复制
$ afl-gcc main.c -o main
afl-cc 2.56b by <lcamtuf@google.com>
afl-as 2.56b by <lcamtuf@google.com>
[+] Instrumented 62 locations (64-bit, non-hardened mode, ratio 100%).
$ afl-fuzz -i INPUTS/ -o OUTPUTS ./main @@

我收到了这条红色的资本崩溃消息:

代码语言:javascript
复制
afl-fuzz 2.56b by <lcamtuf@google.com>
[+] You have 8 CPU cores and 1 runnable tasks (utilization: 12%).
[+] Try parallel jobs - see /usr/local/share/doc/afl/parallel_fuzzing.txt.
[*] Checking CPU core loadout...
[+] Found a free CPU core, binding to #0.
[*] Checking core_pattern...

[-] 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:7316

我有点不愿意改变一些东西,除非我确定我在做什么。这里发生了什么事?我应该听听AFL在说什么吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-11-15 01:59:29

您可能应该更改您的核心模式,但您可以稍后将其更改回来。许多linux发行版都有像apport这样的崩溃报告服务,它依赖于通过像|/usr/share/apport/apport %p %s %c %d %P (参见man 5 core)这样的核心模式将崩溃进程的核心转储通过管道传输到它。当核心模式以这种方式设置时,每次程序崩溃时,apport都会运行,核心作为标准输入提供给它。因此,如果您将核心模式更改为仅core,进行模糊处理,然后将核心模式更改回当前的模式,则发行版的崩溃报告器应该恢复其正常操作。

AFL可能有一个环境变量来禁用这个检查,因为我知道有一些环境变量可以禁用其他的预模糊检查(比如AFL_SKIP_CRASHES允许在初始种子中崩溃输入),但是这个切换成本非常低。

票数 1
EN

Stack Overflow用户

发布于 2019-11-14 14:27:49

答案就在你面前。

代码语言:javascript
复制
log in as root and echo core >/proc/sys/kernel/core_pattern
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58843233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档