一個瀏覽器Fuzzing框架的學習

Ox9A82發表於2017-03-13

一個瀏覽器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官方給出了栗子

相關文章