Pwn - whatsmyname
50 points | 304 solves
Last updated
50 points | 304 solves
Last updated
Can you guess my name?
nc challs.actf.co 31223
We are given 2 files, the binary and the source code itself.
The C source code:
Initially I thought that the vulnerability was in line 25 where the yourName
string buffer was not correctly null-terminated and since myName
happens to be initialised right after yourName
, if we send any string that is 48 characters long, the printf
in line 27 should print our yourName
string together with the randomly generated myName
. I confirmed my theory by using gdb
to dump out the randomly generated bytes and it works locally. However, when I tried it on the server it failed.
I knew there was another vulnerability which is in line 33, inside the strncmp
function. The thing about strncmp
was that it only compare strings up to their null terminator regardless of the length argument passed to the function (unless the max length is reached before the null terminator). Therefore, if the first byte of the randomly generated myName
is null and if we pass in guess
as null, the flag will be printed. The chance of this happening is 1/256 which is reasonably brute-force-able.
Hence, the final solve script:
After a while,
Flag: actf{i_c0uld_be_l0nely_with_y0u_a21f8611c74b}