Scapy 2

Note: The videos found here could help if you are stuck.

TCP Handshake

Write and execute the code that will perform a three-way TCP handshake to with a destination port of 40001. Here is some code to get you started (it generates the 3 way handshake):


    from scapy.all import *


    i.dst = ""

    t = TCP()
    t.dport = 80
    r = sr1(i/t)
    t.flags = "A"
    t.seq = r.ack
    t.ack = r.seq + 1
    p = i/t

You will probably have to disable RST packets by doing something like:

    sudo iptables -A OUTPUT
    sudo iptables –A OUTPUT –p tcp –s --tcp-flags RST RST –j DROP

The ip address above is the ip address of the machine that we don’t want to drop RST packets for.

Send an 8 character code as raw data. (Probably not your last name). You should be able to see if you succeeded by visiting this site. No more than 8 characters.


Modify your previous code so to send to destination port of 40002 on Your packet should arrive with a TTL of 1 to the destination. HINT: This is very easy and should only necessitate adding a single line of code to the previous one. You will probably also make use of the traceroute program. You should be able to see if you succeeded by visiting this site (you should see an entry for firewalk). You may need to double check that port 40002 is actually open if you are doing this on a non-cit farm computer. Write a short paragraph on what TCP firewalking is.

To Submit

Last Updated 02/17/2021