$ cd your/lab/directory
$ python -m venv .venv
$ source .venv/bin/activate
30 May 2025
Procedure
Complete the following procedure, showing the steps required to complete the tasks and gather key evidence (e.g., addresses). Show the claims and evidence that support your reasoning.
-
Download vulnerable.c and compile it into an executable.
-
How does your compiled executable
vulnerablecompare to this executable? -
Install the Python
roppertool by runningpip install ropper.TipIf
pipdoes not install to the usersite-packagesby default (you will see a "permission denied" error), create a Python virtual environment first:Use `ropper` to examine the ROP gadgets in each binary. How do the number of gadgets compare? Why?
-
-
Using a debugger and the data file 1x1 or 4x4, illustrate the contents of the stack just before returning from the
load_matrixfunction (i.e., at line 71 or 72). Show the stack contents from the address in%rspto the call’s return address. Highlight all parameters, local variables and the return address. -
Use a debugger to explain why the fuzzer-generated test cases crash0 and crash1 crash the
vulnerablebinary. -
Create an input file that will cause
load_matrixto zero out the stack frommatrixto the return address. Use the debugger to verify that the file is successfully read and that the correct address is zeroed out. Why does the program fail to run to completion? -
Modify your input file so that the values of
file_sizeandHEADER_SIZEare preserved when the stack is overwritten. Demonstrate that the program now terminates by attempting to execute code at address 0. -
Use the
roppertool to generate a ROP-chain payload for the vulnerable-provided binary that I gave you earlier. This ROP chain should execute the shell/bin/sh. Pass this payload into the vulnerable-provided binary and, using the debugger, explain why the process crashes. -
Required for ENGI 9823, optional for ENGI 7420: Modify the ROP chain (in Python or in the binary file) to successfully execute the ROP chain. Use the debugger to demonstrate how execution passes through at least the first three gadgets of the chain. Demonstrate that the end result is a shell.