pypacker.layer4 package

Submodules

pypacker.layer4.sctp module

Stream Control Transmission Protocol. http://tools.ietf.org/html/rfc3286 http://tools.ietf.org/html/rfc2960

class pypacker.layer4.sctp.Chunk(*args, **kwargs)

Bases: pypacker.pypacker.Packet

__hdr__ = (('type', 'B', 1), ('flags', 'B', 0), ('len', 'H', 0))
flags

Unpack field ondemand

len

Unpack field ondemand

type

Unpack field ondemand

class pypacker.layer4.sctp.SCTP(*args, **kwargs)

Bases: pypacker.pypacker.Packet

__hdr__ = (('sport', 'H', 0), ('dport', 'H', 0), ('vtag', 'I', 0), ('sum', 'I', 0, True), ('chunks', None, <class 'pypacker.triggerlist.TriggerList'>))
bin(update_auto_fields=True)
chunks
direction(other)
dport

Unpack field ondemand

padding
reverse_address()
sport

Unpack field ondemand

sum

Unpack field ondemand

sum_au_active = True
vtag

Unpack field ondemand

pypacker.layer4.sctp.unpack_H()

S.unpack(buffer) -> (v1, v2, ...)

Return a tuple containing values unpacked according to the format string S.format. Requires len(buffer) == S.size. See help(struct) for more on format strings.

pypacker.layer4.sctp.unpack_I()

S.unpack(buffer) -> (v1, v2, ...)

Return a tuple containing values unpacked according to the format string S.format. Requires len(buffer) == S.size. See help(struct) for more on format strings.

pypacker.layer4.ssl module

Secure Sockets Layer / Transport Layer Security.

class pypacker.layer4.ssl.ApplicationData(*args, **kwargs)

Bases: pypacker.pypacker.Packet

class pypacker.layer4.ssl.ChangeCipherSpec(*args, **kwargs)

Bases: pypacker.pypacker.Packet

class pypacker.layer4.ssl.Extension(*args, **kwargs)

Bases: pypacker.pypacker.Packet

Handshake protocol extension

__hdr__ = (('type', 'H', 0), ('len', 'H', 0))
len

Unpack field ondemand

type

Unpack field ondemand

class pypacker.layer4.ssl.HandshakeData(*args, **kwargs)

Bases: pypacker.pypacker.Packet

class pypacker.layer4.ssl.HandshakeHello(*args, **kwargs)

Bases: pypacker.pypacker.Packet

__hdr__ = (('type', 'B', 0), ('len', '3s', b'\x00\x00\x00'), ('tlsversion', 'H', 769), ('random', '32s', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'), ('sid_len', 'B', 32), ('sid', None, b'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'), ('ciphersuite', 'H', 53), ('compression', 'B', 0), ('ext_len', 'H', 0), ('extensions', None, <class 'pypacker.triggerlist.TriggerList'>))
ciphersuite

Unpack field ondemand

compression

Unpack field ondemand

ext_len

Unpack field ondemand

extensions
len

Unpack field ondemand

random

Unpack field ondemand

sid

Unpack field ondemand

sid_len

Unpack field ondemand

tlsversion

Unpack field ondemand

type

Unpack field ondemand

class pypacker.layer4.ssl.Record(*args, **kwargs)

Bases: pypacker.pypacker.Packet

SSLv3 or TLSv1+ Record layer.

__hdr__ = (('type', 'B', 0), ('version', 'H', 0), ('len', 'H', 0))
len

Unpack field ondemand

type

Unpack field ondemand

version

Unpack field ondemand

class pypacker.layer4.ssl.SSL(*args, **kwargs)

Bases: pypacker.pypacker.Packet

__hdr__ = (('records', None, <class 'pypacker.triggerlist.TriggerList'>),)
records
pypacker.layer4.ssl.unpack_H()

S.unpack(buffer) -> (v1, v2, ...)

Return a tuple containing values unpacked according to the format string S.format. Requires len(buffer) == S.size. See help(struct) for more on format strings.

pypacker.layer4.ssl_ciphersuites module

Nicely formatted cipher suite definitions for TLS

A list of cipher suites in the form of CipherSuite objects. These are supposed to be immutable; don’t mess with them.

class pypacker.layer4.ssl_ciphersuites.CipherSuite(code, name, kx, auth, encoding, mac)

Bases: object

Encapsulates a cipher suite.

Members/args: * code: two-byte ID code, as int * name: as in ‘TLS_RSA_WITH_RC4_40_MD5’ * kx: key exchange algorithm, string * auth: authentication algorithm, string * encoding: encoding algorithm * mac: message authentication code algorithm

BLOCK_SIZES = {'AES_256_CBC': 16}
MAC_SIZES = {'MD5': 16, 'SHA': 20, 'SHA256': 32}
block_size

In bytes. Default to 1.

mac_size

In bytes. Default to 0.

pypacker.layer4.tcp module

Transmission Control Protocol (TCP)

RFC 675 - Specification of Internet Transmission Control Program, December 1974 Version RFC 793 - TCP v4 RFC 1122 - includes some error corrections for TCP RFC 1323 - TCP-Extensions RFC 1379 - Extending TCP for Transactions—Concepts RFC 1948 - Defending Against Sequence Number Attacks RFC 2018 - TCP Selective Acknowledgment Options RFC 4614 - A Roadmap for TCP Specification Documents RFC 5681 - TCP Congestion Control RFC 6298 - Computing TCP’s Retransmission Timer RFC 6824 - TCP Extensions for Multipath Operation with Multiple Addresses

class pypacker.layer4.tcp.TCP(*args, **kwargs)

Bases: pypacker.pypacker.Packet

__hdr__ = (('sport', 'H', 57005), ('dport', 'H', 0), ('seq', 'I', 3735928559), ('ack', 'I', 0), ('off_x2', 'B', 80, True), ('flags', 'B', 2), ('win', 'H', 65535), ('sum', 'H', 0, True), ('urp', 'H', 0), ('opts', None, <class 'pypacker.triggerlist.TriggerList'>))
ack

Unpack field ondemand

bin(update_auto_fields=True)
direction(other)
dport

Unpack field ondemand

flags

Unpack field ondemand

is_next_in_stream(packet)
return – True if packet is the next expected packet in stream, False otherwise
This assumes in-order segments, otherwise they stream can’t be followed
off
off_x2

Unpack field ondemand

off_x2_au_active = True
opts
reverse_address()
seq

Unpack field ondemand

sport

Unpack field ondemand

sum

Unpack field ondemand

sum_au_active = True
urp

Unpack field ondemand

win

Unpack field ondemand

class pypacker.layer4.tcp.TCPOptMulti(*args, **kwargs)

Bases: pypacker.pypacker.Packet

len = total length (header + data)

__hdr__ = (('type', 'B', 0), ('len', 'B', 2, True))
bin(update_auto_fields=True)
len

Unpack field ondemand

len_au_active = True
type

Unpack field ondemand

class pypacker.layer4.tcp.TCPOptSingle(*args, **kwargs)

Bases: pypacker.pypacker.Packet

__hdr__ = (('type', 'B', 0),)
type

Unpack field ondemand

pypacker.layer4.tcp.pack_ipv4()

S.pack(v1, v2, ...) -> bytes

Return a bytes object containing values v1, v2, ... packed according to the format string S.format. See help(struct) for more on format strings.

pypacker.layer4.tcp.pack_ipv6()

S.pack(v1, v2, ...) -> bytes

Return a bytes object containing values v1, v2, ... packed according to the format string S.format. See help(struct) for more on format strings.

pypacker.layer4.tcp.unpack_H()

S.unpack(buffer) -> (v1, v2, ...)

Return a tuple containing values unpacked according to the format string S.format. Requires len(buffer) == S.size. See help(struct) for more on format strings.

pypacker.layer4.udp module

User Datagram Protocol (UDP)

RFC 768 - User Datagram Protocol RFC 2460 - Internet Protocol, Version 6 (IPv6) Specification RFC 2675 - IPv6 Jumbograms RFC 4113 - Management Information Base for the UDP RFC 5405 - Unicast UDP Usage Guidelines for Application Designers

class pypacker.layer4.udp.UDP(*args, **kwargs)

Bases: pypacker.pypacker.Packet

__hdr__ = (('sport', 'H', 57005), ('dport', 'H', 0), ('ulen', 'H', 8, True), ('sum', 'H', 0, True))
bin(update_auto_fields=True)
direction(other)
dport

Unpack field ondemand

reverse_address()
sport

Unpack field ondemand

sum

Unpack field ondemand

sum_au_active = True
ulen

Unpack field ondemand

ulen_au_active = True
pypacker.layer4.udp.pack_ipv4()

S.pack(v1, v2, ...) -> bytes

Return a bytes object containing values v1, v2, ... packed according to the format string S.format. See help(struct) for more on format strings.

pypacker.layer4.udp.pack_ipv6()

S.pack(v1, v2, ...) -> bytes

Return a bytes object containing values v1, v2, ... packed according to the format string S.format. See help(struct) for more on format strings.

pypacker.layer4.udp.unpack_H()

S.unpack(buffer) -> (v1, v2, ...)

Return a tuple containing values unpacked according to the format string S.format. Requires len(buffer) == S.size. See help(struct) for more on format strings.

Module contents