0

i have used the following code in order to send a HTTP GET request:

syn = IP(dst='www.google.com') / 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)

and i am still waiting to receive a response packet from google

hashcode55
  • 5,622
  • 4
  • 27
  • 40
  • I think this post may help you. [link](http://stackoverflow.com/questions/37683026/how-to-create-http-get-request-scapy) – Noob123 Jun 21 '16 at 14:46

1 Answers1

0

It might have something to do with the fact that you are not following proper TCP protocol. Reading you code it looks like you forgot the ACK in the 3-way handshake (SYN-SYN_ACK-ACK). So your sending it data, but its just going to ignore it because you have not finished setting up the connection. Try doing something like the following.

syn = IP(dst='www.google.com') / TCP(dport=80, flags='S')
syn_ack = sr1(syn)
ack = TCP(sport=syn.sport, dport=80, flags='A', seq=syn_ack.ack, ack=syn_ack.seq + 1)
ack_resp = sr1(ip/ack)

getStr = 'GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n'
request = IP(dst='www.google.com') / TCP(sport=syn.sport, dport=80, flags='A', seq=ack_resp.ack, ack=ack_resp.seq $
reply = sr1(request)

I have not tested this so it may or may not work, but it definitely will not work without the last ACK.

B_Ride
  • 31
  • 4