0

我正在尝试编写一个使用 scapy 进行 http 流水线处理的脚本。当我调用我的发送函数来背靠背发送我的两个 http 请求时,请求不是流水线的。在收到第一个 http 响应后发送第二个 http 请求。

我所拥有的片段:

#Send SYN
syn = IP(src="31.31.31.10",dst='31.31.31.17') / TCP(dport=80,sport=RandShort(),flags='S')
syn_ack = sr1(syn)
#Send ACK
ack = (IP(src="31.31.31.10",dst="31.31.31.17")/TCP(dport=80, sport=syn_ack[TCP].dport,seq=syn_ack[TCP].ack, ack=syn_ack[TCP].seq + 1, flags='A'))
send(ack)
#Set the HTTP data
http1 = 'GET /a.html HTTP/1.1\r\nUser-Agent: curl/7.19.4\r\nHost: www.google.com\r\nAccept: */*\r\n\r\n'
http2 = 'GET /b.html HTTP/1.1\r\nUser-Agent: curl/7.19.4\r\nHost: www.google.com\r\nAccept: */*\r\n\r\n'
#Send First GET
get1 = (IP(src="31.31.31.10",dst="31.31.31.17")/TCP(dport=80, sport=syn_ack[TCP].dport,seq=syn_ack[TCP].ack, ack=syn_ack[TCP].seq + 1, flags='PA')/http1)
send (get1)
get1_payload = len(http1)
#Send the Second GET
get2 = (IP(src="31.31.31.10",dst="31.31.31.17")/TCP(dport=80, sport=syn_ack[TCP].dport,seq=syn_ack[TCP].ack + get1_payload, ack=syn_ack[TCP].seq + 1,flags='PA')/http1)
send (get2)

scapy 只是发送第二个请求太慢还是我做错了什么?

4

0 回答 0