pyshark实时抓包输出二进制、十进制、十六进制数据

    技术2025-12-23  15

    1、在FileCapture下

    packets = pyshark.FileCapture( input_file=pcap_file, use_json=True,include_raw=True)._packets_from_tshark_sync() hex_packet = packets.__next__().frame_raw.value print(hex_packet) binary_packet = bytearray.fromhex(hex_packet) print(binary_packet) int_packet = list(binary_packet) print(int_packet)

    2.LiveCapture

    packets = pyshark.LiveCapture( interface=iface, use_json=True,include_raw=True)._packets_from_tshark_sync() hex_packet = packets.__next__().frame_raw.value print(hex_packet) binary_packet = bytearray.fromhex(hex_packet) print(binary_packet) int_packet = list(binary_packet) print(int_packet)
    Processed: 0.015, SQL: 9