一个浏览器Fuzzing框架的学习

发布者:Ox9A82
发布于:2017-03-13 17:28

一个浏览器Fuzzing框架的学习

关于框架

之前是LCatro师傅在小密圈分享的他写的这个Fuzzing框架(不过我以前翻github时好像就看到过),但是之前一直没啥时间搞这方面,这两天研究学习了一下。

背景资料

其实浏览器Fuzzing框架的资料还是比较多的,之前walkerfuz在Freebuf发过一篇介绍已有开源框架的文章
http://www.freebuf.com/sectool/93130.html
况且研究过浏览器的童鞋们都应该用过或是听过grinder、cross_fuzz这些大名鼎鼎的工具了。
此外对于框架开发来说有一篇有点老但比较有启发性的文章,http://bobao.360.cn/learning/detail/160.html
walkerfuz也开源了一个框架出来,链接在这里:https://github.com/walkerfuz/morph

其实对于浏览器fuzzer来说,我个人认为分为两个部分:fuzzer框架和模版。框架主要解决的是fuzz的速度、效率、稳定性的问题,而模版负责生成样本决定了到底能不能挖到漏洞和挖到什么漏洞。所以真正有价值的其实还是模版怎么设计,在网上放出的fuzz框架相当多,模版却没有多少。我这里分享几个我自己搜集的资料

1.烧博士在blackhat14上讲的,但是这个思路应该已经被搞过不知道多少次了。
https://www.blackhat.com/docs/eu-14/materials/eu-14-Lu-The-Power-Of-Pair-One-Template-That-Reveals-100-plus-UAF-IE-Vulnerabilities.pdf

2.这个其实就是作者的nduja说明文档,nduja就不用过多介绍了吧
https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnx0ZW50YWNvbG92aW9sYXxneDo1MTgyOTgyYmUyYWY3MWQy

3.同样是Rosario valotta的议题,但是我觉得这个提出的一些思路比较有意思
https://www.syscan360.org/slides/2014_ZH_BrowserFuzzing_RosarioValotta.pdf

4.绿盟大牛的一次演讲ppt,篇幅相当足
https://hitcon.org/2014/downloads/P1_06_Chen%20Zhang%20-%20Smashing%20The%20Browser%20-%20From%20Vulnerability%20Discovery%20To%20Exploit.pdf

5.说的比较基础,我怀疑ppt不全??
http://www.leiphone.com/news/201612/YlysgkvgBbeBIkL9.html

Kite框架

好了我们来回归正题,我用过一些框架但是自己写还没有试过,所以这次来学习一下也是为自己动工做铺垫。
首先看一下作者的使用说明

1.run web_server.py in this new console window
2.using your browser which you want to fuzzing to open http://127.0.0.1/vector
3.using get_poc.py dump crash poc when browser has been crash

这说明框架是从web_server.py开始执行的
我们查看这个模块发现导入了tornado,这是比较有名的web server模块,框架使用它来搭建本地服务器。

import tornado.web
import tornado.ioloop

模块首先创建监视线程,使用的是threading模块

restart_thread=threading.Thread(target=time_wait_restart_process_monitor_thread)
restart_thread.start()

threading是一个比thread更高层的API,基本用法如下

t=threading.Thread(target=thread_func)
t.start()

线程的执行函数time_wait_restart_process_monitor_thread负责重启进程,并重复这个过程

def time_wait_restart_process_monitor_thread() :
    global BLOCK_TIME,globle_tick
    static_tick=globle_tick
    while True :
        is_restart=True
        for time_tick in range(BLOCK_TIME) :#重启线程
            if static_tick!=globle_tick :
                static_tick=globle_tick
                is_restart=False
                break
            time.sleep(1)
        if is_restart :
            restart_process_monitor()
            
def restart_process_monitor() :
    pid=get_process_id()
    if pid is not -1 :
        kill_process(get_process_id())
        
os.system('start process_monitor.py')

读取文件内容之后,使用tornado设置本地服务器

 handler = [
       (r"/vector", MainHandler, dict(copy_data=copy_data)),
       (r"/poc", PocHandler),
       (r"/(.*)", OtherHandler),
    ]
 http_Server = tornado.web.Application(handlers=handler)

调用tornado的Application类需要提供Handler列表,这些Handler组成了一个web应用程序。Handler定义了网页路径与函数之间的映射关系。

MainHandler —— /vector
PocHandler  —— /poc
OtherHandler—— /(.*)

tornado官方给出了栗子


声明:该文观点仅代表作者本人,转载请注明来自看雪