Phase 4: Calling touch2 with Gadgets
Refer back to the Return-Oriented Programming page.
For Phase 4, you will repeat the attack of Phase
2, arranging for your exploit to call
touch2, but this time you will attack the program rtarget with
gadgets from your gadget farm. You can construct your solution
using, using only the first eight x86-64 registers (rax–rdi) and
gadgets consisting of the following instruction types:
movq- The codes for using
movqto copy data from one register to another are shown in the table Byte Encodings ofmovqInstructions. popq- The codes for using
popqto copy data from one register to another are shown in Byte Encodings ofpopqInstructions. ret- This instruction is encoded by the single byte
0xc3. nop- “No operation” or “nop” (pronounced “no op”) is encoded by the
single byte
0x90. Its only effect is to cause the program counter to be incremented by 1.
Hints
- All the gadgets you need for this part can be found in the region
of
rtarget's code demarcated by the functionsstart_farmandmid_farm. - You can do this attack with just two gadgets.
-
When a gadget uses a
popqinstruction, it will pop data from the stack. As a result, your exploit string will contain a combination of gadget addresses and data. -
There is a
-qflag tortargetthat stops the program from talking to the grading server. -
There is an
-ioption tofile rtargetthat tells it to read from a file namedinstead of fromfile stdin.
(When logged in, completion status appears here.)