如果要进行完整的三向握手,则必须手动进行。
从您的SYN数据包开始:
>>> syn = IP(dst='www.google.com') / TCP(dport=80, flags='S')>>> syn<IP frag=0 proto=tcp dst=Net('www.google.com') |<TCP dport=www flags=S |>>
然后从服务器接收SYN-ACK数据包,sr1起作用。然后发送您的HTTP GET请求:
>>> syn_ack = sr1(syn)Begin emission:Finished to send 1 packets.*Received 1 packets, got 1 answers, remaining 0 packets>>> syn_ack<IP version=4L ihl=5L tos=0x0 len=44 id=424 flags= frag=0L ttl=55 proto=tcp chksum=0x2caa src=74.125.226.148 dst=10.20.30.40 options=[] |<TCP sport=www dport=ftp_data seq=3833491143 ack=1 dataofs=6L reserved=0L flags=SA window=5720 chksum=0xd8b6 urgptr=0 options=[('MSS', 1430)] |<Padding load='x00x00' |>>>
然后设置您的TCP序列和确认号并发送GET:
getStr = 'GET / HTTP/1.1rnHost: www.google.comrnrn'request = IP(dst='www.google.com') / TCP(dport=80, sport=syn_ack[TCP].dport, seq=syn_ack[TCP].ack, ack=syn_ack[TCP].seq + 1, flags='A') / getStrreply = sr1(request)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)