Exploiting FSOP with _wide_data

前言 眾所周知,glibc在2.24引入vtable檢查,使針對vtable的攻擊手段如FSOP, House of Orange等攻擊手法失效,不過很快有一條新的利用鏈被發現,就是FILE成員中的 _wide_data段,在glibc執行_wide_data上vtable的函式時,並不會進行vtable進行檢查,因此衍生出如House of Apple等可以在高版本(>=2.35)通殺的利用手段. 本文主要探討在glibc 2.31環境下利用_wide_data進行vtable劫持,以達成control flow FILE結構分析 所有的原始碼皆取自 glibc source browser : Glibc 2.31 Source code 當在C語言進行如 FILE *fp=fopen(...) 或是使用stdin/stdout/stderr時,glibc都是使用以下結構: struct _IO_FILE_plus { FILE file; const struct _IO_jump_t *vtable; }; 其中FILE在內部的實作如下: struct _IO_FILE_complete { struct _IO_FILE _file; #endif __off64_t _offset; /* Wide character stream stuff. */ struct _IO_codecvt *_codecvt; struct _IO_wide_data *_wide_data; struct _IO_FILE *_freeres_list; void *_freeres_buf; size_t __pad5; int _mode; /* Make sure we don't get into trouble again. */ char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; // 你可以把它當作padding }; 其中可以看到除了描述FILE結構相關的_file之外,還有許多用來描述Wide character的相關member, 其中可以看到*_wide_data,追進去看一下相關定義: ...

March 29, 2025 · 9 min

Windows Binary Exploitation筆記

使用工具 VM 分析工具 : PEBear, DLL Export Viewer 組語除錯工具 : WinREPL C++ ROP Gadget : rp++ Debugger : x64dbg, Windbg Preview Windbg操作 | : Process Status ~ : Thread Status 顯示記憶體內容 : d{b|d|q|u} + Ln (顯示N個) 以某種資料結構解讀 : dt (module)!_name + rn (recursive) 對記憶體寫入 : 數值e{b|d|q}, 字串e{a|u|za|zu} (z : 指以NULL做結尾) 暫存器 : r, r [reg] = [val] 取值 : poi 反組譯 : u, uf 斷點 : bp [addr] .if [cond]{} .else{gc} 列出載入的模組 : lm 執行 : go, Step in : t, Step over : p Mapping : !address 查看權限 : !vprot 查看Error Code : !error Value [Flags], Flags=Win32, NTSTATUS… 查看Symbol : x module!symbol 呼叫慣例 流程控制 : call / ret 參數 : 使用 CX, DX, R8, R9, stack Prologue, Epilogue : 保存/恢復上一個frame的RBP Buffer Overflow 列舉一些危險的函數 ...

November 22, 2024 · 2 min