scapy.contrib.stun

STUN (RFC 8489)

TLV code derived from the DTP implementation:
Thanks to Nicolas Bareil,

Arnaud Ebalard, Jochen Bartl.

class scapy.contrib.stun.STUN(_pkt, /, *, RESERVED=0, stun_message_type=None, length=None, magic_cookie=554869826, transaction_id=None, attributes=[])[源代码]

基类:Packet

aliastypes
description = ''
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|RES|     STUN MESSAGE TYPE     |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          MAGIC COOKIE                         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         TRANSACTION ID                        |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           ATTRIBUTES          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                            Fig. STUN                             
STUN fields

RESERVED

BitField (2 bits)

0

stun_message_type

BitEnumField

None

length

LenField

None

magic_cookie

XIntField

554869826

transaction_id

XBitField (96 bits)

None

attributes

PacketListField

[]

post_build(pkt, pay)[源代码]
class scapy.contrib.stun.STUNFingerprint(_pkt, /, *, type=32808, length=4, crc_32=None)[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             CRC 32                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. STUNFingerprint                       
STUNFingerprint fields

type

XShortField

32808

length

ShortField

4

crc_32

XIntField

None

class scapy.contrib.stun.STUNGenericTlv(_pkt, /, *, type=0, length=None, value=b'')[源代码]

基类:Packet

aliastypes
classmethod dispatch_hook(_pkt=None, *args, **kwargs)[源代码]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             VALUE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. STUNGenericTlv                        
STUNGenericTlv fields

type

XShortField

0

length

FieldLenField

None

value

PadField

b''

guess_payload_class(payload)[源代码]
class scapy.contrib.stun.STUNGoogNetworkInfo(_pkt, /, *, type=49239, length=4, network_id=0, network_cost=999)[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           NETWORK ID          |          NETWORK COST         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. STUNGoogNetworkInfo                     
STUNGoogNetworkInfo fields

type

XShortField

49239

length

ShortField

4

network_id

ShortField

0

network_cost

ShortField

999

class scapy.contrib.stun.STUNIceControlling(_pkt, /, *, type=32810, length=8, tie_breaker=None)[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          TIE BREAKER                          |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Fig. STUNIceControlling                      
STUNIceControlling fields

type

XShortField

32810

length

ShortField

8

tie_breaker

XLongField

None

class scapy.contrib.stun.STUNMessageIntegrity(_pkt, /, *, type=8, length=20, hmac_sha1=0)[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           HMAC SHA1                           |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. STUNMessageIntegrity                     
STUNMessageIntegrity fields

type

XShortField

8

length

ShortField

20

hmac_sha1

XNBytesField

0

post_build(pkt, pay)[源代码]
class scapy.contrib.stun.STUNPriority(_pkt, /, *, type=36, length=4, priority=0)[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            PRIORITY                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. STUNPriority                         
STUNPriority fields

type

XShortField

36

length

ShortField

4

priority

IntField

0

class scapy.contrib.stun.STUNUseCandidate(_pkt, /, *, type=37, length=0, value=b'')[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             VALUE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. STUNUseCandidate                       
STUNUseCandidate fields

type

XShortField

37

length

FieldLenField

0

value

PadField

b''

class scapy.contrib.stun.STUNUsername(_pkt, /, *, type=6, length=None, username=b'')[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            USERNAME           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. STUNUsername                         
STUNUsername fields

type

XShortField

6

length

FieldLenField

None

username

PadField

b''

class scapy.contrib.stun.STUNXorMappedAddress(_pkt, /, *, type=32, length=8, RESERVED=0, address_family=1, xport=0, xip=0)[源代码]

基类:STUNGenericTlv

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              TYPE             |             LENGTH            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    RESERVED   | ADDRESS FAMILY|             XPORT             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              XIP                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Fig. STUNXorMappedAddress                     
STUNXorMappedAddress fields

type

XShortField

32

length

ShortField

8

RESERVED

ByteField

0

address_family

ByteEnumField

1

xport

XorPort

0

xip

XorIp

0

class scapy.contrib.stun.XorIp(name: str, default: str | None)[源代码]

基类:IPField

i2m(pkt, x)[源代码]
m2i(pkt, x)[源代码]
class scapy.contrib.stun.XorPort(name: str, default: int | None)[源代码]

基类:ShortField

i2m(pkt, x)[源代码]
m2i(pkt, x)[源代码]