本文主要分享一款靜态的ie浏覽器模糊測試工具,該工具被稱為iefuzz。我們知道,像其他大部分軟體一樣,浏覽器也往往通過兩種方式進行模糊測試,一種為靜态,另外一種則為動态。
在此前,我們在其他文章中也了解過其他的fuzzer,如x-fuzzer,pkav http fuzzer,也了解過相關的fuzzing方法,如從零開始學fuzzing系列:浏覽器挖掘架構morph誕生記等。本文主要講述靜态浏覽器fuzzer的情況。
在當下,動态浏覽器fuzzer占據着主流,因為它們的運作效率高(純粹是用javascript寫的)。然而,當我們在進行動态fuzzing 的時候,往往面臨着一個共同的問題,就是“異常事件重制”。是以一般我們在建構js 浏覽器 fuzzer時都需要非常仔細,否則在運作過程中可能會由于浏覽器fuzzer是動态的,将導緻異常事件不可重制。
是以,在fuzzing之前,我們往往需要考慮以下幾個方面的問題:
對于上述使用動态 fuzzer面臨的問題,另外一種解決思路是,采用靜态fuzzer進行檢測。雖然靜态fuzzer效率較低,但是一般都可以重制異常事件的。
iefuzz簡介
該靜态ie fuzzer 是用python編寫的,包括使用到以下子產品:
pywin32com ——用于加載或者重載*.html測試執行個體;
pydbg——用于監控ie浏覽器的異常事件;
paimei——用于生成異常事件的dump檔案,下載下傳連結為:paimei。
iefuzz使用配置
為了能夠順利進行fuzzing,我們需要在ie設定中做如下更改。
1、首先,因為fuzzer 需要在本地加載測試執行個體(如加載路徑為file://c:/fuzzer/testcases/temp.html)是以應該先将ie的activex告警提示關閉,通過如下步驟:
(1)工具->internet 選項->安全->自定義級别;
(2)随後将activex告警提示關閉。
2、接着,為了能夠使用 python win32com來監控ie,我們還需要關閉ie的保護子產品。但是請注意其中的風險。
(1)工具->internet 選項->安全->受信任的站點:自定義級别為低;
(2)工具->internet 選項->安全->internet:自定義級别為中,同時關閉保護模式;
(3)工具->internet 選項->安全->受限站點:關閉保護模式。
編寫測試執行個體
首先我們可以基于該fuzzer編寫自己的靜态測試用例生成器。之後可以将其放在/testcases檔案夾中。在github源碼中, 也提供了一個樣本以供參考:’testcases/sampletestcase.py。因源碼篇幅較長,連結如下,
<a href="http://netsecurity.51cto.com/art/201512/testcases/sampletestcase.py">testcases/sampletestcase.py</a>
在編寫測試執行個體時也請注意,執行個體中需要包含一個testcase類以及getfinaltestcase()方法。 getfinaltestcase()方法需要能夠傳回完整的 html頁面。
在動态fuzzer的應用過程中,需要從對象中提取不同的html元素屬性,然後在運作狀态下進行模糊檢測。而對于一個靜态fuzzer,我們能夠在我們的python測試執行個體中預定義html元素以及屬性,并将之作為字典dict。
dict舉例如下:
attr = {'canvas':['height','width','getcontext', ... , ... , ... ]}
對于這種屬性生成清單,也提供了一個javascript 應用供參考。
<html>
<head>
<script>
/*
----------------------------------------------------------------------------
"the beer-ware license" (revision 42):
<debasishm89_at_gmail.com> wrote this file. as long as you retain this notice you
can do whatever you want with this stuff. if we meet some day, and you think
this stuff is worth it, you can buy me a beer in return. debasish mandal
this js code should be used for generating a python dict. of element attributes of different html elements.
in case of dynamic fuzzer, its usually generated on the fly, since its a static fuzzer you need to pre define html elements and their attributes to your test case.
other wise you can use a list of well known attributes. it's completely your choice, how you write your test case.
*/
function geteleattributes(ele){
buff = "['"
for( var p in ele ){
buff += p + "','";
}
buff = buff.slice(0, -2) + "]";
return buff
function generate() {
add your element list in this here and open this html in ie.
var elements = ["article","asise","b","bdi","bdo", "blockquote","br","button","canvas","caption","cite","col","code","command","datalist","dd","del","details","dfn","dl","dt", "em","style","fieldset","figcaption","script", "embed","figure","footer","header","hgroup","hr","i","input","ins","keygen","kbd","legend","mark","menu","meter","nav","noscript","optgroup","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","source","span","sup","th","thead","time","object","iframe","textarea","track","u","var","wbr","form","a","body","html","div","table","area","td","tr","link","base","font","head","img","map","meta","ol","li","tbody","title","h1","blink","area","col","span","frameset","frame","ul","option","noframes","tfoot","xmp","isindex","center","hr","label","optgroup","audio","video","template","svg"]
main_buff = "ele_dict = {"
for (ele in elements){
var id_0 = document.createelement( elements[ele] );
all_props = geteleattributes(id_0)
main_buff += "'"+elements[ele]
main_buff += "':"
main_buff += all_props
main_buff += ","
main_buff = main_buff.slice(0,-1)
main_buff += "}"
document.getelementbyid('result').innerhtml = main_buff;
</script>
</head>
<body onload='generate();'>
<b>output : (copy paste following python dictionary to your testcase generator script and fuzz using them )</b></br><textarea id="result" rows="100" cols="200"></textarea>
</body>
</html>
作者:何妍
來源:51cto