ret2win
32 bit
All the functions available to us.

Interesting ones that pop out are main, pwnme, and ret2win. Lets go ahead and disassemble these and see what are we working with.
So we have a fgets which takes 50 bytes of input and tries to store the string into a 32 bytes buffer as described by the challenge text.
So now our task is to use the overflowed buffer to call the ret2win function and get the flag.
Now we'll try and find the offset which will give us the precise control of the EIP register.
So now we have a segmentation fault, and we can check the failed EIP using dmesg logs and find the offset value.
Now we have the desired control of EIP. Now we'll check the address of the function to jump to, to get our precious flag.
Now we can construct our exploit and point our EIP to this address to get the flag.
64 bit
The functions and their functionality remains the same throughout the binaries so we'll jump right to finding the offset to control our RIP.
We can not use the same trick of checking the dmesg for messed up EIP as in case of 64 binaries the result is at RSP and its value is not visible in dmesg.

So value of our RSP is 0x3562413462413362 and the offset value is
So let's confirm our RIP control.

So now we have our control and we can now find the address of the desired function and point the RIP to that address and get our flag.
As you can see, there are plenty of NULL bytes which should break our exploit, but they won't as we are using fgets, which only terminates input when it gets a newline or an EOF. So NULL bytes are no problems in this case. Lets construct our final payload and get the flag.
Last updated
Was this helpful?