netzob.Import.PCAPImporter package

Submodules

netzob.Import.PCAPImporter.ImpactDecoder module

class BaseDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(buff)[source]
class DataDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(aBuffer)[source]
class Decoder[source]

Bases: object

decode(aBuffer)[source]
get_protocol(aprotocol)[source]
set_decoded_protocol(protocol)[source]
class EthDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(aBuffer)[source]
class ICMPDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(aBuffer)[source]
class IPDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(aBuffer)[source]
class IPDecoderForICMP[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

This class was added to parse the IP header of ICMP unreachables packets If you use the “standard” IPDecoder, it might crash (see bug #4870) ImpactPacket.py because the TCP header inside the IP header is incomplete

decode(aBuffer)[source]
class LinuxSLLDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(aBuffer)[source]
class TCPDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(aBuffer)[source]
class UDPDecoder[source]

Bases: netzob.Import.PCAPImporter.ImpactDecoder.Decoder

decode(aBuffer)[source]

netzob.Import.PCAPImporter.ImpactPacket module

class Data(aBuffer=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.Header

This packet type can hold raw data. It’s normally employed to hold a packet’s innermost layer’s contents in those cases for which the protocol details are unknown, and there’s a copy of a valid packet available.

For instance, if all that’s known about a certain protocol is that a UDP packet with its contents set to “HELLO” initiate a new session, creating such packet is as simple as in the following code fragment: packet = UDP() packet.contains(‘HELLO’)

get_size()[source]
set_data(data)[source]
class Ethernet(aBuffer=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.Header

static as_eth_addr(anArray)[source]
get_ether_dhost()[source]

Return 48 bit destination ethernet address as a 6 byte array

get_ether_shost()[source]

Return 48 bit source ethernet address as a 6 byte array

get_ether_type()[source]

Return ethernet data type field

get_header_size()[source]

Return size of Ethernet header

get_packet()[source]
get_tag(index)[source]

Returns an EthernetTag initialized from index-th VLAN tag. The tags are numbered from 0 to self.tag_cnt-1 as they appear in the frame. It is possible to use negative indexes as well.

load_header(aBuffer)[source]
pop_tag(index=0)[source]

Removes the index-th VLAN tag and returns it as an EthernetTag object. Index defaults to 0 (the top of the stack).

push_tag(tag, index=0)[source]

Inserts contents of an EthernetTag object before the index-th VLAN tag. Index defaults to 0 (the top of the stack).

set_ether_dhost(aValue)[source]

Set destination ethernet address from 6 byte array ‘aValue’

set_ether_shost(aValue)[source]

Set source ethernet address from 6 byte array ‘aValue’

set_ether_type(aValue)[source]

Set ethernet data type field to ‘aValue’

set_tag(index, tag)[source]

Sets the index-th VLAN tag to contents of an EthernetTag object. The tags are numbered from 0 to self.tag_cnt-1 as they appear in the frame. It is possible to use negative indexes as well.

class EthernetTag(value=2164260864)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.PacketBuffer

Represents a VLAN header specified in IEEE 802.1Q and 802.1ad. Provides methods for convenient manipulation with header fields.

get_dei()[source]

Returns Drop Eligible Indicator

get_pcp()[source]

Returns Priority Code Point

get_tpid()[source]

Returns Tag Protocol Identifier

get_vid()[source]

Returns VLAN Identifier

set_dei(value)[source]

Sets Drop Eligible Indicator

set_pcp(value)[source]

Sets Priority Code Point

set_tpid(value)[source]

Sets Tag Protocol Identifier

set_vid(value)[source]

Sets VLAN Identifier

class Header(length=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.PacketBuffer, netzob.Import.PCAPImporter.ImpactPacket.ProtocolLayer

This is the base class from which all protocol definitions extend.

calculate_checksum()[source]

Calculate and set the checksum for this header

ethertype = None
get_data_as_string()[source]

Returns all data from children of this header as string

get_header_size()[source]

Return the size of this header, that is, not counting neither the size of the children nor of the parents.

get_packet()[source]

Returns the raw representation of this packet and its children as a string. The output from this method is a packet ready to be transmitted over the wire.

get_pseudo_header()[source]

Pseudo headers can be used to limit over what content will the checksums be calculated.

get_size()[source]

Return the size of this header and all of it’s children

list_as_hex(aList)[source]
load_header(aBuffer)[source]

Properly set the state of this instance to reflect that of the raw packet passed as argument.

packet_printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ '
protocol = None
class ICMP(aBuffer=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.Header

ICMP_UNREACH = 3
get_checksum()[source]
get_code()[source]
get_header_size()[source]
get_icmp_type()[source]
get_identifier()[source]
get_packet()[source]
get_sequence_number()[source]
protocol = 1
set_checksum(value)[source]
set_code(value)[source]
set_icmp_type(value)[source]
set_identifier(value)[source]
set_sequence_number(value)[source]
class IP(aBuffer=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.Header

add_option(option)[source]
ethertype = 2048
fragment_by_list(aList)[source]
fragment_by_size(aSize)[source]
get_header_size()[source]
get_ip_df()[source]
get_ip_dst()[source]
get_ip_hl()[source]
get_ip_id()[source]
get_ip_len()[source]
get_ip_mf()[source]
get_ip_off()[source]
get_ip_offmask()[source]
get_ip_p()[source]
get_ip_rf()[source]
get_ip_src()[source]
get_ip_sum()[source]
get_ip_tos()[source]
get_ip_ttl()[source]
get_ip_v()[source]
get_packet()[source]
get_pseudo_header()[source]
load_header(aBuffer)[source]
reset_ip_sum()[source]
set_ip_df(aValue)[source]
set_ip_dst(value)[source]
set_ip_hl(value)[source]
set_ip_id(value)[source]
set_ip_len(value)[source]
set_ip_mf(aValue)[source]
set_ip_off(aValue)[source]
set_ip_offmask(aValue)[source]
set_ip_p(value)[source]
set_ip_rf(aValue)[source]
set_ip_src(value)[source]
set_ip_sum(value)[source]
set_ip_tos(value)[source]
set_ip_ttl(value)[source]
set_ip_v(value)[source]
class IPOption(opcode=0, size=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.PacketBuffer

IPOPT_EOL = 0
IPOPT_LSRR = 131
IPOPT_NOP = 1
IPOPT_RR = 7
IPOPT_SSRR = 137
IPOPT_TS = 68
append_ip(ip)[source]
get_code()[source]
get_flags(flags)[source]
get_len()[source]
get_ptr()[source]
print_addresses()[source]
set_code(value)[source]
set_flags(flags)[source]
set_len(len)[source]
set_ptr(ptr)[source]
exception ImpactPacketException(value)[source]

Bases: Exception

class LinuxSLL(aBuffer=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.Header

get_addr()[source]

Returns the sender’s address field

get_addr_len()[source]

Returns the length of the sender’s address field

get_arphdr()[source]

Returns the ARPHDR value for the link layer device type

get_ether_type()[source]

Return ethernet data type field

get_header_size()[source]

Return size of packet header

get_packet()[source]
get_type()[source]

Returns the packet type field

get_type_desc()[source]
set_addr(addr)[source]

Sets the sender’s address field to addr. Addr must be at most 8-byte long.

set_addr_len(len)[source]

Sets the length of the sender’s address field to len

set_arphdr(value)[source]

Sets the ARPHDR value for the link layer device type

set_ether_type(aValue)[source]

Set ethernet data type field to ‘aValue’

set_type(type)[source]

Sets the packet type field to type

type_descriptions = ['sent to us by somebody else', 'broadcast by somebody else', 'multicast by somebody else', 'sent to somebody else to somebody else', 'sent by us']
class PacketBuffer(length=None)[source]

Bases: object

Implement the basic operations utilized to operate on a packet’s raw buffer. All the packet classes derive from this one.

The byte, word, long and ip_address getters and setters accept negative indexes, having these the a similar effect as in a regular Python sequence slice.

compute_checksum(anArray)[source]

Return the one’s complement of the one’s complement sum of all the 16-bit words in ‘anArray’

get_buffer_as_string()[source]

Returns the packet buffer as a string object

get_byte(index)[source]

Return byte at ‘index’

get_bytes()[source]

Returns the packet buffer as an array

get_ip_address(index)[source]

Return 4-byte value at ‘index’ as an IP string

get_long(index, order='!')[source]

Return 4-byte value at ‘index’. See struct module’s documentation to understand the meaning of ‘order’.

get_long_long(index, order='!')[source]

Return 8-byte value at ‘index’. See struct module’s documentation to understand the meaning of ‘order’.

get_word(index, order='!')[source]

Return 2-byte word at ‘index’. See struct module’s documentation to understand the meaning of ‘order’.

normalize_checksum(aValue)[source]
set_byte(index, value)[source]

Set byte at ‘index’ to ‘value’

set_bytes(bytes)[source]

Set the packet buffer from an array

set_bytes_from_string(data)[source]

Sets the value of the packet buffer from the string ‘data’

set_checksum_from_data(index, data)[source]

Set 16-bit checksum at ‘index’ by calculating checksum of ‘data’

set_ip_address(index, ip_string)[source]

Set 4-byte value at ‘index’ from ‘ip_string’

set_long(index, value, order='!')[source]

Set 4-byte ‘value’ at ‘index’. See struct module’s documentation to understand the meaning of ‘order’.

set_long_long(index, value, order='!')[source]

Set 8-byte ‘value’ at ‘index’. See struct module’s documentation to understand the meaning of ‘order’.

set_word(index, value, order='!')[source]

Set 2-byte word at ‘index’ to ‘value’. See struct module’s documentation to understand the meaning of ‘order’.

class ProtocolLayer[source]

Bases: object

Protocol Layer Manager for insertion and removal of protocol layers.

child()[source]

Return the child of this protocol layer

contains(aHeader)[source]

Set ‘aHeader’ as the child of this protocol layer

parent()[source]

Return the parent of this protocol layer

set_parent(my_parent)[source]

Set the header ‘my_parent’ as the parent of this protocol layer

Break the hierarchy parent/child child/parent

class ProtocolPacket(header_size, tail_size)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.ProtocolLayer

body
body_string
get_body_as_string()[source]
get_body_size()[source]

Return frame body size

get_header_as_string()[source]
get_header_size()[source]

Return frame header size

get_packet()[source]
get_size()[source]

Return frame total size

get_tail_as_string()[source]
get_tail_size()[source]

Return frame tail size

header
load_body(aBuffer)[source]

Load the packet body from string. WARNING: Using this function will break the hierarchy of preceding protocol layer

load_header(aBuffer)[source]
load_packet(aBuffer)[source]

Load the whole packet from a stringWARNING: Using this function will break the hierarchy of preceding protocol layer

load_tail(aBuffer)[source]
tail
tail_string
class TCP(aBuffer=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.Header

TCP_FLAGS_MASK = 255
add_option(option)[source]
calculate_checksum()[source]
get_ACK()[source]
get_CWR()[source]
get_ECE()[source]
get_FIN()[source]
get_PSH()[source]
get_RST()[source]
get_SYN()[source]
get_URG()[source]
get_flag(bit)[source]
get_header_size()[source]
get_options()[source]
get_packet()[source]

Returns entire packet including child data as a string. This is the function used to extract the final packet

get_padded_options()[source]

Return an array containing all options padded to a 4 byte boundry

get_th_ack()[source]
get_th_dport()[source]
get_th_flags()[source]
get_th_off()[source]
get_th_reserved()[source]
get_th_seq()[source]
get_th_sport()[source]
get_th_sum()[source]
get_th_urp()[source]
get_th_win()[source]
load_header(aBuffer)[source]
protocol = 6
reset_ACK()[source]
reset_CWR()[source]
reset_ECE()[source]
reset_FIN()[source]
reset_PSH()[source]
reset_RST()[source]
reset_SYN()[source]
reset_URG()[source]
reset_flags(aValue)[source]
set_ACK()[source]
set_CWR()[source]
set_ECE()[source]
set_FIN()[source]
set_PSH()[source]
set_RST()[source]
set_SYN()[source]
set_URG()[source]
set_flags(aValue)[source]
set_th_ack(aValue)[source]
set_th_dport(aValue)[source]
set_th_flags(aValue)[source]
set_th_off(aValue)[source]
set_th_seq(aValue)[source]
set_th_sport(aValue)[source]
set_th_sum(aValue)[source]
set_th_urp(aValue)[source]
set_th_win(aValue)[source]
swapSourceAndDestination()[source]
class TCPOption(kind, data=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.PacketBuffer

TCPOPT_EOL = 0
TCPOPT_MAXSEG = 2
TCPOPT_NOP = 1
TCPOPT_SACK = 5
TCPOPT_SACK_PERMITTED = 4
TCPOPT_SIGNATURE = 19
TCPOPT_TIMESTAMP = 8
TCPOPT_WINDOW = 3
get_kind()[source]
get_len()[source]
get_mss()[source]
get_shift_cnt()[source]
get_size()[source]
get_ts()[source]
get_ts_echo()[source]
set_kind(kind)[source]
set_left_edge(aValue)[source]
set_len(len)[source]
set_mss(len)[source]
set_right_edge(aValue)[source]
set_shift_cnt(cnt)[source]
set_ts(ts)[source]
set_ts_echo(ts)[source]
class UDP(aBuffer=None)[source]

Bases: netzob.Import.PCAPImporter.ImpactPacket.Header

calculate_checksum()[source]
get_header_size()[source]
get_packet()[source]
get_uh_dport()[source]
get_uh_sport()[source]
get_uh_sum()[source]
get_uh_ulen()[source]
protocol = 17
set_uh_dport(value)[source]
set_uh_sport(value)[source]
set_uh_sum(value)[source]
set_uh_ulen(value)[source]

netzob.Import.PCAPImporter.PCAPImporter module

netzob.Import.PCAPImporter.all module

Module contents