# 10004-cyberpsychosis ## intro 三個功能 1. 看 implants 2. 寫 implants 3. ??? ## Exploit edit_info 的輸入: ![](https://i.imgur.com/osdXogP.png) 可以發現 - implant id 不會檢查到負數 - implants 是個 array,implants[id] 的位置是 &implants + 0x50 * id + 0x20 - &implants 是 0x4050e0 (這題沒有 ASLR) - 可以輸 16 bytes 進去 - &implants + 0x50 * id + 0x40 = int(輸入) - &implants + 0x50 * id + 0x48 = 1 因此我們可以利用竄改在前面的 GOT 表來做壞事。 ### implants[id] 對應位置 | [id] | StartAddress | 可寫 (`0x20~0x3f`) | 會轉 int (`0x40~0x47`) | |:----:|:------------:|:-------------------:|:----------------------:| | -3 | `0x404ff0` | `0x405010 ~ 0x40502f` | `0x405030 ~ 0x405037` | | -2 | `0x405040` | `0x405060 ~ 0x40507f` | `0x405080 ~ 0x405087` | | -1 | `0x405090` | `0x4050b0 ~ 0x4050cf` | `0x4050d0 ~ 0x4050d7` | | 0 | `0x4050e0` | `0x405100 ~ 0x40511f` | `0x405120 ~ 0x405127` | ### libc 相關 GOT 位置 - `puts` 0x405018 - `write` 0x405020 - `printf` 0x405030 - `atol` 0x405068 哇!`printf` 剛好在 implants[-3] 的 value 上耶! ![](https://i.imgur.com/PCXVyTh.png) ### Prove my thoughts: `printf`是否真的在 implants[-3] 的 value 上 ![](https://i.imgur.com/YdD0oc6.png) ![](https://i.imgur.com/hw3McBW.png) ![](https://i.imgur.com/wQrLLwa.png) YES! 可以藉此算出 libc 的 base address (`leak_printf_address - printf_offset`) ### Libc Gadget using one_gadget ![](https://i.imgur.com/RZONczw.png) ### Inject Gadget ==TODO== 沒半個能用的wtf