scapy.contrib.http2
http2
HTTP/2 support for Scapy see RFC7540 and RFC7541 for more information
Implements packets and fields required to encode/decode HTTP/2 Frames and HPack encoded headers
- class scapy.contrib.http2.AbstractUVarIntField(name: str, default: int | None, size: int)[source]
Bases:
Field
AbstractUVarIntField represents an integer as defined in RFC7541
- addfield(pkt: Packet | None, s: str | Tuple[str, int, int], val: int) str [source]
An AbstractUVarIntField prefix always consumes the remaining bits of a BitField;if no current BitField is in use (no tuple in entry) then the prefix length is 8 bits and the whole byte is to be consumed
- Parameters:
pkt (packet.Packet|None) – the packet containing this field. Probably unused.
s (str|(str, int, long)) – the string to append this field to. A tuple indicates that some bits were already generated by another bitfield-compatible field. This MUST be the case if “size” is not 8. The int is the number of bits already generated in the first byte of the str. The long is the value that was generated by the previous bitfield-compatible fields.
val (int) – the positive or null value to be added.
- Returns:
str: s concatenated with the machine representation of this field.
- Raises:
AssertionError
- any2i(pkt: Packet | None, x: None | str | int) int | None [source]
A “x” value as a string is parsed as a binary encoding of a UVarInt. An int is considered an internal value. # noqa: E501 None is returned as is.
- Parameters:
pkt (packet.Packet|None) – the packet containing this field; probably unused. # noqa: E501
x (str|int|None) – the value to convert.
- Returns:
int|None: the converted value.
- Raises:
AssertionError
- getfield(pkt: Packet | None, s: str | Tuple[str, int]) Tuple[str, int] [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field; probably unused.
s (str|(str, int)) – the input value to get this field value from. If size is 8, s is a string, else it is a tuple containing the value and an int indicating the number of bits already consumed in the first byte of the str. The number of remaining bits to consume in the first byte must be equal to “size”.
- Returns:
(str, int): the remaining bytes of s and the parsed value.
- Raises:
AssertionError
- h2i(pkt: Packet | None, x: int | None) int | None [source]
- Parameters:
pkt (packet.Packet|None) – unused.
x (int|None) – the value to convert.
- Returns:
int|None: the converted value.
- Raises:
AssertionError
- i2h(pkt: Packet | None, x: int | None) int | None [source]
- Parameters:
pkt (packet.Packet|None) – unused.
x (int|None) – the value to convert.
- Return::
int|None: the converted value.
- i2len(pkt: Packet | None, x: int) int [source]
- Parameters:
pkt (packet.Packet|None) – unused.
x (int) – the positive or null value whose binary size if requested. # noqa: E501
- Raises:
AssertionError
- i2m(pkt: Packet | None, x: int) str [source]
- Parameters:
pkt (packet.Packet|None) – unused.
x (int) – the value to convert.
- Returns:
str: the converted value.
- Raises:
AssertionError
- i2repr(pkt: Packet | None, x: int | None) str [source]
- Parameters:
pkt (packet.Packet|None) – probably unused.
x – int|None: the positive, null or none value to convert.
- Returns:
str: the representation of the value.
- m2i(pkt: Packet | None, x: str | Tuple[str, int]) int [source]
A tuple is expected for the “x” param only if “size” is different than 8. If a tuple is received, some bits # noqa: E501 were consumed by another field. This field consumes the remaining bits, therefore the int of the tuple must # noqa: E501 equal “size”.
- Parameters:
pkt (packet.Packet|None) – unused.
x (str|(str, int)) – the string to convert. If bits were consumed by a previous bitfield-compatible field. # noqa: E501
- Raises:
AssertionError
- randval() VolatileValue [source]
- Returns:
volatile.VolatileValue: a volatile value for this field “long”-compatible internal value. # noqa: E501
- rev
- size
- class scapy.contrib.http2.EOS[source]
Bases:
object
Simple “marker” to designate the End Of String symbol in the huffman table
- class scapy.contrib.http2.FieldUVarLenField(name: str, default: int | None, size: int, length_of: str, adjust: ~typing.Callable[[int], int] = <function FieldUVarLenField.<lambda>>)[source]
Bases:
AbstractUVarIntField
- addfield(pkt: Packet | None, s: str | Tuple[str, int, int], val: int | None) str [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance. This parameter must not be # noqa: E501 None if the val parameter is.
s (str|(str, int, long)) – the string to append this field to. A tuple indicates that some bits were already # noqa: E501 generated by another bitfield-compatible field. This MUST be the case if “size” is not 8. The int is the # noqa: E501 number of bits already generated in the first byte of the str. The long is the value that was generated by the # noqa: E501 previous bitfield-compatible fields.
val (int|None) – the positive or null value to be added. If None, the value is computed from pkt. # noqa: E501
- Returns:
str: s concatenated with the machine representation of this field. # noqa: E501
- Raises:
AssertionError
- i2m(pkt: Packet | None, x: int | None) str [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance. This parameter must not be # noqa: E501 None if the x parameter is.
x (int|None) – the positive or null value to be added. If None, the value is computed from pkt. # noqa: E501
- Returns:
str
- Raises:
AssertionError
- class scapy.contrib.http2.H2AbstractHeadersFrame(_pkt, /)[source]
Bases:
H2FramePayload
Superclass of all variants of HTTP/2 Header Frame Packets. May be used for type checking.
- aliastypes
- class scapy.contrib.http2.H2ContinuationFrame(_pkt, /, *, hdrs=[])[source]
Bases:
H2FramePayload
H2ContinuationFrame implements the RFC 7540 par6.10
- END_HEADERS_FLAG = 2
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HDRS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2ContinuationFrame
H2ContinuationFrame fields hdrs
[]
- flags = {2: ('EH', 'End Headers')}
- type_id = 9
- class scapy.contrib.http2.H2DataFrame(_pkt, /, *, data=b'')[source]
Bases:
H2FramePayload
H2DataFrame implements RFC7540 par6.1 This packet is the Data Frame to use when there is no padding.
- END_STREAM_FLAG = 0
- PADDED_FLAG = 3
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2DataFrame
H2DataFrame fields data
b''
- flags = {0: ('ES', 'End Stream'), 3: ('P', 'Padded')}
- type_id = 0
- class scapy.contrib.http2.H2ErrorCodes[source]
Bases:
object
H2ErrorCodes is an enumeration of the error codes defined in RFC7540 par7. This enumeration is not part of any frame because the error codes are in common with H2ResetFrame and H2GoAwayFrame.
- CANCEL = 8
- COMPRESSION_ERROR = 9
- CONNECT_ERROR = 10
- ENHANCE_YOUR_CALM = 11
- FLOW_CONTROL_ERROR = 3
- FRAME_SIZE_ERROR = 6
- HTTP_1_1_REQUIRED = 13
- INADEQUATE_SECURITY = 12
- INTERNAL_ERROR = 2
- NO_ERROR = 0
- PROTOCOL_ERROR = 1
- REFUSED_STREAM = 7
- SETTINGS_TIMEOUT = 4
- STREAM_CLOSED = 5
- literal = {0: 'No error', 1: 'Protocol error', 2: 'Internal error', 3: 'Flow control error', 4: 'Settings timeout', 5: 'Stream closed', 6: 'Frame size error', 7: 'Refused stream', 8: 'Cancel', 9: 'Compression error', 10: 'Control error', 11: 'Enhance your calm', 12: 'Inadequate security', 13: 'HTTP/1.1 required'}
- class scapy.contrib.http2.H2Frame(_pkt, /, *, len=None, type=None, flags={}, reserved=0, stream_id=0)[source]
Bases:
Packet
H2Frame implements the frame structure as defined in RFC 7540 par4.1
This packet may have a payload (one of the H2FramePayload) or none, in some rare cases such as settings acknowledgement)
- aliastypes
- extract_padding(s: str) Tuple[str, str] [source]
- Parameters:
s (str) – the string from which to tell the padding and the payload data apart # noqa: E501
- Returns:
(str, str): the padding and the payload data strings
- Raises:
AssertionError
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TYPE | FLAGS |R| STREAM ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2Frame
H2Frame fields len
None
type
None
flags
set()
reserved
BitField
(1 bit)0
stream_id
BitField
(31 bits)0
- guess_payload_class(payload: str) Packet_metaclass [source]
guess_payload_class returns the Class object to use for parsing a payload This function uses the H2Frame.type field value to decide which payload to parse. The implement cannot be # noqa: E501 performed using the simple bind_layers helper because sometimes the selection of which Class object to return # noqa: E501 also depends on the H2Frame.flags value.
- Parameters:
payload
- Return::
- payload_guess
Possible sublayers:
H2ContinuationFrame
,H2DataFrame
,H2GoAwayFrame
,H2HeadersFrame
,H2PaddedDataFrame
,H2PaddedHeadersFrame
,H2PaddedPriorityHeadersFrame
,H2PaddedPushPromiseFrame
,H2PingFrame
,H2PriorityFrame
,H2PriorityHeadersFrame
,H2PushPromiseFrame
,H2ResetFrame
,H2SettingsFrame
,H2WindowUpdateFrame
- class scapy.contrib.http2.H2FramePayload(_pkt, /)[source]
Bases:
Packet
H2FramePayload is an empty class that is a super class of all Scapy HTTP/2 Frame Packets
- aliastypes
- class scapy.contrib.http2.H2GoAwayFrame(_pkt, /, *, reserved=0, last_stream_id=0, error=0, additional_data=b'')[source]
Bases:
H2FramePayload
H2GoAwayFrame implements the RFC 7540 par6.8
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R| LAST STREAM ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ERROR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ADDITIONAL DATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2GoAwayFrame
H2GoAwayFrame fields reserved
BitField
(1 bit)0
last_stream_id
BitField
(31 bits)0
error
0
additional_data
b''
- type_id = 7
- class scapy.contrib.http2.H2HeadersFrame(_pkt, /, *, hdrs=[])[source]
Bases:
H2AbstractHeadersFrame
H2HeadersFrame implements RFC 7540 par6.2 Headers Frame when there is no padding and no priority information
The choice of decomposing into four classes is probably preferable to having # noqa: E501 numerous conditional fields based on the underlayer :/
- END_HEADERS_FLAG = 2
- END_STREAM_FLAG = 0
- PADDED_FLAG = 3
- PRIORITY_FLAG = 5
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HDRS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2HeadersFrame
H2HeadersFrame fields hdrs
[]
- flags = {0: ('ES', 'End Stream'), 2: ('EH', 'End Headers'), 3: ('P', 'Padded'), 5: ('+', 'Priority')}
- type_id = 1
- class scapy.contrib.http2.H2PaddedDataFrame(_pkt, /, *, padlen=None, data=b'', padding=b'')[source]
Bases:
H2DataFrame
H2DataFrame implements RFC7540 par6.1 This packet is the Data Frame to use when there is padding.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PADLEN | DATA | PADDING | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. H2PaddedDataFrame
H2PaddedDataFrame fields padlen
None
data
b''
padding
b''
- get_data_len() int [source]
get_data_len computes the length of the data field
To do this computation, the length of the padlen field and the actual padding is subtracted to the string that was provided to the pre_dissect # noqa: E501 fun of the pkt parameter :return: int; length of the data part of the HTTP/2 frame packet provided as parameter # noqa: E501 :raises: AssertionError
- pre_dissect(s: str) str [source]
pre_dissect is filling the s_len property of this instance. This property is later used during the getfield call of the “data” field when # noqa: E501 trying to evaluate the length of the StrLenField! This “trick” works because the underlayer packet (H2Frame) is assumed to override the “extract_padding” method and to only provide to this packet the data necessary for this packet. Tricky, tricky, will break some day probably! # noqa: E501
- s_len
- class scapy.contrib.http2.H2PaddedHeadersFrame(_pkt, /, *, padlen=None, hdrs=[], padding=b'')[source]
Bases:
H2AbstractHeadersFrame
H2PaddedHeadersFrame is the variant of H2HeadersFrame where padding flag is set and priority flag is cleared
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PADLEN | HDRS | PADDING | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. H2PaddedHeadersFrame
H2PaddedHeadersFrame fields padlen
None
hdrs
[]
padding
b''
- get_hdrs_len() int [source]
get_hdrs_len computes the length of the hdrs field
To do this computation, the length of the padlen field and the actual padding is subtracted to the string that was provided to the pre_dissect # noqa: E501 fun of the pkt parameter. :return: int; length of the data part of the HTTP/2 frame packet provided as parameter # noqa: E501 :raises: AssertionError
- pre_dissect(s: str) str [source]
pre_dissect is filling the s_len property of this instance. This property is later used during the parsing of the hdrs PacketListField when trying to evaluate the length of the PacketListField! This “trick” works because the underlayer packet (H2Frame) is assumed to override the # noqa: E501 “extract_padding” method and to only provide to this packet the data necessary for this packet. Tricky, tricky, will break some day probably! # noqa: E501
- s_len
- class scapy.contrib.http2.H2PaddedPriorityHeadersFrame(_pkt, /, *, padlen=None, exclusive=0, stream_dependency=0, weight=0, hdrs=[], padding=b'')[source]
Bases:
H2AbstractHeadersFrame
H2PaddedPriorityHeadersFrame is the variant of H2HeadersFrame where both priority and padding flags are set
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PADLEN |E| STREAM DEPENDENCY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | WEIGHT | HDRS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PADDING | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2PaddedPriorityHeadersFrame
H2PaddedPriorityHeadersFrame fields padlen
None
exclusive
BitField
(1 bit)0
stream_dependency
BitField
(31 bits)0
weight
0
hdrs
[]
padding
b''
- get_hdrs_len() int [source]
get_hdrs_len computes the length of the hdrs field
To do this computation, the length of the padlen field, the priority information fields and the actual padding is subtracted to the string that was provided to the pre_dissect fun of the pkt parameter. :return: int: the length of the hdrs field :raises: AssertionError
- pre_dissect(s: str) str [source]
pre_dissect is filling the s_len property of this instance. This property is later used during the parsing of the hdrs PacketListField when trying to evaluate the length of the PacketListField! This “trick” works because the underlayer packet (H2Frame) is assumed to override the # noqa: E501 “extract_padding” method and to only provide to this packet the data necessary for this packet. Tricky, tricky, will break some day probably! # noqa: E501
- s_len
- class scapy.contrib.http2.H2PaddedPushPromiseFrame(_pkt, /, *, padlen=None, reserved=0, stream_id=0, hdrs=[], padding=b'')[source]
Bases:
H2PushPromiseFrame
H2PaddedPushPromiseFrame implements RFC7540 par6.6. This packet is the variant to use when the underlayer padding flag is set
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PADLEN |R| STREAM ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | HDRS | PADDING | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+ Fig. H2PaddedPushPromiseFrame
H2PaddedPushPromiseFrame fields padlen
None
reserved
BitField
(1 bit)0
stream_id
BitField
(31 bits)0
hdrs
[]
padding
b''
- get_hdrs_len() int [source]
get_hdrs_len computes the length of the hdrs field
To do this computation, the length of the padlen field, reserved, stream_id and the actual padding is subtracted to the string that was provided to the pre_dissect fun of the pkt parameter. :return: int: the length of the hdrs field :raises: AssertionError
- pre_dissect(s: str) str [source]
pre_dissect is filling the s_len property of this instance. This property is later used during the parsing of the hdrs PacketListField when trying to evaluate the length of the PacketListField! This “trick” works because the underlayer packet (H2Frame) is assumed to override the # noqa: E501 “extract_padding” method and to only provide to this packet the data necessary for this packet. Tricky, tricky, will break some day probably! # noqa: E501
- s_len
- class scapy.contrib.http2.H2PingFrame(_pkt, /, *, opaque=0)[source]
Bases:
H2FramePayload
H2PingFrame implements the RFC 7540 par6.7
- ACK_FLAG = 0
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OPAQUE | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2PingFrame
H2PingFrame fields opaque
0
- flags = {0: ('A', 'ACK')}
- type_id = 6
- class scapy.contrib.http2.H2PriorityFrame(_pkt, /, *, exclusive=0, stream_dependency=0, weight=0)[source]
Bases:
H2FramePayload
H2PriorityFrame implements RFC 7540 par6.3
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |E| STREAM DEPENDENCY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | WEIGHT | +-+-+-+-+-+-+-+-+ Fig. H2PriorityFrame
H2PriorityFrame fields exclusive
BitField
(1 bit)0
stream_dependency
BitField
(31 bits)0
weight
0
- type_id = 2
- class scapy.contrib.http2.H2PriorityHeadersFrame(_pkt, /, *, exclusive=0, stream_dependency=0, weight=0, hdrs=[])[source]
Bases:
H2AbstractHeadersFrame
H2PriorityHeadersFrame is the variant of H2HeadersFrame where priority flag is set and padding flag is cleared
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |E| STREAM DEPENDENCY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | WEIGHT | HDRS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2PriorityHeadersFrame
H2PriorityHeadersFrame fields exclusive
BitField
(1 bit)0
stream_dependency
BitField
(31 bits)0
weight
0
hdrs
[]
- s_len
- class scapy.contrib.http2.H2PushPromiseFrame(_pkt, /, *, reserved=0, stream_id=0, hdrs=[])[source]
Bases:
H2FramePayload
H2PushPromiseFrame implements RFC7540 par6.6. This packet is the variant to use when the underlayer padding flag is cleared
- END_HEADERS_FLAG = 2
- PADDED_FLAG = 3
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R| STREAM ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HDRS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2PushPromiseFrame
H2PushPromiseFrame fields reserved
BitField
(1 bit)0
stream_id
BitField
(31 bits)0
hdrs
[]
- flags = {2: ('EH', 'End Headers'), 3: ('P', 'Padded')}
- type_id = 5
- class scapy.contrib.http2.H2ResetFrame(_pkt, /, *, error=0)[source]
Bases:
H2FramePayload
H2ResetFrame implements RFC 7540 par6.4
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ERROR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2ResetFrame
H2ResetFrame fields error
0
- type_id = 3
- class scapy.contrib.http2.H2Seq(_pkt, /, *, frames=[])[source]
Bases:
Packet
H2Seq is a helper packet that contains several H2Frames and their payload. This packet can be used, for instance, while reading manually from a TCP socket.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | FRAMES | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2Seq
H2Seq fields frames
[]
- guess_payload_class(payload: str) Packet_metaclass [source]
- class scapy.contrib.http2.H2Setting(_pkt, /, *, id=0, value=0)[source]
Bases:
Packet
H2Setting implements a setting, as defined in RFC7540 par6.5.1
- SETTINGS_ENABLE_PUSH = 2
- SETTINGS_HEADER_TABLE_SIZE = 1
- SETTINGS_INITIAL_WINDOW_SIZE = 4
- SETTINGS_MAX_CONCURRENT_STREAMS = 3
- SETTINGS_MAX_FRAME_SIZE = 5
- SETTINGS_MAX_HEADER_LIST_SIZE = 6
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ID | VALUE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2Setting
H2Setting fields id
0
value
0
- guess_payload_class(payload: str) Packet_metaclass [source]
- class scapy.contrib.http2.H2SettingsFrame(_pkt, /, *, settings=[])[source]
Bases:
H2FramePayload
H2SettingsFrame implements RFC7540 par6.5
- ACK_FLAG = 0
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SETTINGS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2SettingsFrame
H2SettingsFrame fields settings
[]
- flags = {0: ('A', 'ACK')}
- type_id = 4
- class scapy.contrib.http2.H2WindowUpdateFrame(_pkt, /, *, reserved=0, win_size_incr=0)[source]
Bases:
H2FramePayload
H2WindowUpdateFrame implements the RFC 7540 par6.9
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R| WIN SIZE INCR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. H2WindowUpdateFrame
H2WindowUpdateFrame fields reserved
BitField
(1 bit)0
win_size_incr
BitField
(31 bits)0
- type_id = 8
- class scapy.contrib.http2.HPackDynamicSizeUpdate(_pkt, /, *, magic=1, max_size=0)[source]
Bases:
HPackHeaders
HPackDynamicSizeUpdate implements RFC 7541 par6.3
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |MAGIC| MAX SIZE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. HPackDynamicSizeUpdate
HPackDynamicSizeUpdate fields magic
HPackMagicBitField
(3 bits)1
max_size
0
- class scapy.contrib.http2.HPackHdrEntry(name: str, value: str)[source]
Bases:
Sized
HPackHdrEntry is an entry of the HPackHdrTable helper
Each HPackHdrEntry instance is a header line (name and value). Names are normalized (lowercase), according to RFC 7540 par8.1.2
- class scapy.contrib.http2.HPackHdrString(_pkt, /, *, type=None, len=None, data=<scapy.contrib.http2.HPackLiteralString object>)[source]
Bases:
Packet
HPackHdrString is a packet that that is serialized into a RFC7541 par5.2 string literal repr.
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |T| LEN | DATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+ Fig. HPackHdrString
HPackHdrString fields type
None
len
None
data
<scapy.contrib.http2.HPackLiteralString object at 0x7f003f7647d0>
- guess_payload_class(payload: str) Packet_metaclass [source]
- class scapy.contrib.http2.HPackHdrTable(dynamic_table_max_size: int = 4096, dynamic_table_cap_size: int = 4096)[source]
Bases:
Sized
HPackHdrTable is a helper class that implements some of the logic associated with indexing of headers (read and write operations in this “registry”. THe HPackHdrTable also implements convenience functions to easily # noqa: E501 convert to and from textual representation and binary representation of a HTTP/2 requests
- gen_txt_repr(hdrs: H2Frame | List[HPackHeaders], register: bool | None = True) str [source]
gen_txt_repr returns a “textual” representation of the provided headers. The output of this function is compatible with the input of parse_txt_hdrs.
- Parameters:
hdrs (H2Frame|list of HPackHeaders) – the list of headers to convert to textual representation.
bool – whether incremental headers should be added to the dynamic table as we generate the text representation
- Returns:
str: the textual representation of the provided headers
- Raises:
AssertionError
- get_idx_by_name(name: str) int | None [source]
get_idx_by_name returns the index of a matching registered header
This implementation will prefer returning a static entry index whenever possible. If multiple matching header name are found in the static table, there is insurance that the first entry (lowest index number) will be returned. If no matching header is found, this method returns None.
- get_idx_by_name_and_value(name: str, value: str) int | None [source]
get_idx_by_name_and_value returns the index of a matching registered header
This implementation will prefer returning a static entry index whenever possible. If multiple matching headers are found in the dynamic table, the lowest index is returned If no matching header is found, this method returns None.
- parse_txt_hdrs(s: bytes | str, stream_id: int = 1, body: str | None = None, max_frm_sz: int = 4096, max_hdr_lst_sz: int = 0, is_sensitive: ~typing.Callable[[str, str], bool] = <function HPackHdrTable.<lambda>>, should_index: ~typing.Callable[[str], bool] = <function HPackHdrTable.<lambda>>, register: bool = True) H2Seq [source]
parse_txt_hdrs parses headers expressed in text and converts them into a series of H2Frames with the “correct” flags. A body can be provided in which case, the data frames are added, bearing the End Stream flag, instead of the H2HeadersFrame/H2ContinuationFrame. The generated frames may respect max_frm_sz (SETTINGS_MAX_FRAME_SIZE) and max_hdr_lst_sz (SETTINGS_MAX_HEADER_LIST_SIZE) if provided. The headers are split into multiple headers fragment (and H2Frames) to respect these limits. Also, a callback can be provided to tell if a header should be never indexed (sensitive headers, such as cookies), and another callback say if the header should be registered into the index table at all. For an header to be registered, the is_sensitive callback must return False AND the should_index callback should return True. This is the default behavior.
- Parameters:
s (str) – the string to parse for headers
stream_id (int) – the stream id to use in the generated H2Frames
body (str/None) – the eventual body of the request, that is added to the generated frames
max_frm_sz (int) – the maximum frame size. This is used to split the headers and data frames according to the maximum frame size negotiated for this connection.
max_hdr_lst_sz (int) – the maximum size of a “header fragment” as defined in RFC7540
is_sensitive (callable) – callback that returns True if the provided header is sensible and must be stored in a header packet requesting this header never to be indexed
should_index (callable) – callback that returns True if the provided header should be stored in a header packet requesting indexation in the dynamic header table.
register (bool) – whether to register new headers with incremental indexing as we parse them
- Raises:
Exception
- recap(nc: int) None [source]
recap changes the maximum size limit of the dynamic table. It also proceeds to a resize(), if the new size is lower than the previous one. :param int nc: the new cap of the dynamic table (that is the maximum-maximum size) # noqa: E501 :raises: AssertionError
- register(hdrs: HPackLitHdrFldWithIncrIndexing | H2Frame | List[HPackHeaders]) None [source]
register adds to this table the instances of HPackLitHdrFldWithIncrIndexing provided as parameters.
A H2Frame with a H2HeadersFrame payload can be provided, as much as a python list of HPackHeaders or a single HPackLitHdrFldWithIncrIndexing instance. :param HPackLitHdrFldWithIncrIndexing|H2Frame|list of HPackHeaders hdrs: the header(s) to register # noqa: E501 :raises: AssertionError
- class scapy.contrib.http2.HPackHeaders(_pkt, /)[source]
Bases:
Packet
HPackHeaders uses the “dispatch_hook” trick of Packet_metaclass to select the correct HPack header packet type. For this, the first byte of the string # noqa: E501 to dissect is snooped on.
- aliastypes
- classmethod dispatch_hook(s: str | None = None, *_args: Any, **_kwds: Any) Packet_metaclass [source]
dispatch_hook returns the subclass of HPackHeaders that must be used to dissect the string.
- guess_payload_class(payload: str) Packet_metaclass [source]
- class scapy.contrib.http2.HPackIndexedHdr(_pkt, /, *, magic=1, index=2)[source]
Bases:
HPackHeaders
HPackIndexedHdr implements RFC 7541 par6.1
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |M| INDEX | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. HPackIndexedHdr
HPackIndexedHdr fields magic
HPackMagicBitField
(1 bit)1
index
2
- class scapy.contrib.http2.HPackLitHdrFldWithIncrIndexing(_pkt, /, *, magic=1, index=0, hdr_name=None, hdr_value=None)[source]
Bases:
HPackHeaders
HPackLitHdrFldWithIncrIndexing implements RFC 7541 par6.2.1
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |MAG| INDEX | HDR NAME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | HDR VALUE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. HPackLitHdrFldWithIncrIndexing
HPackLitHdrFldWithIncrIndexing fields magic
HPackMagicBitField
(2 bits)1
index
0
hdr_name
PacketField
(Cond)None
hdr_value
None
- class scapy.contrib.http2.HPackLitHdrFldWithoutIndexing(_pkt, /, *, magic=0, never_index=0, index=0, hdr_name=None, hdr_value=None)[source]
Bases:
HPackHeaders
HPackLitHdrFldWithIncrIndexing implements RFC 7541 par6.2.2 and par6.2.3
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |MAGIC|N| INDEX | HDR NAME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | HDR VALUE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. HPackLitHdrFldWithoutIndexing
HPackLitHdrFldWithoutIndexing fields magic
HPackMagicBitField
(3 bits)0
never_index
0
index
0
hdr_name
PacketField
(Cond)None
hdr_value
None
- class scapy.contrib.http2.HPackLiteralString(s: str)[source]
Bases:
HPackStringsInterface
HPackLiteralString is a string. This class is used as a marker and implements an interface in common with HPackZString
- class scapy.contrib.http2.HPackMagicBitField(name: str, default: int, size: int)[source]
Bases:
BitField
HPackMagicBitField is a BitField variant that cannot be assigned another value than the default one. This field must not be used where there is potential for fuzzing. OTOH, this field makes sense (for instance, if the magic bits are used by a dispatcher to select the payload class)
- addfield(pkt: Packet | None, s: str | Tuple[str, int, int], val: int) str | Tuple[str, int, int] [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused. # noqa: E501
s (str|(str, int, long)) – either a str if 0 == size%8 or a tuple with the string to add this field to, the # noqa: E501 number of bits already generated and the generated value so far.
val (int) – unused; must be equal to default value
- Returns:
str|(str, int, long): the s string extended with this field machine representation # noqa: E501
- Raises:
AssertionError
- any2i(pkt: Packet | None, x: int) int [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused # noqa: E501
x (int) – unused; must be equal to default value
- Returns:
int; default value
- Raises:
AssertionError
- getfield(pkt: Packet | None, s: str | Tuple[str, int]) Tuple[Tuple[str, int] | str, int] [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused. # noqa: E501
s (str|(str, int)) – either a str if size%8==0 or a tuple with the string to parse from and the number of # noqa: E501 bits already consumed by previous bitfield-compatible fields.
- Returns:
(str|(str, int), int): Returns the remaining string and the parsed value. May return a tuple if there # noqa: E501 are remaining bits to parse in the first byte. Returned value is equal to default value # noqa: E501
- Raises:
AssertionError
- h2i(pkt: Packet | None, x: int) int [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused # noqa: E501
x (int) – unused; must be equal to default value
- Returns:
int; default value
- Raises:
AssertionError
- i2h(pkt: Packet | None, x: int) int [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused # noqa: E501
x (int) – unused; must be equal to default value
- Returns:
int; default value
- Raises:
AssertionError
- i2m(pkt: Packet | None, x: int) int [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused # noqa: E501
x (int) – unused; must be equal to default value
- Returns:
int; default value
- Raises:
AssertionError
- m2i(pkt: Packet | None, x: int) int [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused # noqa: E501
x (int) – must be the machine representatino of the default value
- Returns:
int; default value
- Raises:
AssertionError
- class scapy.contrib.http2.HPackStrLenField(name: str, default: HPackStringsInterface, length_from: Callable[[Packet], int], type_from: str)[source]
Bases:
Field
HPackStrLenField is a StrLenField variant specialized for HTTP/2 HPack
This variant uses an internal representation that implements HPackStringsInterface. # noqa: E501
- addfield(pkt: Packet | None, s: str, val: HPackStringsInterface) str [source]
- any2i(pkt: Packet | None, x: str | HPackStringsInterface) HPackStringsInterface [source]
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance. # noqa: E501
x (str|HPackStringsInterface) – the value to convert
- Returns:
HPackStringsInterface: the Scapy internal value for this field
- Raises:
AssertionError, InvalidEncodingException
- getfield(pkt: Packet, s: str) Tuple[str, HPackStringsInterface] [source]
- Parameters:
pkt (packet.Packet) – the packet instance containing this field instance. # noqa: E501
s (str) – the string to parse this field from.
- Returns:
(str, HPackStringsInterface): the remaining string after this field was carved out & the extracted # noqa: E501 value.
- Raises:
KeyError if “type_from” is not a field of pkt or its payloads.
- Raises:
InvalidEncodingException
- h2i(pkt: Packet, x: str) HPackStringsInterface [source]
- i2h(pkt: Packet | None, x: HPackStringsInterface) str [source]
- i2len(pkt: Packet | None, x: HPackStringsInterface) int [source]
- i2m(pkt: Packet | None, x: HPackStringsInterface) str [source]
- i2repr(pkt: Packet | None, x: HPackStringsInterface) str [source]
- m2i(pkt: Packet, x: str) HPackStringsInterface [source]
- Parameters:
pkt (packet.Packet) – the packet instance containing this field instance. # noqa: E501
x (str) – the string to parse.
- Returns:
HPackStringsInterface: the internal type of the value parsed from x. # noqa: E501
- Raises:
AssertionError
- Raises:
InvalidEncodingException
- Raises:
KeyError if _type_from is not one of pkt fields.
- class scapy.contrib.http2.HPackZString(s: str)[source]
Bases:
HPackStringsInterface
- classmethod huffman_compute_decode_tree() None [source]
huffman_compute_decode_tree initializes/builds the static_huffman_tree
- Returns:
None
- Raises:
InvalidEncodingException if there is an encoding problem
- classmethod huffman_conv2bitstring(s: str) Tuple[int, int] [source]
huffman_conv2bitstring converts a string into its bitstring representation. It returns a tuple: the bitstring and its bitlength. This function DOES NOT compress/decompress the string!
- Parameters:
s (str) – the bytestring to convert.
- Returns:
(int, int): the bitstring of s, and its bitlength.
- Raises:
AssertionError
- classmethod huffman_conv2str(bit_str: int, bit_len: int) str [source]
huffman_conv2str converts a bitstring of bit_len bitlength into a binary string. It DOES NOT compress/decompress the bitstring!
- Parameters:
bit_str (int) – the bitstring to convert.
bit_len (int) – the bitlength of bit_str.
- Returns:
str: the converted bitstring as a bytestring.
- Raises:
AssertionError
- classmethod huffman_decode(i: int, ibl: int) str [source]
huffman_decode decodes the bitstring provided as parameters.
- Parameters:
i (int) – the bitstring to decode
ibl (int) – the bitlength of i
- Returns:
str: the string decoded from the bitstring
- Raises:
AssertionError, InvalidEncodingException
- classmethod huffman_encode(s: str) Tuple[int, int] [source]
huffman_encode returns the bitstring and the bitlength of the bitstring representing the string provided as a parameter
- Parameters:
s (str) – the string to encode
- Returns:
(int, int): the bitstring of s and its bitlength
- Raises:
AssertionError
- static_huffman_code = [(8184, 13), (8388568, 23), (268435426, 28), (268435427, 28), (268435428, 28), (268435429, 28), (268435430, 28), (268435431, 28), (268435432, 28), (16777194, 24), (1073741820, 30), (268435433, 28), (268435434, 28), (1073741821, 30), (268435435, 28), (268435436, 28), (268435437, 28), (268435438, 28), (268435439, 28), (268435440, 28), (268435441, 28), (268435442, 28), (1073741822, 30), (268435443, 28), (268435444, 28), (268435445, 28), (268435446, 28), (268435447, 28), (268435448, 28), (268435449, 28), (268435450, 28), (268435451, 28), (20, 6), (1016, 10), (1017, 10), (4090, 12), (8185, 13), (21, 6), (248, 8), (2042, 11), (1018, 10), (1019, 10), (249, 8), (2043, 11), (250, 8), (22, 6), (23, 6), (24, 6), (0, 5), (1, 5), (2, 5), (25, 6), (26, 6), (27, 6), (28, 6), (29, 6), (30, 6), (31, 6), (92, 7), (251, 8), (32764, 15), (32, 6), (4091, 12), (1020, 10), (8186, 13), (33, 6), (93, 7), (94, 7), (95, 7), (96, 7), (97, 7), (98, 7), (99, 7), (100, 7), (101, 7), (102, 7), (103, 7), (104, 7), (105, 7), (106, 7), (107, 7), (108, 7), (109, 7), (110, 7), (111, 7), (112, 7), (113, 7), (114, 7), (252, 8), (115, 7), (253, 8), (8187, 13), (524272, 19), (8188, 13), (16380, 14), (34, 6), (32765, 15), (3, 5), (35, 6), (4, 5), (36, 6), (5, 5), (37, 6), (38, 6), (39, 6), (6, 5), (116, 7), (117, 7), (40, 6), (41, 6), (42, 6), (7, 5), (43, 6), (118, 7), (44, 6), (8, 5), (9, 5), (45, 6), (119, 7), (120, 7), (121, 7), (122, 7), (123, 7), (32766, 15), (2044, 11), (16381, 14), (8189, 13), (268435452, 28), (1048550, 20), (4194258, 22), (1048551, 20), (1048552, 20), (4194259, 22), (4194260, 22), (4194261, 22), (8388569, 23), (4194262, 22), (8388570, 23), (8388571, 23), (8388572, 23), (8388573, 23), (8388574, 23), (16777195, 24), (8388575, 23), (16777196, 24), (16777197, 24), (4194263, 22), (8388576, 23), (16777198, 24), (8388577, 23), (8388578, 23), (8388579, 23), (8388580, 23), (2097116, 21), (4194264, 22), (8388581, 23), (4194265, 22), (8388582, 23), (8388583, 23), (16777199, 24), (4194266, 22), (2097117, 21), (1048553, 20), (4194267, 22), (4194268, 22), (8388584, 23), (8388585, 23), (2097118, 21), (8388586, 23), (4194269, 22), (4194270, 22), (16777200, 24), (2097119, 21), (4194271, 22), (8388587, 23), (8388588, 23), (2097120, 21), (2097121, 21), (4194272, 22), (2097122, 21), (8388589, 23), (4194273, 22), (8388590, 23), (8388591, 23), (1048554, 20), (4194274, 22), (4194275, 22), (4194276, 22), (8388592, 23), (4194277, 22), (4194278, 22), (8388593, 23), (67108832, 26), (67108833, 26), (1048555, 20), (524273, 19), (4194279, 22), (8388594, 23), (4194280, 22), (33554412, 25), (67108834, 26), (67108835, 26), (67108836, 26), (134217694, 27), (134217695, 27), (67108837, 26), (16777201, 24), (33554413, 25), (524274, 19), (2097123, 21), (67108838, 26), (134217696, 27), (134217697, 27), (67108839, 26), (134217698, 27), (16777202, 24), (2097124, 21), (2097125, 21), (67108840, 26), (67108841, 26), (268435453, 28), (134217699, 27), (134217700, 27), (134217701, 27), (1048556, 20), (16777203, 24), (1048557, 20), (2097126, 21), (4194281, 22), (2097127, 21), (2097128, 21), (8388595, 23), (4194282, 22), (4194283, 22), (33554414, 25), (33554415, 25), (16777204, 24), (16777205, 24), (67108842, 26), (8388596, 23), (67108843, 26), (134217702, 27), (67108844, 26), (67108845, 26), (134217703, 27), (134217704, 27), (134217705, 27), (134217706, 27), (134217707, 27), (268435454, 28), (134217708, 27), (134217709, 27), (134217710, 27), (134217711, 27), (134217712, 27), (67108846, 26), (1073741823, 30)]
- static_huffman_tree: HuffmanNode = None
- class scapy.contrib.http2.HuffmanNode(left: None | HuffmanNode | EOS | str, right: None | HuffmanNode | EOS | str)[source]
Bases:
object
HuffmanNode is an entry of the binary tree used for encoding/decoding HPack compressed HTTP/2 headers
- left
- right
- exception scapy.contrib.http2.InvalidEncodingException[source]
Bases:
Exception
InvalidEncodingException is raised when a supposedly huffman-encoded string is decoded and a decoding error arises
- class scapy.contrib.http2.UVarIntField(name: str, default: int, size: int)[source]
Bases:
AbstractUVarIntField
- any2i(pkt: Packet | None, x: str | int) int [source]
any2i is overloaded to restrict the acceptable x values (not None)
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused. # noqa: E501
x (str|int) – the value to convert.
- Returns:
int: the converted value.
- Raises:
AssertionError
- h2i(pkt: Packet | None, x: int) int [source]
h2i is overloaded to restrict the acceptable x values (not None)
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused. # noqa: E501
x (int) – the value to convert.
- Returns:
int: the converted value.
- Raises:
AssertionError
- i2h(pkt: Packet | None, x: int) int [source]
i2h is overloaded to restrict the acceptable x values (not None)
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused. # noqa: E501
x (int) – the value to convert.
- Returns:
int: the converted value.
- Raises:
AssertionError
- i2repr(pkt: Packet | None, x: int) str [source]
i2repr is overloaded to restrict the acceptable x values (not None)
- Parameters:
pkt (packet.Packet|None) – the packet instance containing this field instance; probably unused. # noqa: E501
x (int) – the value to convert.
- Returns:
str: the converted value.