It is the porn_master on BoB9 CTF. let’s check protection. It is full protection. then we should know pie-base and libc-base when we exploit it. let’s see the binary on IDA!
we can find format string bug on line 28. but we can only write 0x18 at once to buf. and also we can write two times because of the for loop on line 24. so first time we need to leak pie_addr and libc_addr on stack. then we can get its base_addr. and second time we overwrite printf_ret_addr to printf_addr on line 21(It is pie_addr). then we jump to line21. we have two opportunities to use format string bug again. according to this, we can make many opportunities, if we overwrite print_ret_addr. we can’t overwrite got because of full relro. so we should overwrite __malloc_hook. let’s overwrite __malloc_hook to oneshot gadget and get flag!