如何创建跳过特定种子的增强AFL模糊器?

2024-05-16 12:04:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我是一名硕士生,正在复制论文的结果:https://www.microsoft.com/en-us/research/publication/not-all-bytes-are-equal-neural-byte-sieve-for-fuzzing/

我想创建一个增强的fuzzer,它拒绝对种子的修改,因为它发现这些修改没有用。在实现这一点上的任何帮助都将非常有帮助。你知道吗

我已经为增强fuzzer创建了一个简单的python函数。为了测试实现,我使用了普通的“deadbeef”程序并编写了python函数,这样每当seed被修改为“deadbeef”时,该函数就会向AFL fuzz代码的“common\u fuzz\u stuff()”函数发送一个“无用”的返回。这应该意味着模糊程序不能找到崩溃。但它仍然能够找到坠机的地方,我也无法确定我哪里出了问题。你知道吗

下面是用于AFL的python函数:

 def check_useful(seed):

  my_string = str.encode('deadbeef')

  file = open(seed, 'rb')

  value = file.read()


  if (value == my_string):

    print('[*] Crash Found!')

    return True


 else:

   return False 

下面是afl fuzz.c代码片段:

/* Write a modified test case, run program, process results. Handle

error conditions, returning 1 if it's time to bail out. This is

a helper function for fuzz_one(). */


EXP_ST u8 common_fuzz_stuff(char** argv, u8* out_buf, u32 len) {


if (PyCallable_Check(pFuncCheckModel)){


pArgs = PyTuple_New(1);

PyTuple_SetItem(pArgs, 0, PyUnicode_FromString(queue_cur->fname));

pFuncReturn = PyObject_CallObject(pFuncCheckModel, pArgs);

if (PyObject_IsTrue(pFuncReturn)){

skip_requested = 1;

return 1;

}

} else

{

PyErr_Print();

}

即使seed“deadbeef”的common\u fuzz\u stuff()函数的返回值是1,我的程序怎么还能找到崩溃呢?你知道吗


Tags: 函数代码程序forreturnifmycommon
2条回答

回答我自己的问题: 我必须将out_file发送到Python函数,而不是queue_cur->fname。你知道吗

PyTuple_SetItem(pArgs, 0, PyUnicode_FromString(out_file));

此外,上述代码中的skip_requested = 1;也是多余的。你知道吗

现在模糊程序将运行,不会找到崩溃

如果你决定这个输入是否有用只取决于输入本身(而不是变异),据我所知,你可以使用experimental/post_library的东西。该文档包含在示例post\u库中,并包含一个注释,即这可能不是您想要的不是您的特定需要,这是该文档的近似引用。:)

另一方面,此单函数API说明包含以下内容:

2) If you want to skip this test case altogether and have AFL generate a
   new one, return NULL. Use this sparingly - it's faster than running
   the target program with patently useless inputs, but still wastes CPU
   time.

相关问题 更多 >