CS197U: A Hands-on Introduction to Unix

Assignment 6 : Due Thursday October 29, 2015 at 3:45pm

Note: For those who have a total of 45+ points from previous 5 assignments, you're encouraged to do the entire assignment,
but only part-1 and part-2 are required.

This assignment will teach you how to resolve simple networking/security issues and will help you understand better about your own file system.

You will again need to consult `man', earlier lectures, and also the web for finding out how to accomplish the tasks. The tasks are sufficiently complex, so you will need to find out some things on your own. There is often more than one correct approach.

Part 1: Network basics (2pts)

1. Make a new directory called 'assign-6' in: /courses/cs100/cs197/USERNAME
copy files from assignment directory: cp -r /courses/cs100/cs197u/cs197u/assignment/assign-6/* /courses/cs100/cs197u/USERNAME/assign-6/

2. How many network interfaces do you have on your own Ubuntu machine (or virtual machine), what are they? What are their IP address(es), and what command do you use? (It should look like x.x.x.x. If you don't see your wireless interface in virtualbox, just report the other one(s))
3. Write a command that outputs only the IP address of your active network interface. (you will need awk)
4. What is the IP address of edlab server: www-edlab.cs.umass.edu ? what is the command that you use that can covert this into IP address?
Write your answers into file answers-6.txt

Part 2: Debugging your network (2pts)

1. What is the command to check if ESPN's website espn.go.com is alive? What is the average round trip time from your machine to ESPN's server (take 10 samples)?

2. I am watching news from BBC website www.bbc.com , but the connection is a bit slow. What command can I use to track the data packets going from UMass (or your home) to BBC website? If I don't have this tool, what is the command that I should issue to install the tool? ( this part should be done on your own Ubuntu (or virtual box), not on your Mac or Ed-lab server )

3. Show the result of your tracking (if you see too many * at home, redo this in UMass). Briefly describe how the packets are routed to the UK, and tell us where the bottleneck was (i.e., the place where packets start moving very slowly). Was that at the UK side?
(Notice: for windows users, if you are having problems with the command in your virtual machine, you can try tracert in Windows command prompt, which does the same thing. Remember to specify that in your answers-6.txt)
Write your answers into file answers-6.txt

Part 3: Encrypting your messages and documents (3 pts)

1. Run ./script.sh | less and study the code to understand what it does. Look up the tr command in man and on the web for this.

2. Edit the script so that instead of text/alice.txt it takes in the first command line argument. Add code that will check whether the first command line argument is set. If it is set, the line with the tr command should be run. If no argument is given, print out "Need file as argument 1" and do nothing further. Run your script with different files as input, such as text/hamlet.txt for testing the encryption. ( Hint: you can refer to lecture 6 for detectng arguments.)

3. Edit script.sh further to take the key as a second command line argument. Also add code that does the following: If "-" is given as second argument, use the default key in script.sh, otherwise change the key to use the second command line argument. Run your script with different keys for testing.

4. Edit script.sh with a third command line argument (which acts as a flag):

a.) Add code so that the flag can be set to "encrypt" for encrypting the file with the key, and to "decrypt" for decrypting;

b.) Add code so that for any other string given as the third argument (or if it is missing), the code should do nothing;

c.) Add code for the "decrypt" case: if the flag is set to "decrypt", decrypt an encrypted text back to lower-case using the key.

Run your code to verify that encryption and decryption work correctly. Note that for running decryption, you should first run "encrypt" and save the output to a file, and then use that as input with the "decrypt" flag next time. What happens if your key is shorter than the alphabet, or if it contains duplicate letters?

Write your answers into file answers-6.txt

Part 4: Packet sniffing and safeguard your connections (3 pts)

1. Install Wireshark on your own Ubuntu. ( Wireshark quick tutorial)
2. Type sudo wireshark to open wireshark, click the top-left icon to choose an active interface that you want to monitor, and click start
3. On your terminal, type wget -N www-edlab.cs.umass.edu/cs197u/wget.html. When the webpage is downloaded (should be within a second), click the stop icon on wireshark toolbar to stop packet sniffing.

a.) At the protocol column (the 5th column), look for HTTP (in green) and identfy your own connection(s) to edlab server. (with the IP addresses of your machine and the edlab server in the source/destination column - edlab Web IP:
b.) Briefly describe the HTTP conversation between your machine and the edlab server (in 1-2 sentenses).
c.) Find the HTTP packet with HTTP 200 OK (text/html) in the Info column.
d.) Inspect this packet. What are the contents of this pacekt? (You can find them at the very end of the packet named: Line-based text data: text/html).
e.) Go to http://www-edlab.cs.umass.edu/cs197u/wget.html and compare the results.

4. Click the restart button at the wireshark toolbar (the fifth button, you can choose to save the previous results or not).

a.) On your terminal, type scp USERNAME@elnux7.cs.umass.edu:/courses/cs100/cs197u/cs197u/public_html/wget.html ./scp.html (replace USERNAME with your edlab username). Then you'll download the same webpage from edlab server by scp, and will save it with the new name: scp.html.
b.) In wireshark, look for SSH in the protocol column (in light purple) and identify your own connection(s) to edlab server (elnux7 IP:
c.) Inspect each SSH packet, what does the conent look like? Briefly describe the difference of retrieving a webpage by wget and by scp.
Write your answers into file answers-6.txt


I will collect all these files directly from /courses/cs100/cs197u/USERNAME/assign-6/ : Make sure you followed the directions in all parts so the files exist in the correct location and are named correctly as above.Please verify the paths by using cd, pwd and ls.