scapy 3 way handshake

不问归期 提交于 2021-01-28 05:07:11

问题


I am trying to build a scapy 3 way handshake. But when I send an Acknowledgement packet in response of SYN-ACK packet, I receive a FA packet instead of completion of 3 way handshake. My code is.

from scapy.all import*

ip = IP(dst = "192.168.0.1")
syn = TCP(dport=35021, flags="S", seq=100)
synack = sr1(ip/syn, iface = "D-Link DUB-E100 USB 2.0 Fast Ethernet Adapter")
ack = TCP(dport=35021, flags="A", seq=101, ack=synack.seq+1)
ans=sr1(ip/ack, iface = "D-Link DUB-E100 USB 2.0 Fast Ethernet Adapter")

The output which I receive in the end is,

>>> ans
<IP  version=4 ihl=5 tos=0x0 len=40 id=22653 flags=DF frag=0 ttl=64 proto=tcp chksum=0x6003 src=192.168.0.1 dst=192.168.0.254
options=[] |<TCP  sport=35021 dport=ftp_data seq=4141767969L ack=101 dataofs=5 reserved=0 flags=FA window=1500 chksum=0x4a61 u
rgptr=0 |<Padding  load='\x00\x00\x00\x00\x00\x00' |>>>

But when I send some data in ACK packet setting the 'flags=PA' I get a proper response against the data I send.

Shouldn't it behave like, complete 3-way handshake first and then send data? I am using scapy on Windows10 with python 2.7 and scapy latest version.

来源:https://stackoverflow.com/questions/45734269/scapy-3-way-handshake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!