creating a pcap file using python

前端 未结 3 2067
忘掉有多难
忘掉有多难 2020-12-20 06:41

I\'m trying to create a very simple PCAP file (1 UDP message).
Tried using dpkt (pcap.Writer), no luck, and the documentation is scarce.
Can anyone post a working ex

3条回答
  •  情歌与酒
    2020-12-20 07:00

    You may use Scapy.

    https://scapy.readthedocs.io/en/latest/installation.html

    If using Python 3:

    pip3 install scapy
    

    Then in Python:

    from scapy.all import wrpcap, Ether, IP, UDP
    packet = Ether() / IP(dst="1.2.3.4") / UDP(dport=123)
    wrpcap('foo.pcap', [packet])
    

提交回复
热议问题