如何创建跳过某些种子的增强型AFL模糊器?

时间:2019-01-20 15:27:03

标签: python c fuzzing fuzzer american-fuzzy-lop

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

我想创建一个增强的模糊测试器,该测试器拒绝对种子的修改,但认为这没有用。实现这一目标的任何帮助都将非常有帮助。

我为增强型模糊器创建了一个简单的python函数。为了测试实现,我使用了一个简单的“ deadbeef”程序并编写了python函数,以便每当将种子修改为“ deadbeef”时,该函数都会向AFL的“ common_fuzz_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();

}

即使种子“ deadbeef”的common_fuzz_stuff()函数的返回值为1,我的程序仍如何找到崩溃?

2 个答案:

答案 0 :(得分:0)

根据我的理解,如果您决定此输入是否有用取决于仅取决于输入本身(而不取决于突变),则可以使用experimental/post_library东西。该文档包含在示例post_library中,并包含一条说明,即这可能不是您想要的-不是您的特定需要,这是该文档的大概引用。 :)

另一方面,此单一功能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.

答案 1 :(得分:0)

要回答我自己的问题: 我必须将out_file发送给Python函数,而不是queue_cur->fname

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

以上代码中的skip_requested = 1;也是多余的。

现在,模糊器将运行,并且不会找到崩溃