Takehome exam

Upload via Moodle as: final.tar, including a writeup (final.txt or final.md or final.pdf, for example) and your code for problem 3 (server.py).

This is a take-home exam. Do your own work, and do not discuss the contents of the exam with any person other than Jeff or your prefect. Do not use LLMs for this exam. If Google or another search engine gives you AI summaries, it's OK to read them, but you need to check up on the validity of their answers if you use those answers in your submission.

1. Buffer overflow (15 points)

This has been a homework assignment in past terms, so instead of importing its description into this page, I'll just direct you to the buffer overflow homework page.

3. Moving bits around with base64 (6 points)

The base64 encoding scheme converts any arbitrary sequence of bytes into a corresponding sequence of printable ASCII characters (letters, digits, and a few punctuation marks).

Read up on base64 encoding and answer the following questions.

  1. Why would we bother encoding data in this way instead of just leaving the data as it was to begin with? (One well-explained application would be a sufficient answer for this question.)
  2. Suppose you have a base64-encoded string in a file named message.base64. Show me the command you would use on mantis or similar systems to covert the contents of the file back to its original form.
  3. What original sequence of bytes would have the base64 encoding of R3JlYXQhCg==? Show how the bits of the original bytes are reassembled when you decode R3JlYXQhCg== (for example, via some sort of diagram showing which bits come from R and 3 etc., and where those bits go to reconstruct the original bytes).

2. Implementing a tiny HTTP-like protocol (8 points)

For this exercise, you're going to modify the sample server.py. Your modified code will implement the server side of the protocol described below.

Hand in:

  1. Your modified version of server.py
  2. A brief explanation of how to use nc as a rudimentary client to test your server, including the specific command(s) plus anything else you would type while testing.
Super-Tiny HTTP Normal flow of events 1. Client requests TCP connection, and connection setup occurs. 2. Once TCP connection is established, client sends GET FILENAME where FILENAME is the name of a requested file. 3. If the specified file is present and readable in the directory from which the server was launched, server sends 200 OK Content-length: NUMBER_OF_BYTES_IN_FILE CONTENTS_OF_FILE If the file does not exist or is not openable for reading, the server sends, instead: 404 Not Found 4. Server closes connection Exception: If in step 2 the client sends something other than "GET " followed by a non-zero length string, the server sends "400 Bad Request" and then closes the connection.

4. Educating and/or entertaining Jeff (2 points)

I just finished a book. What should I read next? Or watch? Or waste time with over the summer? Or whatever?

Thanks for a great term

Enjoy your summer, everyone. Seniors, congratulations and good luck out there!