本文介绍了如何创建HTTP GET请求Scapy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

$ $ p $ code> syn = IP(dst = URL)/ TCP(dport = 80,flags ='S')
syn_ack = sr1(syn)
getStr ='GET / HTTP / 1.1 \r\\\
Host:www.google.com\r\\\
\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()

但是当我打印回复时,我没有看到任何数据响应。
另外,当我检查'Wireshark'时,我得到了SYN,SYN / ACK,但是我没有收到确认信。

Image:



编辑:

我现在试着去做:

 #从scapy.all导入scapy 
导入*

#打印信息标题
print[*] ACK-GET示例 - Thijs'Thice'Bosschert,06-06-2011

#准备GET语句
get ='GET / HTTP / 1.0 \\\
\\\
'

#设置目标IP
ip = IP(dst =www.google.com)

#生成随机源端口号
端口= RandNum(1024,65535)

#创建SYN数据包
SYN = ip / TCP(sport = port,dport = 80,flags =S, seq = 42)

#发送SYN并接收SYN,ACK
打印\\\
[*]发送SYN数据包
SYNACK = sr1(SYN)

#使用GET请求创建ACK
ACK = ip / TCP(sport = SYNACK.dpor t,dport = 80,flags =A,seq = SYNACK.ack,ack = SYNACK.seq + 1)/ get

#发送ACK-GET请求
print\\ \\ n [*]发送ACK-GET包
回复,错误= sr(ACK)

#打印回复来自服务器
打印\\\
[*]服务器:
print reply.show()

print'\\\
[*] Done!'

但它的打印回复来自服务器;

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

解决方案

SYN并正确接收SYN_ACK。此时,您应根据您收到的SYN_ACK生成并发送ACK,然后最终传输HTTP GET请求。看起来你对TCP 3路握手机制有些困惑。总之,你不应该'得到'一个ACK,你应该自己生成并发送这个。


I need to create HTTP GET request and save the data response.I tried to use this:

    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()

But when I print reply I don't see any data response.In addition, when I checked in 'Wireshark' I got SYN, SYN/ACK but I didn't get an ACK.

Image:

Edit:

I try to do that now:

# 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!'

but its print me in reply from server;

And I need Line-based text data: text/html.

解决方案

You are sending a SYN and correctly receiving a SYN_ACK. At this point, you should generate and send an ACK based on the SYN_ACK that you've received, and THEN finally transmit the HTTP GET request. It seems that you are somewhat confused about the TCP 3-way handshake mechanism. In short, you are not supposed to 'get' an ACK, you are supposed to generate and send this yourself.

这篇关于如何创建HTTP GET请求Scapy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 18:37