pysap.utils.fields module¶
-
class
pysap.utils.fields.ASN1F_CHOICE_SAFE(name, default, *args, **kwargs)[source]¶ Bases:
scapy.asn1fields.ASN1F_CHOICE
-
class
pysap.utils.fields.AdjustableFieldLenField(name, default, length_of=None)[source]¶ Bases:
scapy.fields.Field-
addfield(pkt, s, val)[source]¶ Add an internal value to a string
Copy the network representation of field val (belonging to layer pkt) to the raw string packet s, and return the new string packet.
-
adjust¶
-
count_of¶
-
getfield(pkt, s)[source]¶ Extract an internal value from a string
Extract from the raw packet s the field value belonging to layer pkt.
Returns a two-element list, first the raw packet string after having removed the extracted field, second the extracted field itself in internal representation.
-
length_of¶
-
-
class
pysap.utils.fields.ByteMultiEnumKeysField(name, default, enum, depends_on, fmt='H')[source]¶ Bases:
scapy.fields.MultiEnumFieldMultiEnumField that picks a reduced number of values. Used for fuzzing Byte fields with reduced number of values.
-
class
pysap.utils.fields.IntToStrField(name, default, length=11)[source]¶ Bases:
scapy.fields.FieldCustom field from int to str values, with a variable length
-
format¶
-
i2count(pkt, x)[source]¶ Convert internal value to a number of elements usable by a FieldLenField. Always 1 except for list fields
-
length¶
-
-
class
pysap.utils.fields.MutablePacketField(name, default, length_from, get_class, evaluators=None)[source]¶ Bases:
scapy.fields.StrLenFieldPacket field that mutates the class according to a list of evaluators. The evaluators are run against the packet and given to a class getter.
If the class can’t be found, the field is treated as a StrLenField.
-
evaluators¶
-
length_from¶
-
-
class
pysap.utils.fields.PacketListStopField(name, default, cls, count_from=None, length_from=None, stop=None)[source]¶ Bases:
scapy.fields.PacketListFieldCustom field that contains a list of packets until a ‘stop’ condition is met.
-
count_from¶
-
getfield(pkt, s)[source]¶ Extract an internal value from a string
Extract from the raw packet s the field value belonging to layer pkt.
Returns a two-element list, first the raw packet string after having removed the extracted field, second the extracted field itself in internal representation.
-
length_from¶
-
stop¶
-
-
class
pysap.utils.fields.PacketNoPadded(_pkt='', post_transform=None, _internal=0, _underlayer=None, **fields)[source]¶ Bases:
scapy.packet.PacketRegular scapy packet with no padding.
-
aliastypes= [<class 'pysap.utils.fields.PacketNoPadded'>, <class 'scapy.packet.Packet'>]¶
-
-
class
pysap.utils.fields.RandByteReduced[source]¶ Bases:
scapy.volatile.RandNumRandByte that only returns random values between 0 and x2a. Used while performing some fuzz to reduce the test cases space.
-
class
pysap.utils.fields.StrEncodedPaddedField(name, default, encoding='utf-16', padd='x0c', fmt='H', remain=0)[source]¶ Bases:
scapy.fields.StrField-
addfield(pkt, s, val)[source]¶ Add an internal value to a string
Copy the network representation of field val (belonging to layer pkt) to the raw string packet s, and return the new string packet.
-
encoding¶
-
getfield(pkt, s)[source]¶ Extract an internal value from a string
Extract from the raw packet s the field value belonging to layer pkt.
Returns a two-element list, first the raw packet string after having removed the extracted field, second the extracted field itself in internal representation.
-
padd¶
-
remain¶
-
-
class
pysap.utils.fields.StrFixedLenPaddedField(name, default, length=None, length_from=None, padd=' ')[source]¶ Bases:
scapy.fields.StrFixedLenFieldPacket field that has a fixed length and is padded with a given character.
-
addfield(pkt, s, val)[source]¶ Add an internal value to a string
Copy the network representation of field val (belonging to layer pkt) to the raw string packet s, and return the new string packet.
-
getfield(pkt, s)[source]¶ Extract an internal value from a string
Extract from the raw packet s the field value belonging to layer pkt.
Returns a two-element list, first the raw packet string after having removed the extracted field, second the extracted field itself in internal representation.
-
length_from¶
-
padd¶
-
-
class
pysap.utils.fields.StrNullFixedLenField(name, default, length=None, length_from=None, max_length=None, null_terminated=None)[source]¶ Bases:
scapy.fields.StrFixedLenFieldPacket field that has a fixed length and is conditionally null-terminated.
-
addfield(pkt, s, val)[source]¶ Add an internal value to a string
Copy the network representation of field val (belonging to layer pkt) to the raw string packet s, and return the new string packet.
-
getfield(pkt, s)[source]¶ Extract an internal value from a string
Extract from the raw packet s the field value belonging to layer pkt.
Returns a two-element list, first the raw packet string after having removed the extracted field, second the extracted field itself in internal representation.
-
length_from¶
-
max_length¶
-
null_terminated¶
-
-
class
pysap.utils.fields.StrNullFixedLenPaddedField(name, default, length=None, length_from=None, padd=' ')[source]¶ Bases:
scapy.fields.StrFixedLenFieldPacket field that has a fixed length and is padded with a given character and null terminated.
-
addfield(pkt, s, val)[source]¶ Add an internal value to a string
Copy the network representation of field val (belonging to layer pkt) to the raw string packet s, and return the new string packet.
-
getfield(pkt, s)[source]¶ Extract an internal value from a string
Extract from the raw packet s the field value belonging to layer pkt.
Returns a two-element list, first the raw packet string after having removed the extracted field, second the extracted field itself in internal representation.
-
length_from¶
-
padd¶
-