Sometimes computer numbers can be so harddd
nc numbersss.chal.cyberjousting.com 1351
Challenge
1 | └─$ ./numbersss |
Running the program spit this out. Looks like we are given some address here, lets run our checks and open her up.
1 | Arch: amd64-64-little |
1 | void vuln(void) |
Looking at this vuln function we see that the address that was being given to us is the address of printf. This will be important as we will be able to calculate libc base from it. Moving forward we see that the scanf is reading in a %hhd
to length. We can manipulate this to allow us to write more than \x10
bytes. For example, if we input -1 it will actually register as 256-1 when being compared to counter because of byte comparison.
So our objectives here will be to calculate the libc address with the given printf address, then we will want to overflow into the return address and place a rop chain that calls the shell.
Playing around with the number that I wanted to input to bypass the "Too many bytes!"
counter made me land on -129
. This gave me more than enough space to write my chain and was bypassing the check. It left me with 256-127 bytes (129).
One last thing I needed to iron out before exploiting was the libc file. I wasn’t given a libc file with the challenge and actually thought I was supposed to leak more libc addresses in the program and ended up wasting a bunch of time. A teammate pointed me in the right direction and helped me realize it was the libc that was on the docker image given to us. I exfilled both the libc and the linker and used it for my exploit.
1 | from pwn import * |
After all is done it really is just a standard ret2libc attack with a tricky little number manipulation in the middle.
Flag
byuctf{gotta_pay_attention_to_the_details!}