/tmp/target1, ... , /tmp/target7
). These programs are all
installed as setuid root in the boxes system. Your goal is to write seven
exploit programs (sploit1, ..., sploit7). Program sploit[i] will execute
program /tmp/target[i], giving it certain input that should result in a root
shell on the boxes system. In other words, before running your sploit, the
command whoami
should output user and after running your
sploit, the command whoami
should output root.
sploit1, ..., sploit7
are provided in the
sploits/
directory. Note that the exploit programs are very
short, so there is no need to write a lot of code here.
targets/
directory in the assignment tarball contains the source code
for the targets, along with a Makefile specifying how they are to be built.
/tmp
-- /tmp/target1, /tmp/target2,
etc.
sploits/
directory in the assignment tarball contains skeleton source for
the exploits which you are to write, along with a Makefile for building them.
Also included is shellcode.h, which gives Aleph One's shellcode.
/tmp
, should yield a root shell (/bin/sh
).
disassemble
and stepi
commands. You may find the x
command
useful to examine memory (and the different ways you can print the contents
such as /a /i
after x
). The info
register
command is helpful in printing out the contents of registers
such as ebp
and esp
. gdb
is to use the -e
and -s
command
line flags; for example, the command gdb -e sploit3 -s
/tmp/target3
in boxes tells gdb to execute sploit3 and use the symbol
file in target3. These flags let you trace the execution of the target3 after
the sploit has forked off the execve process. When running gdb using these
command line flags, be sure to run
the program before you set any
breakpoints; for our purposes, entering the command run
naturally breaks
the execution at the first SIGTRACE
before the target is
actually exec-ed, so you can set your breakpoints when gdb
catches the SIGTRACE
.You must therefore hard-code target stack locations in your exploits. You should not use a function such as get_sp() in the exploits you hand in.
chmod 700 /tmp/yoshi
.
wget http://www.cs.washington.edu/education/courses/cse484/09wi/projects/lab1/code/lab1.tar.bz2
wget http://www.cs.washington.edu/education/courses/cse484/09wi/projects/lab1/code/boxes.tar.bz2
romieu% tar jxvf boxes.tar.bz2 ; tar xjvf lab1.tar.bz2
romieu% setenv BOXESDIR /tmp/yoshi/boxes
romieu% setenv BOXESHOME /tmp/yoshi
romieu% setenv PATH /tmp/yoshi/boxes:$PATH
For convenience, instead of repeatedly typing in the commands, you may wish to place the three setenv commands into a file and "source" the file whenever you log into a machine.
romieu% xterm -e boxes/string &
Then run boxes, specifying the copy-on-write disk and the virtual private network.
romieu% boxes/openbox cow1 10.64.64.64
box:~# mount none -t hostfs /mnt -o /tmp/yoshi/project
Now you can access the project files in /mnt
. Copy the sploits dir
to the user's home directory (and make sure to set the ownership so that user
can access them chown -R user:user sploits
), and target dir to
root's home directory. Make the targets and copy the targets to
/tmp
together with the corresponding .c and .h files. Using the
following commands, set up the permissions so that the targets are owned by
root, are setuid root, and the .c and .h files are publicly readable.
box:~# chown root:root target? ; chmod 4755 target? ; chmod a+r target?.[ch] ; chmod a+r tmalloc.[ch]
/tmp
because it will be wiped clean. Also make sure to
periodically transfer your work out to your home directory on the real machines
because the lab machines' /tmp
(containing your copy of boxes and
the project) gets wiped periodically. To save your instance of boxes, you
can copy cow1
to your home directory and then when you set boxes
up again, you can just copy cow1
back to your /tmp
directory and start boxes with that image.
box:~# TERM=vt100 ; vi /etc/inittab
and uncomment out lines:
##2:23:respawn:/sbin/getty 38400 vc/2
##3:23:respawn:/sbin/getty 38400 vc/3
to spawn two extra console windows on the next reboot of boxes. The only two editors on the boxes environment are nano and vi. If you prefer other editors, write the code outside of boxes and then use nano to paste the code into a text file in a boxes console.