Solution for http://www.overthewire.org/wargames/vortex/vortex1.shtml. Here’s the code they have used:
|
|
The executable was at /vortex/vortex1:
|
|
I hope you have noticed the SETUID-Bit which belongs to user vortex2. So that programm will run as vortex2. The password we need to find out is at /etc/vortex_pass/vortex2. Now let’s analyze the code…
- There is a buffer
buf
of size 512 * ptr points at the middle of the buffer - Everytime “"” is read in,
ptr
is decremented. So we need to set ptr to the beginning ofbuf
’s address e()
is a macro which checks if*ptr = 0xCA
. If this is true, then an “interactive shell will be launched. This is what I did:
|
|
Nothing happens. We need to execute the new process (/bin/sh) with some “extra arguments”. I have created following script:
|
|
…then as the bash manual states:
“When invoked as an interactive shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute”
We’ll need to set the ENV variable properly and we’re done:
|
|