Project #1

Errata:

Goal

The Environment

The Targets

The Exploits

The 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.

The Assignment

You are to write exploits, one per target. Each exploit, when run in the virtual machine with its target installed setuid-root in /tmp, should yield a root shell (/bin/sh).

Hints

Warnings

Aleph One gives code that calculates addresses on the target's stack based on addresses on the exploit's stack. Addresses on the exploit's stack can change based on how the exploit is executed (working directory, arguments, environment, etc.); in our testing, we do not guarantee to execute your exploits as bash does.

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.

Deliverables

How to set up the Environment

We will be showing you how to set up the environment and solving an overflow problem in section. The problem we'll be solving is essentially identical to target1, so come to section if you want a jump start. If you want an earlier start, here are the following steps that you need to take to set up the environment.

  1. VMware player should be installed on the lab Windows machines. If you're working on your own machine, you can download and install VMware player from http://www.vmware.com/products/player/ (for Windows and Linux) or VMware Fusion from http://www.vmware.com/download/fusion/ (for Mac OS X). Note that you can't install anything on the Linux lab machines.
  2. Download the VMware virtual machine tarball: box-updated.tar.gz).
  3. Decompress and unarchive the virtual machine tarball:

    $ tar zxvf box.tar.gz

    If you're using Windows, you can use 7-zip to extract the files (7-zip should be installed on the lab Windows machines). Next, open the file box.vmx using VMware Player. If VMware Player asks you if you moved or copied the virtual machine, say that you copied it.
  4. Login to the virtual machine. There are two accounts, root with the password root, and user with the password user.
  5. Ensure that networking is working by typing ifconfig and checking that the inet addr: field of eth0 has a valid IP address.
    If you're using a lab Windows machine:
    1. Look for eth0 and notice the IP address. It should be something like 192.168.X.Y where X and Y are two more numbers. For me the address was 192.168.142.128. I'll use these numbers through the rest of the instructions. You should now be able to ssh out of the box. Try sshing into attu.
    2. Okay, now back in Windows land, press the Start button and the letter r. Type cmd. Now try to ping your VM: ping 192.168.142.128 (remember to use your IP if yours was different in step 1). The ping will likely fail. If it doesn't, then skip to the step ix.
    3. In the start menu, click Control Panel -> Network and Sharing Center. On the left hand side of the window that opens, choose Adapter Settings.
    4. Right click on VMWare Adapter #3 and select Enable.
    5. Right click on VMWare Adapter #3 and select Properties.
    6. Select TCP/IPv4 and click Properties
    7. Change the IP to 192.168.142.1 (Note that if your X in step i was not 142, then you should put it instead of the 142)
    8. Try pinging the VM again. If it works, go to the next step, if it doesn't, eat some cake* (or seek grief counceling) and try the instructions again. If it still doesn't work, e-mail me.
    9. In the start menu, navigate to the ssh client. You should now be able to ssh into the VM with the user or root account using the IP from step i.
  6. Download the project 1 tarball (cse484-proj1.tar.gz) onto the virtual machine. You can do this by downloading the tarball first, then using scp or an sftp client to transfer the files onto the vm. Alternatively, log in as root to the vm and type:

    box:~# wget http://www.cs.washington.edu/education/courses/cse484/10wi/projects/project1/cse484-proj1.tar.gz

  7. Decompress and unarchive the files as before:

    $ tar zxvf cse484-proj1.tar.gz

    Copy the sploits/ directory 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 the contents of the targets/ directory to /tmp. In /tmp, make the targets then apply the following commands to set up the permissions so that the targets are owned by root, are setuid root, and the .c files are publicly readable. Doing this correctly will allow gdb to read the source files while you are debugging.

    box:/tmp# chown root:root target? ; chmod 4755 target? ; chmod a+r target?.c

  8. Every time you reboot the vm, you'll have to set up the targets in vm's /tmp because it'll be wiped clean.

Misc

Credits

This project was originally designed for Dan Boneh and John Mitchell's CS155 course at Stanford, and was then also extended by Hovav Shacham at UCSD. Thanks Dan, John, and Hovav!


*The cake is a lie