Commit f638d57c authored by Barcis, Michal's avatar Barcis, Michal
Browse files

sniffer added

parent 629f1fc4
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import binascii
import json
import subprocess as sub
CMD = (
'sudo tshark -i wlan0 -Y'.split() +
["frame contains \"MEEETADATA\""] +
'-T fields -e data'.split()
)
p = sub.Popen(CMD, stdout=sub.PIPE)
for row in iter(p.stdout.readline, b''):
packet = binascii.unhexlify(row.rstrip())
FRAME_IDENT = b"MEEETADATA"
s = packet.find(FRAME_IDENT)
if s == -1:
continue
data_start = s+len(FRAME_IDENT)+1
data_len = packet[data_start-1]
data_str = packet[data_start:data_start+data_len]
data = json.loads(data_str)
print("!", data)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment