不久前@三勤學(xué)生師傅買了一個(gè)wooyun wifi,然后聊到了緩存投毒:
然后看到wooyun wifi的這個(gè)說明:
默認(rèn)環(huán)境下該成果附帶緩存投毒成果,將視圖緩存所有的頁面至2099年,您可以通過排除所有緩存以及欣賞器數(shù)據(jù)來排除緩存投毒的影響。
以為這是個(gè)很不錯(cuò)的技能,所以查詢谷爺,度娘,拜讀了@EtherDream 大牛寫的文章今后,就有了這篇文章,也算是一個(gè)總結(jié)。
js緩存投毒說白了就是受害者的欣賞器緩存了一個(gè)被我們改動(dòng)的js劇本,假如緩存沒有被排除,每次這個(gè)受害者會(huì)見網(wǎng)頁的時(shí)候城市加載我們的js劇本。
那他是什么道理呢,很簡樸,其實(shí)就是欣賞器的緩存機(jī)制,凡是,為了加快各類靜態(tài)資源的會(huì)見,各大網(wǎng)站會(huì)把一些靜態(tài)資源緩存到客戶端,這樣一方面能提高客戶體驗(yàn),一方面也能減輕web處事器的壓力。
欣賞器緩存節(jié)制機(jī)制有兩種:HTML Meta標(biāo)簽 以及 HTTP頭信息,凡是,web開拓者可以在HTML頁面的<head>節(jié)點(diǎn)中插手<meta>標(biāo)簽,好比:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> |
代碼的浸染是匯報(bào)欣賞器當(dāng)前頁面不被緩存,每次會(huì)見都需要去處事器拉取。 更多欣賞器緩存機(jī)制我就不多說了,詳情請戳我。
要想預(yù)加載并緩存一個(gè)劇本很容易,只需new Image().src=''。雖然有少數(shù)欣賞器不支持,不外ie和chrome都是支持的。盡量js文件并不是一個(gè)圖片,但仍然會(huì)緩存。
安裝node
wget https://codeload.github.com/nodejs/node/zip/master -O node-master.zip //下載
tar zxvf node-master.zip //解壓
cd node-master
./configure
make //編譯
make install //安裝
wget https://codeload.github.com/nodejs/node/zip/master -O node-master.zip //下載 tar zxvf node-master.zip //解壓 cd node-master ./configure make //編譯 make install //安裝 |
安裝closurether
npm install -g closurether
npm install -g closurether |
安裝phantomjs
下載安裝,詳細(xì)詳見 phantomjs,按照本身的系統(tǒng)舉辦選擇。
測試進(jìn)程中,利用了EtherDream大牛的demo。詳細(xì)進(jìn)程如下。
下載安裝:
[email protected]:~/Desktop/# git clone https://github.com/EtherDream/mitm-http-cache-poisoning.git js
[email protected]:~/Desktop/# cd js
[email protected]:~/Desktop/js/# npm install
[email protected]:~/Desktop/# git clone https://github.com/EtherDream/mitm-http-cache-poisoning.git js [email protected]:~/Desktop/# cd js [email protected]:~/Desktop/js/# npm install |
更新緩存列表
[email protected]:~/Desktop/js# cd tool/
[email protected]:~/Desktop/js/tool# phantomjs sniffer.js -i url.txt -o target.json
[email protected]:~/Desktop/js# cd tool/ [email protected]:~/Desktop/js/tool# phantomjs sniffer.js -i url.txt -o target.json |
這個(gè)劇本的浸染主要是為了找出各大網(wǎng)站中緩存最久的劇本資源,也就是我們要舉辦投毒的劇本鏈接。網(wǎng)站可以再url.txt內(nèi)里添加,之后將生成的json復(fù)制到 asset 目次。
[email protected]:~/Desktop/js/tool# cp -fr target.json ../asset/
[email protected]:~/Desktop/js/tool# cp -fr target.json ../asset/ |
運(yùn)行