Answer the question
In order to leave comments, you need to log in
Pyshark: how to serialize a package to json?
There is a simple pyshark sniffer that outputs the captured packet directly to bash:
import pyshark
capture = pyshark.LiveCapture(interface='ens33')
while(1):
capture.sniff(packet_count=1)
for packet in capture:
print (packet)
Answer the question
In order to leave comments, you need to log in
looked more closely at the output.
this is 99% typical yaml file
installed Pyaml
and tried
or in the interpreter
import yaml
with open("tshark.yml", 'r') as stream:
data_loaded = yaml.safe_load(stream)
{
"Packet (Length": "90)",
"Layer ETH": {
"Destination": "c4:6e:1f:07:3f:42",
"Address": "00:0c:29:ef:ff:9c",
".... ..0. .... .... .... .... = LG bit": "Globally unique address (factory default)",
".... ...0 .... .... .... .... = IG bit": "Individual address (unicast)",
"Source": "00:0c:29:ef:ff:9c",
"Type": "IPv4 (0x0800)"
},
"Layer IP": {
"0100 .... = Version": 4,
".... 0101 = Header Length": "20 bytes (5)",
"Differentiated Services Field": 16,
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question