How to create HTTP GET request Scapy?

Yair B.

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: The problem

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;

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

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

wookie919

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Create HTTP GET Header Request

From Dev

Create HTTP GET Header Request

From Dev

How to create an XML Http Request?

From Dev

How to create a HTTP Request in Telnet

From Dev

HTTP GET packet sniffer in Scapy

From Dev

how to get response of http request

From Dev

How to get the type of the HTTP request

From Dev

how to create simple Http request via AFNetworking

From Dev

How to create a http request that contains multiple FileHeaders?

From Dev

How do I create an HTTP Request in Rails?

From Dev

How to create a cross domain HTTP request

From Java

How to get a testing http request in django testcase?

From Java

How to properly make a http web GET request

From Dev

How to get URL in http.Request

From Java

How to write a test for an http get request in elm

From Dev

How to get http request origin in php

From Dev

How to make an HTTP GET request manually with netcat?

From Dev

how to pass date in $http.get request

From Dev

How to send HTTP (GET) request in background

From Dev

how to pass date in $http.get request

From Dev

How to get all results in a http request python

From Dev

(GET http request) How send cookie in the server

From Dev

How to get correct data from HTTP Request

From Dev

How to get full HTTP request (not response) headers

From Dev

how to rewrite HTTP get request with .htaccess

From Dev

How to create a GET, POST, and PUT request in Swift?

From Dev

Django - How to create/apply a Serializer for a GET request?

From Dev

How to create a Scapy packet from raw bytes

From Dev

how to create a breakpoint to the function sr() of scapy?