> Write-up for non-fflush version
This binary has normal BOF and FSB, but without `fflush()` we can't get stack cookie before program exit.
So, we have to get server's `key.aes` and `iv.aes` in other way. (If you want to get shell with fflush version binary, just get stack cookie and stack address with FSB and then make .fini_array with main's address)
As you can see, in `encrypt()` function's stack frame, there's key and iv on memory. I want to get it.But how..?
In this function, there's `printf(ciphertext_msg);` and ciphertext_msg is on `.data` (it means ciphertext_msg is on fixed address). So, we can change this string with main function's FSB like `%17$8x`(get first 4 bytes of key) or `%12$8x`(get first 4 bytes of iv). With this, we can get 32 bytes of key and 16 bytes of iv, then we can decrypt message.
Flag is pctf{th4t_m0m3n1-wh3n~f0rm41`SpiLls_0v3r}