In this lab, the instructions are described based on the following configuration of IP addresses: Deliverables: In your VMs, the IP addresses may be slightly different from the above. In your lab report, please give the IP addresses of it430a, it430b and it430c so that I can read your report correctly.

[15pts] Part 1: UDP Socket Spoofing

Refer to the lecture notes on UDP Socket Spoofing. Slightly change the code udp_spoof.py in the lecture notes into p01.py as follows:

Deliverables:

[40pts] Part 2: Crafting a Normal SYN Packet

Create a python program p02.py that sends a normal SYN packet from VM it430a to VM it430b. Your program should create a SYN packet and send it using a raw socket. This task requires complete understanding of how IP and TCP headers work. In particular,

IP header and TCP header

Please inspect the layout of the headers carefully.
Internet Datagram Header
 0                   1                   2                   3   
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |R D M|      Fragment Offset    |
|                               |S F F|                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
TCP header format
 0                   1                   2                   3   
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |           |U|A|P|R|S|F|                               |
| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
|       |           |G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Requirements

You should only import the following modules. Do NOT import any other module.

import struct
import random
import socket

Tips

You may find this article helpful.

Common mistakes

If your code doesn't work, please double check the following.

Deliverables

[15pts] Part 3: Crafting a SYN Packet with a Spoofed IP address

Warning

Do not flood SYN packets attack on the yard.
Create a python program p03.py that sends a SYN packet from VM it430a to VM it430b. However, in this part, the source IP address should contain not the IP address of it430a but the IP address of it430c.

Activity 1

  1. Turn on it430c.
  2. Start an nc chet server listening at port 9000 on it430b.
    $ nc -l 9000
  3. On it430b (note it's not it430a this time), launch Wireshark.
  4. On it430a, run the program p03.py as follows:
    $ sudo python3 p03.py
    
  5. Then, from Wireshark (again not on it430a but on it430b), you should see: That is, you should something like the picture below (the port number will be different).

    In the above, the IP address for it430a is 192.168.172.4 and the IP address for it430b is 192.168.172.5, and the IP address for it430c is 192.168.172.6. Note:

Activity 2

Conceptually, if you change p03.py to send a bunch of SYN packets with a random source IP address, that's a SYN flood attack. (Again, don't actually do this).

Deliverables:

[20pts] Part 4: Reading Assignment

  1. Click here to download chapter 2 of the following book:
    Security Engineering, 3rd ed. by Ross Anderson
  2. Read the following:
    • 2.4 Geeks - 2.6 Summary
    (Eventually, we will finish reading the whole chapter. Expect further reading assignments in later labs.)
  3. In the lab report, give a brief summary of what you read.

[10pts] Lab Report and Submission

Write a lab report by using the provided template (check the lab ground rules). The writing quality of the lab report matters.
~/bin/submit -c=IT430 -p=lab06 *.py lab06.docx