nc -l 5555
Note: on older Ubuntu versions, and on BackTrack 4 R2, you need to use
this command instead: nc -l -p 5555
On the Linux target machine, open another Terminal window and execute this command:
netstat -an | grep 5555
You should see a process listening on port 5555,
as shown below on this page.
On the Linux Sender machine, execute these commands.
sudo iptables -A OUTPUT -p tcp --tcp-flags RST RST -j DROP
sudo iptables -L
You should see one rule in the OUTPUT section dropping RST packets,
as shown below on this page.
If you are using Ubuntu, use this command to install it:
sudo apt-get install python-scapy
sudo scapy
i = IP()
i.dst="192.168.198.139"
i.display()
scapy fills in both the source and destination addresses,
as shown below on this page.
t = TCP()
t.dport = 5555
t.flags = "S"
t.display()
The properties of your TCP object should look like the example
shown below on this page. Notice that the seq and ack numbers
are both 0.
sr1(i/t)
This command sends and receives one packet, of type IP at layer 3 and TCP at layer 4.
As you can see in the image below, the response is shown,
with flags=SA (a SYN/ACK reply).
The ack number is 1, indicating that this is a reply to your SYN
packet with seq = 0.
Find the seq number in the SYN/ACK reply--in the figure below, it is 2833926512. Add one to this number to find the ack value you must use in the ACK packet that completes the handshake.
t.flags = "A"
t.seq = 1
t.ack = 2833926513
t.display()
The properties of your TCP object should look like the example
shown below on this page.
Use this command to send the packet onto the network:
send(i/t)
netstat -an | grep 5555
You should see a connection from local port 5555 with
a status of ESTABLISHED,
as shown below on this page. If you don't see the session, it may have
timed out. Repeat the steps more quickly--try to get the ACK sent
within 30 seconds of the SYN. A trick that sometimes helps is to
send some layer 7 data along with the ack: instead of using the
send(i/t) command, use send(i/t/"X")
to send the final ACK. That will keep the session open longer, while the
target waits for more layer 7 data.
Make sure you can see the ESTABLISHED connection.
Save a screen image with the filename Proj 10 from Your Name.
Email the images to [email protected] with a Subject line of Proj 10 from Your Name.
http://blog.facilelogin.com/2010/12/hand-crafting-tcp-handshake-with-scapy.html
Last modified 8-1-11 11 pm