Writeup - Odd Shell (UIUCTF 2022)
UIUCTF 2022 - Odd Shell Writeup
- Type - pwn
- Name - Odd Shell
- Points - 107
Description
1 | O ho! You found me! I have a display of oddities available to you! |
Writeup
I decided to spawn a shell using the syscall
approach (see the entry for execve
in the Linux System Call Table to see how I had to set registers). I used an online x86/x64 assembler to test my assembly commands and ensure they were all odd. Since some important instructions were only even, I took a dynamic approach, where I had the instructions change future instructions.
For example, if I wanted the instruction xor rsi,rsi
to zero out the rsi
register, the assembly would be 48 31 f6
. Since both 48
and f6
were even, I modified them to odd instructions (xor r13d,r14d
, which was 45 31 f5
), and then wrote instructions that added 3 to 45 and 1 to f6. This transformed xor r13d,r14d
to xor rsi,rsi
, then ran the instruction. I also stored the string /bin/sh
at the beginning of the memory address provided for our shellcode, and copied that address from the rdx
register. Register 15 (r15
) was my main scratch register.
Shellcode:
1 | ### PUT "/bin/sh" AT BEGINNING OF INSTRUCTIONS ### |
I then put this shellcode into a Python script with pwntools (odd.py) and ran it! Results:
1 | $ python3 odd.py REMOTE |
Flag: uiuctf{5uch_0dd_by4t3s_1n_my_r3g1st3rs!}