scapy.contrib.tzsp

TZSP - TaZmen Sniffer Protocol

author

Thomas Tannhaeuser, hecke@naberius.de

license

GPLv2

This module is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

description

This module provides Scapy layers for the TZSP protocol.

references:
NOTES
  • to allow Scapy to dissect this layer automatically, you need to bind the TZSP layer to UDP using # noqa: E501 the default TZSP port (0x9090), e.g.

    bind_layers(UDP, TZSP, sport=TZSP_PORT_DEFAULT) bind_layers(UDP, TZSP, dport=TZSP_PORT_DEFAULT)

  • packet format definition from www.networkchemistry.com is different from the one given by wikipedia # noqa: E501

  • seems Wireshark implements the wikipedia protocol version (didn’t dive into their code) # noqa: E501

  • observed (miss)behavior of Wireshark (2.2.6) - fails to decode RSSI & SNR using short values - only one byte taken - SNR is labeled as silence - WlanRadioHdrSerial is labeled as Sensor MAC - doesn’t know the packet count tag (40 / 0x28)

class scapy.contrib.tzsp.TZSP

Bases: scapy.packet.Packet

ENCAPSULATED_ETHERNET = 1
ENCAPSULATED_IEEE_802_11 = 18
ENCAPSULATED_PRISM_HEADER = 119
ENCAPSULATED_PROTOCOLS = {1: 'ETHERNET', 18: 'IEEE 802.11', 119: 'PRISM HEADER', 127: 'WLAN AVS'}
ENCAPSULATED_PROTOCOL_CLASSES = {1: <class 'scapy.layers.l2.Ether'>, 18: <class 'scapy.layers.dot11.Dot11'>, 119: <class 'scapy.layers.dot11.PrismHeader'>, 127: <class 'scapy.contrib.avs.AVSWLANHeader'>}
ENCAPSULATED_WLAN_AVS = 127
TYPES = {0: 'RX_PACKET', 1: 'TX_PACKET', 3: 'CONFIG', 4: 'KEEPALIVE/NULL', 5: 'PORT'}
TYPE_CONFIG = 3
TYPE_KEEPALIVE = 4
TYPE_NULL = 4
TYPE_PORT = 5
TYPE_RX_PACKET = 0
TYPE_TX_PACKET = 1
aliastypes
fields_desc
TZSP fields

version

ByteField

1

type

ByteEnumField

0

encapsulated_protocol

ShortEnumField

1

get_encapsulated_payload()
get_encapsulated_payload_class()

get the class that holds the encapsulated payload of the TZSP packet :return: class representing the payload, Raw() on error

guess_payload_class(payload)
exception scapy.contrib.tzsp.TZSPStructureException

Bases: scapy.error.Scapy_Exception

class scapy.contrib.tzsp.TZSPTagContentionFree

Bases: scapy.contrib.tzsp._TZSPTag

packet received in contention free period

NO = 0
YES = 1
aliastypes
fields_desc
TZSPTagContentionFree fields

type

ByteEnumField

15

len

ByteField

1

contention_free

YesNoByteField

0

class scapy.contrib.tzsp.TZSPTagDataRate

Bases: scapy.contrib.tzsp._TZSPTag

wireless link data rate

DATA_RATES = {0: 'unknown', 2: '1 MB/s', 4: '2 MB/s', 10: '1 MB/s (legacy)', 11: '5.5 MB/s', 12: '6 MB/s', 18: '9 MB/s', 20: '2 MB/s (legacy)', 22: '11 MB/s', 24: '12 MB/s', 36: '18 MB/s', 44: '22 MB/s', 48: '24 MB/s', 55: '5.5 MB/s (legacy)', 66: '33 MB/s', 72: '36 MB/s', 96: '48 MB/s', 108: '54 MB/s', 110: '11 MB/s (legacy)'}
DATA_RATE_1 = 2
DATA_RATE_11 = 22
DATA_RATE_12 = 24
DATA_RATE_18 = 36
DATA_RATE_2 = 4
DATA_RATE_22 = 44
DATA_RATE_24 = 48
DATA_RATE_33 = 66
DATA_RATE_36 = 72
DATA_RATE_48 = 96
DATA_RATE_54 = 108
DATA_RATE_5_5 = 11
DATA_RATE_6 = 12
DATA_RATE_9 = 18
DATA_RATE_LEGACY_1 = 10
DATA_RATE_LEGACY_11 = 110
DATA_RATE_LEGACY_2 = 20
DATA_RATE_LEGACY_5_5 = 55
DATA_RATE_UNKNOWN = 0
aliastypes
fields_desc
TZSPTagDataRate fields

type

ByteEnumField

12

len

ByteField

1

data_rate

ByteEnumField

0

class scapy.contrib.tzsp.TZSPTagDecrypted

Bases: scapy.contrib.tzsp._TZSPTag

packet was decrypted

NO = 1
YES = 0
aliastypes
fields_desc
TZSPTagDecrypted fields

type

ByteEnumField

16

len

ByteField

1

decrypted

YesNoByteField

1

class scapy.contrib.tzsp.TZSPTagEnd

Bases: scapy.packet.Packet

last tag

aliastypes
fields_desc
TZSPTagEnd fields

type

ByteEnumField

1

guess_payload_class(payload)

the type of the payload encapsulation is given be the outer TZSP layers attribute encapsulation_protocol # noqa: E501

class scapy.contrib.tzsp.TZSPTagError

Bases: scapy.contrib.tzsp._TZSPTag

frame checksum error

NO = 0
YES = 1
aliastypes
fields_desc
TZSPTagError fields

type

ByteEnumField

17

len

ByteField

1

fcs_error

YesNoByteField

0

class scapy.contrib.tzsp.TZSPTagPacketCount

Bases: scapy.contrib.tzsp._TZSPTag

packet counter

aliastypes
fields_desc
TZSPTagPacketCount fields

type

ByteEnumField

40

len

ByteField

4

packet_count

IntField

0

class scapy.contrib.tzsp.TZSPTagPadding

Bases: scapy.contrib.tzsp._TZSPTag

padding tag (should be ignored)

aliastypes
fields_desc
TZSPTagPadding fields

type

ByteEnumField

0

class scapy.contrib.tzsp.TZSPTagRXChannel

Bases: scapy.contrib.tzsp._TZSPTag

channel the sensor was on while receiving the frame

aliastypes
fields_desc
TZSPTagRXChannel fields

type

ByteEnumField

18

len

ByteField

1

rx_channel

ByteField

0

class scapy.contrib.tzsp.TZSPTagRXFrameLength

Bases: scapy.contrib.tzsp._TZSPTag

received packet length

aliastypes
fields_desc
TZSPTagRXFrameLength fields

type

ByteEnumField

41

len

ByteField

2

rx_frame_length

ShortField

0

class scapy.contrib.tzsp.TZSPTagRawRSSIByte

Bases: scapy.contrib.tzsp._TZSPTag

relative received signal strength - signed byte value

aliastypes
fields_desc
TZSPTagRawRSSIByte fields

type

ByteEnumField

10

len

ByteField

1

raw_rssi

ByteField

0

class scapy.contrib.tzsp.TZSPTagRawRSSIShort

Bases: scapy.contrib.tzsp._TZSPTag

relative received signal strength - signed short value

aliastypes
fields_desc
TZSPTagRawRSSIShort fields

type

ByteEnumField

10

len

ByteField

2

raw_rssi

ShortField

0

class scapy.contrib.tzsp.TZSPTagSNRByte

Bases: scapy.contrib.tzsp._TZSPTag

signal noise ratio - signed byte value

aliastypes
fields_desc
TZSPTagSNRByte fields

type

ByteEnumField

11

len

ByteField

1

snr

ByteField

0

class scapy.contrib.tzsp.TZSPTagSNRShort

Bases: scapy.contrib.tzsp._TZSPTag

signal noise ratio - signed short value

aliastypes
fields_desc
TZSPTagSNRShort fields

type

ByteEnumField

11

len

ByteField

2

snr

ShortField

0

class scapy.contrib.tzsp.TZSPTagTimestamp

Bases: scapy.contrib.tzsp._TZSPTag

MAC receive timestamp

aliastypes
fields_desc
TZSPTagTimestamp fields

type

ByteEnumField

13

len

ByteField

4

timestamp

IntField

0

class scapy.contrib.tzsp.TZSPTagUnknown

Bases: scapy.contrib.tzsp._TZSPTag

unknown tag type dummy

aliastypes
fields_desc
TZSPTagUnknown fields

type

ByteField

255

len

FieldLenField

None

data

XStrLenField

b''

class scapy.contrib.tzsp.TZSPTagWlanRadioHdrSerial

Bases: scapy.contrib.tzsp._TZSPTag

(vendor specific) unique capture device (sensor/AP) identifier

aliastypes
fields_desc
TZSPTagWlanRadioHdrSerial fields

type

ByteEnumField

60

len

FieldLenField

None

sensor_id

StrLenField

b''