如何创建HTTP GET请求Scapy?

我需要创建HTTP GET请求并保存数据响应。我试图用这个:

    syn = IP(dst=URL) / TCP(dport=80, flags='S')

syn_ack = sr1(syn)

getStr = 'GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n'

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') / getStr

reply = sr1(request)

print reply.show()

但是,当我打印时reply,没有看到任何数据响应。另外,当我签入“ Wireshark”时,我收到了SYN,SYN / ACK,但没有收到ACK。

图片:

问题

编辑:

我现在尝试这样做:

# Import scapy

from scapy.all import *

# Print info header

print "[*] ACK-GET example -- Thijs 'Thice' Bosschert, 06-06-2011"

# Prepare GET statement

get='GET / HTTP/1.0\n\n'

# Set up target IP

ip=IP(dst="www.google.com")

# Generate random source port number

port=RandNum(1024,65535)

# Create SYN packet

SYN=ip/TCP(sport=port, dport=80, flags="S", seq=42)

# Send SYN and receive SYN,ACK

print "\n[*] Sending SYN packet"

SYNACK=sr1(SYN)

# Create ACK with GET request

ACK=ip/TCP(sport=SYNACK.dport, dport=80, flags="A", seq=SYNACK.ack, ack=SYNACK.seq + 1) / get

# SEND our ACK-GET request

print "\n[*] Sending ACK-GET packet"

reply,error=sr(ACK)

# print reply from server

print "\n[*] Reply from server:"

print reply.show()

print '\n[*] Done!'

但它会打印出服务器的回复;

0000 IP / TCP 192.168.44.130:23181> 216.58.208.164:http A / Raw ==> IP / TCP

216.58.208.164:http> 192.168.44.130:23181 A /填充无

我需要基于行的文本数据:text / html。

回答:

您正在发送SYN并正确接收到SYN_ACK。此时,您应该基于收到的SYN_ACK生成并发送一个ACK,然后最终传输HTTP GET请求。似乎您对TCP

3路握手机制有些困惑。简而言之,您不应“获取” ACK,而应自己生成并发送此确认。

以上是 如何创建HTTP GET请求Scapy? 的全部内容, 来源链接: utcz.com/qa/404057.html

回到顶部