Question: I want to send a HTTP response via scapy to a target system. I know scapy uses layered implementation to create a packet like IP/TCP/ETHER. To send a simple TCP packet we can use the following scapy script.

```
#!/usr/bin/python
from scapy.all import *

ip=IP(src="10.10.1.207", dst="10.10.1.60")

payload="Hello World"
PUSH=TCP(sport=80, dport=3389, flags="F")
send(ip/PUSH/payload)

```

---

Is there any way we can attach a HTTP layer with this?
I tried many ways however every time I receive a TCP packet instead of a HTTP response packet on the target machine.

Answer: 
**Edit: this is outdated. Since Scapy 2.4.3 you can use [the http layer](https://scapy.readthedocs.io/en/latest/layers/http.html)**

Scapy does not have a native HTTP layer dissector, however, you can send an HTTP request/response easily as it is a textual protocol:

```
RESP  = "HTTP/1.1 200 OK\r\n"
RESP += "Server: exampleServer\r\n"
RESP += "Content-Length: 6\r\n"
RESP += "\r\n"
RESP += "A body"

IP(src="10.10.1.207", dst="10.10.1.60")/TCP(sport=80, dport=3389, flags="A", seq=ACK.ack, ack=ACK.seq)/RESP

```

`ACK` is the third segment of a previously made 3 way handshake (SYN, SYN-ACK, ACK) as this is necessary before sending data over TCP.
As mentioned by Jeff Bencteux's answer, http layer is now available on scapy. This can be easily done by this, here's an example:

```
>>>import scapy.all as S

>>>S.load_layer("http") # without this, http might not be loaded as default
>>> pkg = S.IP() / S.TCP() / HTTP() / HTTPResponse(Server="exampleServer") / "<html></html>"

```

The sting at the end of the last line is raw data. Echoing `pkg` you'll get:

```
>>> pkg
<IP  frag=0 proto=tcp |<TCP  sport=http dport=http |<HTTP  |<HTTPResponse  Server='exampleServer' |<Raw  load='<html></html>' |>>>>>

```

*You should [read the doc](https://scapy.readthedocs.io/en/latest/api/scapy.layers.http.html)* and maybe sniff some http responses to understand which fields you need to modify