-1

i have a list of packets
i want to save packets in pcap file with pyshark
I can't convert packets to bynary of that



    packets = []  # List to store filtered packets

    # Loop through packets and filter based on the capture filter
    for packet in capture:
        if packet.matches(capture_filter):
            packets.append(packet.raw_mode_packet)  # Save the raw packet data

    # Save the filtered packets to a new pcap file
    with open(output_file, "wb") as f:
        for packet in packets:
            f.write(packet)

amir.h
  • 1
  • 1

0 Answers0