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: 
Although, Scapy does not have native support for HTTP Layer but there is a python module available for extending the functionality of Scapy to support HTTP layer. The module name is "scapy-http" and can be found on github at [invernizzi/scapy-http](https://github.com/invernizzi/scapy-http).  

You can install it using pip:

```
    sudo pip install scapy-http
```

Here is the example code from github repository:

```

    #!/usr/bin/env python
    try:
        import scapy.all as scapy
    except ImportError:
        import scapy

    try:
        # This import works from the project directory
        import scapy_http.http
    except ImportError:
        # If you installed this package via pip, you just need to execute this
        from scapy.layers import http

    packets = scapy.rdpcap('example_network_traffic.pcap')
    for p in packets:
        print '=' * 78
        p.show()

```

Using this module, you can generate HTTP packets without sending your own text data.
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