ctf2
=== Originality === Very original
=== Difficulty === Quite difficult. Noticed that variable r was the key to solving this ctf. Initially, I tried to force the program to skip the assignment of r. Afterwards, i tried to carefully chose my argument, as r to be assigned a specific value.
Added printf to better view how pointers change
akan@ubuntu:~/resolved_oss_1/alex$ ./ctf2 0 p = 0x8048372 q = 0x8048374 r = 0x10680804 Segmentation fault (core dumped) //missing print r =
By brute-forcing it (and with luck) i found out that lucky number 7 grants me shell access:
akan@ubuntu:/resolved_oss_1/alex$ gcc ctf2.c -o ctf2
akan@ubuntu:/resolved_oss_1/alex$ sudo ./ctf2 7
root@ubuntu:~/resolved_oss_1/alex# exit
With printf:
akan@ubuntu:/resolved_oss_1/alex$ gcc ctf2.c -o ctf2
akan@ubuntu:/resolved_oss_1/alex$ sudo ./ctf2 7
p = 0x8048372
q = 0x8048382
r = 0x804a018
after assigning pass
r = 0x804a018
=== Relevance === Objdump, linking, loading