pyrip
Breaking out of C invoked-Python interpreter jail.
Problem Description
Is this misc or pwn?
Author: farisv
Analysis
We're given a binary and a C code.
If we try to run the binary, the program will fork the process, and that forked process will run a Python interpreter, and that's what will appear in our terminal. The main process will trace that forked process. Looking at the source code, our objective is to cause a segmentation fault (SIGSEGV) on the fork process running the Python interpreter. When the SIGSEGV happens, the main process will check if the value in the RIP register before the SIGSEGV happened is 0xc0ffeedecaf
. If it is, the main process will print a flag. This means that we need to find a way to run some code through Python that can cause a SIGSEGV and moves the value 0xc0ffeedecaf
to RIP.
Solution Breakdown
RIP is an instruction pointer register that stores the address of the current instruction. "Instruction" here refers to any line of assembly code, even the beginning of a function. That being said, if we want the value in RIP to be 0xc0ffeedecaf
, we need to find a way to "call a function which instructions are stored in 0xc0ffeedecaf
". With that, we're telling the program, like, "Hey, for the next instruction, you have to run the function in 0xc0ffeedecaf
".
Note: I do not have a screenshot of getting the flag from the server. The server also has some technical issues, causing players unable to re-obtain the flag post-competition.
Flag
CJ{=*= Jump, pogo, pogo, pogo, pogo, pogo, pogo, pogo =*/=}
Full Solver Script
Last updated