如何创建 HTTP GET 请求 Scapy? [英] How to create HTTP GET request Scapy?

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

问题描述

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

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
Host: www.google.com

'
    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.

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.

图片:

我现在尝试这样做:

# 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

'

# 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 "
[*] 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 "
[*] Sending ACK-GET packet"
reply,error=sr(ACK)

# print reply from server
print "
[*] Reply from server:"
print reply.show()

print '
[*] Done!'

但是它打印我作为服务器的回复;

but its print me in reply from server;

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/Padding None

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 / Padding None

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

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

推荐答案

您正在发送 SYN 并正确接收 SYN_ACK.此时,您应该根据您收到的 SYN_ACK 生成并发送一个 ACK​​,然后最终发送 HTTP GET 请求.看来你对TCP 3次握手机制有些困惑.简而言之,您不应该获得"ACK,您应该自己生成并发送.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆