Nautilus:一款基于语法的反馈式模糊测试工具

admin 2020年10月11日18:00:50评论185 views字数 3329阅读11分5秒阅读模式

Nautilus:一款基于语法的反馈式模糊测试工具

Nautilus介绍

Nautilus是一款基于覆盖指引和语法的反馈式模糊测试工具,广大研究人员可以使用Nautilus来提升模糊测试过程中的测试覆盖率,以寻找到更多的安全漏洞。在Nautilus的帮助下,研究人员可以通过指定半有效的输入语法,来执行更加复杂的变异操作,并生成更多有效的测试用例。

目前,Nautilus已发布了2.0版本,该版本相较于Nautilus原型,引入了很多功能性提升,目前该工具已经100%支持AFL++了。除了稳定性和可用性提升之外,还包括下列功能提升:

  • 支持AFL-Qemu模式

  • 支持Python格式语法

  • 支持使用Python脚本生成结构化输入

  • 支持指定源码协议/格式

  • 支持指定正则表达式

  • 避免生成相似的短输入

  • 提供了更好的错误输出

  • 修复大量Bug

Nautilus工作机制

我们可以使用类似EXPR -> EXPR + EXPR、EXPR -> NUM和NUM -> 1这样的规则来指定一个语法。针对这些规则,模糊测试器将构建一个树状结构,这种内部语法表达允许支持更加复杂的变异操作。接下来,这个树状结构将会转变为针对目标应用程序的真实输入,即拼接所有的叶子节点。在下方给出的示例中,左子树将会被解析为“a=1+2”,右子树则为“a=1+1+1+2”。为了提高语法的表达能力,Nautilus还可以允许广大研究人员使用Python脚本来实现对树状结构的解析,以支持更加复杂的操作。

Nautilus:一款基于语法的反馈式模糊测试工具

工具安装&配置

首先,广大用户需要使用下列命令将该项目源码克隆至本地,并进行基础配置:

git clone '[email protected]:nautilus-fuzz/nautilus.git'

cd nautilus

/path/to/AFLplusplus/afl-clang-fast test.c -o test #afl-clang-fast as provided by AFL

接下来,我们需要在config.ron文件中设置好所有需要使用的参数:

cargo run --release -- -g grammars/grammar_py_example.py -o /tmp/workdir -- ./test @@

如果想要使用QEMU模式的话,可以运行下列命令:

cargo run /path/to/AFLplusplus/afl-qemu-trace -- ./test_bin @@

工具使用样例

在这里,我们可以使用Python来生成一个语法,并生成一个有效的类XML输入。需要注意的是,Python脚本的语法规则,这里必须确保匹配起始标签:

#ctx.rule(NONTERM: string, RHS: string|bytes) adds a rule NONTERM->RHS. We can use {NONTERM} in the RHS to request a recursion.

ctx.rule("START","<document>{XML_CONTENT}</document>")

ctx.rule("XML_CONTENT","{XML}{XML_CONTENT}")

ctx.rule("XML_CONTENT","")

#ctx.script(NONTERM:string, RHS: [string]], func) adds a rule NONTERM->func(*RHS).

# In contrast to normal `rule`, RHS is an array of nonterminals.

# It's up to the function to combine the values returned for the NONTERMINALS with any fixed content used.

ctx.script("XML",["TAG","ATTR","XML_CONTENT"], lambda tag,attr,body: b"<%s %s>%s</%s>"%(tag,attr,body,tag) )

ctx.rule("ATTR","foo=bar")

ctx.rule("TAG","some_tag")

ctx.rule("TAG","other_tag")

#sometimes we don't want to explore the set of possible inputs in more detail. For example, if we fuzz a script

#interpreter, we don't want to spend time on fuzzing all different variable names. In such cases we can use Regex

#terminals. Regex terminals are only mutated during generation, but not during normal mutation stages, saving a lot of time.

#The fuzzer still explores different values for the regex, but it won't be able to learn interesting values incrementally.

#Use this when incremantal exploration would most likely waste time.

ctx.regex("TAG","[a-z]+")

接下来,我们可以使用模糊测试用例生成器来测试我们刚才生成的语法:

$ cargo run --bin generator -- -g grammars/grammar_py_exmaple.py -t 100

<document><some_tag foo=bar><other_tag foo=bar><other_tag foo=bar><some_tag foo=bar></some_tag></other_tag><some_tag foo=bar><other_tag foo=bar></other_tag></some_tag><other_tag foo=bar></other_tag><some_tag foo=bar></some_tag></other_tag><other_tag foo=bar></other_tag><some_tag foo=bar></some_tag></some_tag></document>

除此之外,我们还可以结合AFL来使用Nautilus。使用“-o”参数来指向AFL到同一工作目录,而AFL则会将数据跟Nautilus同步。在这里,AFL将导入Nautilus的输入:

#Terminal/Screen 1

./afl-fuzz -Safl -i /tmp/seeds -o /tmp/workdir/ ./test @@

#Terminal/Screen 2

cargo run --release -- -o /tmp/workdir -- ./test @@

项目地址

Nautilus:【GitHub传送门(阅读原文查看)

参考资料

https://github.com/Microsoft/ChakraCore/issues/5503

https://github.com/mruby/mruby/issues/3995(CVE-2018-10191)

https://github.com/mruby/mruby/issues/4001(CVE-2018-10199)

https://github.com/mruby/mruby/issues/4038(CVE-2018-12248)

https://github.com/mruby/mruby/issues/4027(CVE-2018-11743)

https://github.com/mruby/mruby/issues/4036(CVE-2018-12247)

https://github.com/mruby/mruby/issues/4037(CVE-2018-12249)

https://bugs.php.net/bug.php?id=76410

https://bugs.php.net/bug.php?id=76244

Nautilus:一款基于语法的反馈式模糊测试工具

精彩推荐





Nautilus:一款基于语法的反馈式模糊测试工具
Nautilus:一款基于语法的反馈式模糊测试工具Nautilus:一款基于语法的反馈式模糊测试工具

Nautilus:一款基于语法的反馈式模糊测试工具Nautilus:一款基于语法的反馈式模糊测试工具Nautilus:一款基于语法的反馈式模糊测试工具

Nautilus:一款基于语法的反馈式模糊测试工具

本文始发于微信公众号(FreeBuf):Nautilus:一款基于语法的反馈式模糊测试工具

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2020年10月11日18:00:50
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Nautilus:一款基于语法的反馈式模糊测试工具https://cn-sec.com/archives/154849.html

发表评论

匿名网友 填写信息