# PWN 0b01 --- ## WHOAMI * 彭建霖 (YingMuo) * 大四老人 * HITCON 講者 * Balsn 戰隊成員 --- ## What's pwn? ---- #### 惡意的輸入導致程式在 Binary 層不正常執行 ---- #### 惡意的輸入導致程式在 Binary 層執行任意程式 --- ## Need what capabilities? ---- * 電腦自動穩定的輸入 * debug 組語層的狀態 --- ## pwntools * 讓程式幫你管理 IO * 按下暫停去裝吧 * https://github.com/Gallopsled/pwntools ---- ```python # Sample from pwn import * # import pwntools p = process( './a.out' ) # 執行 a.out 並讓 pwntools 控制 IO p.recvuntil( 'input: ' ) # 讀 output 直到 "input: " p.sendline( str( 123 ) ) # 輸入 "123\n" 到 input p.interactive() # 換成我們操作 IO ``` ---- ```python # Sample 2 from pwn import * addr = 0x401234 print(p64(addr)) print(u64(p64(addr))) ``` ---- ### Pwntools Cheatsheet * https://gist.github.com/anvbis/64907e4f90974c4bdd930baeb705dedf ---- ### Lab 0x1 * https://github.com/YingMuo/w33d_lecture * 2021_fall 的 lab01 --- ## GDB * debug 組語層的工具 * install ``` sudo apt install gdb ``` * plugin * https://github.com/hugsy/gef * 按下暫停去裝ㄅ ---- ### 執行 ``` gdb a.out ``` ---- * 常用指令 * r * 開始執行 * c * 繼續執行 * disas \<func\> * 查看 function 組語 * b \<addr\> * 下斷點 * i b * 查看斷點 ---- * 常用指令 * ni * 下行指令 * si * 進入指令 * fin * 會到 caller function * x/gx \<addr\> * 查看特定位置 8 bytes 值 * x/s \<addr\> * 查看特定位置 string ---- ### GDB cheat sheet * https://darkdust.net/files/GDB%20Cheat%20Sheet.pdf --- ## Stack Buffer Overflow ---- * 直接實作 Lab 0x2 * https://github.com/YingMuo/w33d_lecture * 2021_fall 的 lab02 --- # GG
{"metaMigratedAt":"2023-06-17T10:18:04.605Z","metaMigratedFrom":"Content","title":"PWN 0b01","breaks":true,"contributors":"[{\"id\":\"3e7054e0-80a6-4ce4-96a9-aee17f1726a2\",\"add\":1619,\"del\":38}]"}
    485 views