scapy.packet¶
Packet class
- Provides:
the default Packet classes
binding mechanisms
fuzz() method
exploration methods: explore() / ls()
-
class
scapy.packet.
NoPayload
(*args, **kargs)¶ Bases:
scapy.packet.Packet
-
add_payload
(payload)¶
-
add_underlayer
(underlayer)¶
-
aliastypes
¶
-
answers
(other)¶
-
build
()¶
-
build_done
(p)¶
-
build_padding
()¶
-
build_ps
(internal=0)¶
-
clear_cache
()¶
-
command
()¶
-
copy
()¶
-
delfieldval
(attr)¶
-
dissection_done
(pkt)¶
-
do_build
()¶
-
fragment
(*args, **kargs)¶
-
getfield_and_val
(attr)¶
-
getfieldval
(attr)¶
-
getlayer
(cls, nb=1, _track=None, **flt)¶
-
hashret
()¶
-
haslayer
(cls, _subclass=None)¶
-
hide_defaults
()¶
-
lastlayer
(layer)¶
-
layers
()¶
-
remove_payload
()¶
-
remove_underlayer
(other)¶
-
route
()¶
-
setfieldval
(attr, val)¶
-
show
(indent=3, lvl='', label_lvl='')¶
-
sprintf
(fmt, relax)¶
-
-
class
scapy.packet.
Packet
(*args, **kargs)¶ Bases:
scapy.base_classes.BasePacket
,scapy.base_classes._CanvasDumpExtended
-
add_payload
(payload)¶
-
add_underlayer
(underlayer)¶
-
aliastypes
¶
-
answers
(other)¶ DEV: true if self is an answer from other
-
build
()¶ Create the current layer
- Returns
string of the packet with the payload
-
build_done
(p)¶
-
build_padding
()¶
-
build_ps
(internal=0)¶
-
canvas_dump
(layer_shift=0, rebuild=1)¶
-
class_default_fields
= {<class 'scapy.layers.x509.ECFieldID'>: {'fieldType': <ASN1_OID['prime-field']>, 'prime': 0x0 <ASN1_INTEGER[0]>}, <class 'scapy.layers.x509.ECCurve'>: {'a': <ASN1_STRING['']>, 'b': <ASN1_STRING['']>, 'seed': None}, <class 'scapy.layers.x509.X509_AttributeValue'>: {'value': <ASN1_PRINTABLE_STRING['FR']>}, <class 'scapy.layers.x509.X509_AttributeTypeAndValue'>: {'type': <ASN1_OID['countryName']>, 'value': <ASN1_PRINTABLE_STRING['FR']>}, <class 'scapy.layers.x509.X509_RDN'>: {'rdn': [<X509_AttributeTypeAndValue |>]}, <class 'scapy.layers.x509.X509_DirectoryName'>: {'directoryName': [<X509_RDN rdn=[<X509_AttributeTypeAndValue |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.10' value=<ASN1_PRINTABLE_STRING['Scapy, Inc.']> |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.3' value=<ASN1_PRINTABLE_STRING['Scapy Default Name']> |>] |>]}, <class 'scapy.layers.x509.X509_Attribute'>: {'type': <ASN1_OID['countryName']>, 'values': [<X509_AttributeValue |>]}, <class 'scapy.layers.x509.X509_GeneralName'>: {'generalName': <X509_DirectoryName directoryName=[<X509_RDN rdn=[<X509_AttributeTypeAndValue |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.10' value=<ASN1_PRINTABLE_STRING['Scapy, Inc.']> |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.3' value=<ASN1_PRINTABLE_STRING['Scapy Default Name']> |>] |>] |>}, <class 'scapy.layers.x509.X509_ExtDistributionPointName'>: {'distributionPointName': None}, <class 'scapy.layers.x509.X509_ExtPolicyInformation'>: {'policyIdentifier': <ASN1_OID['anyPolicy']>, 'policyQualifiers': None}, <class 'scapy.layers.x509.X509_ExtDistributionPoint'>: {'distributionPoint': <X509_ExtDistributionPointName |>, 'reasons': None, 'cRLIssuer': None}, <class 'scapy.layers.x509.X509_AccessDescription'>: {'accessMethod': <ASN1_OID['.0']>, 'accessLocation': <X509_GeneralName generalName=<X509_DirectoryName directoryName=[<X509_RDN rdn=[<X509_AttributeTypeAndValue |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.10' value=<ASN1_PRINTABLE_STRING['Scapy, Inc.']> |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.3' value=<ASN1_PRINTABLE_STRING['Scapy Default Name']> |>] |>] |> |>}, <class 'scapy.layers.x509.X509_ExtQcStatement'>: {'statementId': <ASN1_OID['.0.4.0.1862.1.1']>, 'statementInfo': None}, <class 'scapy.layers.x509.X509_ExtBasicConstraints'>: {'cA': False <ASN1_BOOLEAN[False]>, 'pathLenConstraint': None}, <class 'scapy.layers.x509.X509_AlgorithmIdentifier'>: {'algorithm': <ASN1_OID['sha256WithRSAEncryption']>, 'parameters': <ASN1_NULL[0]>}, <class 'scapy.layers.x509.RSAPrivateKey'>: {'version': 0x0 <ASN1_INTEGER[0]>, 'modulus': 0xa <ASN1_INTEGER[10]>, 'publicExponent': 0x3 <ASN1_INTEGER[3]>, 'privateExponent': 0x3 <ASN1_INTEGER[3]>, 'prime1': 0x2 <ASN1_INTEGER[2]>, 'prime2': 0x5 <ASN1_INTEGER[5]>, 'exponent1': 0x0 <ASN1_INTEGER[0]>, 'exponent2': 0x3 <ASN1_INTEGER[3]>, 'coefficient': 0x1 <ASN1_INTEGER[1]>, 'otherPrimeInfos': None}, <class 'scapy.layers.x509.ECParameters'>: {'curve': <ASN1_OID['ansip384r1']>}, <class 'scapy.layers.x509.ECDSAPrivateKey'>: {'version': 0x1 <ASN1_INTEGER[1]>, 'privateKey': <ASN1_STRING['']>, 'parameters': None, 'publicKey': None}, <class 'scapy.layers.x509.X509_Validity'>: {'not_before': Nov 23 11:35:19 2020 GMT <ASN1_UTC_TIME['201123113519Z']>, 'not_after': Nov 24 11:45:19 2020 GMT <ASN1_UTC_TIME['201124114519Z']>}, <class 'scapy.layers.x509.X509_SubjectPublicKeyInfo'>: {'signatureAlgorithm': <X509_AlgorithmIdentifier |>, 'subjectPublicKey': None}, <class 'scapy.layers.x509.X509_Extension'>: {'extnID': <ASN1_OID['basicConstraints']>, 'critical': False <ASN1_BOOLEAN[False]>, 'extnValue': <X509_ExtBasicConstraints |>}, <class 'scapy.layers.x509.X509_TBSCertificate'>: {'version': 0x2 <ASN1_INTEGER[2]>, 'serialNumber': 0x1 <ASN1_INTEGER[1]>, 'signature': <X509_AlgorithmIdentifier |>, 'issuer': [<X509_RDN rdn=[<X509_AttributeTypeAndValue |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.10' value=<ASN1_PRINTABLE_STRING['Scapy, Inc.']> |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.3' value=<ASN1_PRINTABLE_STRING['Scapy Default Issuer']> |>] |>], 'validity': <X509_Validity |>, 'subject': [<X509_RDN rdn=[<X509_AttributeTypeAndValue |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.10' value=<ASN1_PRINTABLE_STRING['Scapy, Inc.']> |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.3' value=<ASN1_PRINTABLE_STRING['Scapy Default Subject']> |>] |>], 'subjectPublicKeyInfo': <X509_SubjectPublicKeyInfo signatureAlgorithm=<X509_AlgorithmIdentifier |> |>, 'issuerUniqueID': None, 'subjectUniqueID': None, 'extensions': [<X509_Extension extnValue=<X509_ExtBasicConstraints |> |>]}, <class 'scapy.layers.x509.X509_TBSCertList'>: {'version': 0x1 <ASN1_INTEGER[1]>, 'signature': <X509_AlgorithmIdentifier |>, 'issuer': [<X509_RDN rdn=[<X509_AttributeTypeAndValue |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.10' value=<ASN1_PRINTABLE_STRING['Scapy, Inc.']> |>] |>, <X509_RDN rdn=[<X509_AttributeTypeAndValue type='2.5.4.3' value=<ASN1_PRINTABLE_STRING['Scapy Default Issuer']> |>] |>], 'this_update': Nov 23 11:45:18 2020 GMT <ASN1_UTC_TIME['201123114518Z']>, 'next_update': None, 'revokedCertificates': None, 'crlExtensions': None}, <class 'scapy.layers.x509.OCSP_GoodInfo'>: {'info': <ASN1_NULL[0]>}, <class 'scapy.layers.x509.OCSP_RevokedInfo'>: {'revocationTime': [invalid _generalized_time] <ASN1_GENERALIZED_TIME['']>, 'revocationReason': None}, <class 'scapy.layers.x509.OCSP_UnknownInfo'>: {'info': <ASN1_NULL[0]>}, <class 'scapy.layers.x509.OCSP_CertID'>: {'hashAlgorithm': <X509_AlgorithmIdentifier |>, 'issuerNameHash': <ASN1_STRING['']>, 'issuerKeyHash': <ASN1_STRING['']>, 'serialNumber': 0x0 <ASN1_INTEGER[0]>}, <class 'scapy.layers.x509.OCSP_CertStatus'>: {'certStatus': None}, <class 'scapy.layers.x509.OCSP_ByName'>: {'byName': []}, <class 'scapy.layers.x509.OCSP_ByKey'>: {'byKey': <ASN1_STRING['']>}, <class 'scapy.layers.x509.OCSP_ResponderID'>: {'responderID': None}, <class 'scapy.layers.x509.OCSP_ResponseData'>: {'version': 0x0 <ASN1_INTEGER[0]>, 'responderID': <OCSP_ResponderID |>, 'producedAt': Nov 23 11:45:19 2020 GMT <ASN1_GENERALIZED_TIME['20201123114519Z']>, 'responses': [], 'responseExtensions': None}, <class 'scapy.contrib.loraphy2wan.LinkADRAns_Status'>: {'RFU': 0, 'PowerACK': 0, 'DataRate': 0, 'ChannelMaskACK': 0}, <class 'scapy.contrib.oncrpc.Object_Name'>: {'length': 0, '_name': b'', 'fill': b''}, <class 'scapy.contrib.oncrpc.Auth_Unix'>: {'stamp': 0, 'mname': <Object_Name |>, 'uid': 0, 'gid': 0, 'num_auxgids': 0, 'auxgids': []}, <class 'scapy.contrib.nfs.Fattr3'>: {'type': 0, 'mode': 0, 'nlink': 0, 'uid': 0, 'gid': 0, 'size': 0, 'used': 0, 'rdev': [0, 0], 'fsid': 0, 'fileid': 0, 'atime_s': 0, 'atime_ns': 0, 'mtime_s': 0, 'mtime_ns': 0, 'ctime_s': 0, 'ctime_ns': 0}, <class 'scapy.contrib.nfs.File_Object'>: {'length': 0, 'fh': b'', 'fill': b''}, <class 'scapy.contrib.nfs.WCC_Attr'>: {'size': 0, 'mtime_s': 0, 'mtime_ns': 0, 'ctime_s': 0, 'ctime_ns': 0}, <class 'scapy.contrib.nfs.Sattr3'>: {'set_mode': 0, 'mode': 0, 'set_uid': 0, 'uid': 0, 'set_gid': 0, 'gid': 0, 'set_size': 0, 'size': 0, 'set_atime': 0, 'atime_s': 0, 'atime_ns': 0, 'set_mtime': 0, 'mtime_s': 0, 'mtime_ns': 0}, <class 'scapy.contrib.mount.Path'>: {'length': 0, 'path': b'', 'fill': b''}, <class 'scapy.contrib.nlm.NLM4_Cookie'>: {'length': 0, 'contents': b'', 'fill': b''}, <class 'scapy.layers.dot15d4.Dot15d4AuxSecurityHeader'>: {'sec_sc_reserved': 0, 'sec_sc_keyidmode': 0, 'sec_sc_seclevel': 0, 'sec_framecounter': 0, 'sec_keyid_keysource': 0, 'sec_keyid_keyindex': 255}}¶
-
class_default_fields_ref
= {<class 'scapy.layers.x509.ECFieldID'>: [], <class 'scapy.layers.x509.ECCurve'>: [], <class 'scapy.layers.x509.X509_AttributeValue'>: [], <class 'scapy.layers.x509.X509_AttributeTypeAndValue'>: [], <class 'scapy.layers.x509.X509_RDN'>: ['rdn'], <class 'scapy.layers.x509.X509_DirectoryName'>: ['directoryName'], <class 'scapy.layers.x509.X509_Attribute'>: ['values'], <class 'scapy.layers.x509.X509_GeneralName'>: ['generalName'], <class 'scapy.layers.x509.X509_ExtDistributionPointName'>: [], <class 'scapy.layers.x509.X509_ExtPolicyInformation'>: [], <class 'scapy.layers.x509.X509_ExtDistributionPoint'>: ['distributionPoint'], <class 'scapy.layers.x509.X509_AccessDescription'>: ['accessLocation'], <class 'scapy.layers.x509.X509_ExtQcStatement'>: [], <class 'scapy.layers.x509.X509_ExtBasicConstraints'>: [], <class 'scapy.layers.x509.X509_AlgorithmIdentifier'>: [], <class 'scapy.layers.x509.RSAPrivateKey'>: [], <class 'scapy.layers.x509.ECParameters'>: [], <class 'scapy.layers.x509.ECDSAPrivateKey'>: [], <class 'scapy.layers.x509.X509_Validity'>: [], <class 'scapy.layers.x509.X509_SubjectPublicKeyInfo'>: ['signatureAlgorithm'], <class 'scapy.layers.x509.X509_Extension'>: ['extnValue'], <class 'scapy.layers.x509.X509_TBSCertificate'>: ['signature', 'issuer', 'validity', 'subject', 'subjectPublicKeyInfo', 'extensions'], <class 'scapy.layers.x509.X509_TBSCertList'>: ['signature', 'issuer'], <class 'scapy.layers.x509.OCSP_GoodInfo'>: [], <class 'scapy.layers.x509.OCSP_RevokedInfo'>: [], <class 'scapy.layers.x509.OCSP_UnknownInfo'>: [], <class 'scapy.layers.x509.OCSP_CertID'>: ['hashAlgorithm'], <class 'scapy.layers.x509.OCSP_CertStatus'>: [], <class 'scapy.layers.x509.OCSP_ByName'>: ['byName'], <class 'scapy.layers.x509.OCSP_ByKey'>: [], <class 'scapy.layers.x509.OCSP_ResponderID'>: [], <class 'scapy.layers.x509.OCSP_ResponseData'>: ['responderID', 'responses'], <class 'scapy.contrib.loraphy2wan.LinkADRAns_Status'>: [], <class 'scapy.contrib.oncrpc.Object_Name'>: [], <class 'scapy.contrib.oncrpc.Auth_Unix'>: ['mname', 'auxgids'], <class 'scapy.contrib.nfs.Fattr3'>: ['rdev'], <class 'scapy.contrib.nfs.File_Object'>: [], <class 'scapy.contrib.nfs.WCC_Attr'>: [], <class 'scapy.contrib.nfs.Sattr3'>: [], <class 'scapy.contrib.mount.Path'>: [], <class 'scapy.contrib.nlm.NLM4_Cookie'>: [], <class 'scapy.layers.dot15d4.Dot15d4AuxSecurityHeader'>: []}¶
-
class_dont_cache
= {}¶
-
class_fieldtype
= {<class 'scapy.layers.x509.ECFieldID'>: {'fieldType': <scapy.asn1fields.ASN1F_OID object>, 'prime': <scapy.asn1fields.ASN1F_INTEGER object>}, <class 'scapy.layers.x509.ECCurve'>: {'a': <scapy.asn1fields.ASN1F_STRING object>, 'b': <scapy.asn1fields.ASN1F_STRING object>, 'seed': <scapy.asn1fields.ASN1F_BIT_STRING object>}, <class 'scapy.layers.x509.X509_AttributeValue'>: {'value': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.X509_AttributeTypeAndValue'>: {'type': <scapy.asn1fields.ASN1F_OID object>, 'value': <scapy.layers.x509.ASN1F_X509_DirectoryString object>}, <class 'scapy.layers.x509.X509_RDN'>: {'rdn': <ASN1F_SET_OF rdn>}, <class 'scapy.layers.x509.X509_DirectoryName'>: {'directoryName': <ASN1F_SEQUENCE_OF directoryName>}, <class 'scapy.layers.x509.X509_Attribute'>: {'type': <scapy.asn1fields.ASN1F_OID object>, 'values': <ASN1F_SET_OF values>}, <class 'scapy.layers.x509.X509_GeneralName'>: {'generalName': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.X509_ExtDistributionPointName'>: {'distributionPointName': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.X509_ExtPolicyInformation'>: {'policyIdentifier': <scapy.asn1fields.ASN1F_OID object>, 'policyQualifiers': <ASN1F_SEQUENCE_OF policyQualifiers>}, <class 'scapy.layers.x509.X509_ExtDistributionPoint'>: {'distributionPoint': <scapy.asn1fields.ASN1F_PACKET object>, 'reasons': <scapy.asn1fields.ASN1F_FLAGS object>, 'cRLIssuer': <ASN1F_SEQUENCE_OF cRLIssuer>}, <class 'scapy.layers.x509.X509_AccessDescription'>: {'accessMethod': <scapy.asn1fields.ASN1F_OID object>, 'accessLocation': <scapy.asn1fields.ASN1F_PACKET object>}, <class 'scapy.layers.x509.X509_ExtQcStatement'>: {'statementId': <scapy.asn1fields.ASN1F_OID object>, 'statementInfo': <scapy.asn1fields.ASN1F_field object>}, <class 'scapy.layers.x509.X509_ExtBasicConstraints'>: {'cA': <scapy.asn1fields.ASN1F_BOOLEAN object>, 'pathLenConstraint': <scapy.asn1fields.ASN1F_INTEGER object>}, <class 'scapy.layers.x509.X509_AlgorithmIdentifier'>: {'algorithm': <scapy.asn1fields.ASN1F_OID object>, 'parameters': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.RSAPrivateKey'>: {'version': <scapy.asn1fields.ASN1F_enum_INTEGER object>, 'modulus': <scapy.asn1fields.ASN1F_INTEGER object>, 'publicExponent': <scapy.asn1fields.ASN1F_INTEGER object>, 'privateExponent': <scapy.asn1fields.ASN1F_INTEGER object>, 'prime1': <scapy.asn1fields.ASN1F_INTEGER object>, 'prime2': <scapy.asn1fields.ASN1F_INTEGER object>, 'exponent1': <scapy.asn1fields.ASN1F_INTEGER object>, 'exponent2': <scapy.asn1fields.ASN1F_INTEGER object>, 'coefficient': <scapy.asn1fields.ASN1F_INTEGER object>, 'otherPrimeInfos': <ASN1F_SEQUENCE_OF otherPrimeInfos>}, <class 'scapy.layers.x509.ECParameters'>: {'curve': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.ECDSAPrivateKey'>: {'version': <scapy.asn1fields.ASN1F_enum_INTEGER object>, 'privateKey': <scapy.asn1fields.ASN1F_STRING object>, 'parameters': <scapy.asn1fields.ASN1F_PACKET object>, 'publicKey': <scapy.asn1fields.ASN1F_PACKET object>}, <class 'scapy.layers.x509.X509_Validity'>: {'not_before': <scapy.asn1fields.ASN1F_CHOICE object>, 'not_after': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.X509_SubjectPublicKeyInfo'>: {'signatureAlgorithm': <scapy.asn1fields.ASN1F_PACKET object>, 'subjectPublicKey': <scapy.asn1fields.ASN1F_BIT_STRING object>}, <class 'scapy.layers.x509.X509_Extension'>: {'extnID': <scapy.asn1fields.ASN1F_OID object>, 'critical': <scapy.asn1fields.ASN1F_BOOLEAN object>, 'extnValue': <scapy.asn1fields.ASN1F_PACKET object>}, <class 'scapy.layers.x509.X509_TBSCertificate'>: {'version': <scapy.asn1fields.ASN1F_enum_INTEGER object>, 'serialNumber': <scapy.asn1fields.ASN1F_INTEGER object>, 'signature': <scapy.asn1fields.ASN1F_PACKET object>, 'issuer': <ASN1F_SEQUENCE_OF issuer>, 'validity': <scapy.asn1fields.ASN1F_PACKET object>, 'subject': <ASN1F_SEQUENCE_OF subject>, 'subjectPublicKeyInfo': <scapy.asn1fields.ASN1F_PACKET object>, 'issuerUniqueID': <scapy.asn1fields.ASN1F_BIT_STRING object>, 'subjectUniqueID': <scapy.asn1fields.ASN1F_BIT_STRING object>, 'extensions': <ASN1F_SEQUENCE_OF extensions>}, <class 'scapy.layers.x509.X509_TBSCertList'>: {'version': <scapy.asn1fields.ASN1F_enum_INTEGER object>, 'signature': <scapy.asn1fields.ASN1F_PACKET object>, 'issuer': <ASN1F_SEQUENCE_OF issuer>, 'this_update': <scapy.asn1fields.ASN1F_UTC_TIME object>, 'next_update': <scapy.asn1fields.ASN1F_UTC_TIME object>, 'revokedCertificates': <ASN1F_SEQUENCE_OF revokedCertificates>, 'crlExtensions': <ASN1F_SEQUENCE_OF crlExtensions>}, <class 'scapy.layers.x509.OCSP_GoodInfo'>: {'info': <scapy.asn1fields.ASN1F_NULL object>}, <class 'scapy.layers.x509.OCSP_RevokedInfo'>: {'revocationTime': <scapy.asn1fields.ASN1F_GENERALIZED_TIME object>, 'revocationReason': <scapy.asn1fields.ASN1F_PACKET object>}, <class 'scapy.layers.x509.OCSP_UnknownInfo'>: {'info': <scapy.asn1fields.ASN1F_NULL object>}, <class 'scapy.layers.x509.OCSP_CertID'>: {'hashAlgorithm': <scapy.asn1fields.ASN1F_PACKET object>, 'issuerNameHash': <scapy.asn1fields.ASN1F_STRING object>, 'issuerKeyHash': <scapy.asn1fields.ASN1F_STRING object>, 'serialNumber': <scapy.asn1fields.ASN1F_INTEGER object>}, <class 'scapy.layers.x509.OCSP_CertStatus'>: {'certStatus': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.OCSP_ByName'>: {'byName': <ASN1F_SEQUENCE_OF byName>}, <class 'scapy.layers.x509.OCSP_ByKey'>: {'byKey': <scapy.asn1fields.ASN1F_STRING object>}, <class 'scapy.layers.x509.OCSP_ResponderID'>: {'responderID': <scapy.asn1fields.ASN1F_CHOICE object>}, <class 'scapy.layers.x509.OCSP_ResponseData'>: {'version': <scapy.asn1fields.ASN1F_enum_INTEGER object>, 'responderID': <scapy.asn1fields.ASN1F_PACKET object>, 'producedAt': <scapy.asn1fields.ASN1F_GENERALIZED_TIME object>, 'responses': <ASN1F_SEQUENCE_OF responses>, 'responseExtensions': <ASN1F_SEQUENCE_OF responseExtensions>}, <class 'scapy.contrib.loraphy2wan.LinkADRAns_Status'>: {'RFU': <Field (LinkADRAns_Status).RFU>, 'PowerACK': <Field (LinkADRAns_Status).PowerACK>, 'DataRate': <Field (LinkADRAns_Status).DataRate>, 'ChannelMaskACK': <Field (LinkADRAns_Status).ChannelMaskACK>}, <class 'scapy.contrib.oncrpc.Object_Name'>: {'length': <Field (Object_Name).length>, '_name': <Field (Object_Name)._name>, 'fill': <Field (Object_Name).fill>}, <class 'scapy.contrib.oncrpc.Auth_Unix'>: {'stamp': <Field (Auth_Unix).stamp>, 'mname': <Field (Auth_Unix).mname>, 'uid': <Field (Auth_Unix).uid>, 'gid': <Field (Auth_Unix).gid>, 'num_auxgids': <Field (Auth_Unix).num_auxgids>, 'auxgids': <Field (Auth_Unix).auxgids>}, <class 'scapy.contrib.nfs.Fattr3'>: {'type': <Field (Fattr3).type>, 'mode': <Field (Fattr3).mode>, 'nlink': <Field (Fattr3).nlink>, 'uid': <Field (Fattr3).uid>, 'gid': <Field (Fattr3).gid>, 'size': <Field (Fattr3).size>, 'used': <Field (Fattr3).used>, 'rdev': <Field (Fattr3).rdev>, 'fsid': <Field (Fattr3).fsid>, 'fileid': <Field (Fattr3).fileid>, 'atime_s': <Field (Fattr3).atime_s>, 'atime_ns': <Field (Fattr3).atime_ns>, 'mtime_s': <Field (Fattr3).mtime_s>, 'mtime_ns': <Field (Fattr3).mtime_ns>, 'ctime_s': <Field (Fattr3).ctime_s>, 'ctime_ns': <Field (Fattr3).ctime_ns>}, <class 'scapy.contrib.nfs.File_Object'>: {'length': <Field (File_Object).length>, 'fh': <Field (File_Object).fh>, 'fill': <Field (File_Object).fill>}, <class 'scapy.contrib.nfs.WCC_Attr'>: {'size': <Field (WCC_Attr).size>, 'mtime_s': <Field (WCC_Attr).mtime_s>, 'mtime_ns': <Field (WCC_Attr).mtime_ns>, 'ctime_s': <Field (WCC_Attr).ctime_s>, 'ctime_ns': <Field (WCC_Attr).ctime_ns>}, <class 'scapy.contrib.nfs.Sattr3'>: {'set_mode': <Field (Sattr3).set_mode>, 'mode': <scapy.fields.ConditionalField object>, 'set_uid': <Field (Sattr3).set_uid>, 'uid': <scapy.fields.ConditionalField object>, 'set_gid': <Field (Sattr3).set_gid>, 'gid': <scapy.fields.ConditionalField object>, 'set_size': <Field (Sattr3).set_size>, 'size': <scapy.fields.ConditionalField object>, 'set_atime': <Field (Sattr3).set_atime>, 'atime_s': <scapy.fields.ConditionalField object>, 'atime_ns': <scapy.fields.ConditionalField object>, 'set_mtime': <Field (Sattr3).set_mtime>, 'mtime_s': <scapy.fields.ConditionalField object>, 'mtime_ns': <scapy.fields.ConditionalField object>}, <class 'scapy.contrib.mount.Path'>: {'length': <Field (Path).length>, 'path': <Field (Path).path>, 'fill': <Field (Path).fill>}, <class 'scapy.contrib.nlm.NLM4_Cookie'>: {'length': <Field (NLM4_Cookie).length>, 'contents': <Field (NLM4_Cookie).contents>, 'fill': <Field (NLM4_Cookie).fill>}, <class 'scapy.layers.dot15d4.Dot15d4AuxSecurityHeader'>: {'sec_sc_reserved': <Field (Dot15d4AuxSecurityHeader).sec_sc_reserved>, 'sec_sc_keyidmode': <Field (Dot15d4AuxSecurityHeader).sec_sc_keyidmode>, 'sec_sc_seclevel': <Field (Dot15d4AuxSecurityHeader).sec_sc_seclevel>, 'sec_framecounter': <Field (Dot15d4AuxSecurityHeader).sec_framecounter>, 'sec_keyid_keysource': <scapy.fields.ConditionalField object>, 'sec_keyid_keyindex': <scapy.fields.ConditionalField object>}}¶
-
class_packetfields
= {<class 'scapy.layers.x509.ECFieldID'>: [], <class 'scapy.layers.x509.ECCurve'>: [], <class 'scapy.layers.x509.X509_AttributeValue'>: [<scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.X509_AttributeTypeAndValue'>: [<scapy.layers.x509.ASN1F_X509_DirectoryString object>], <class 'scapy.layers.x509.X509_RDN'>: [<ASN1F_SET_OF rdn>], <class 'scapy.layers.x509.X509_DirectoryName'>: [<ASN1F_SEQUENCE_OF directoryName>], <class 'scapy.layers.x509.X509_Attribute'>: [<ASN1F_SET_OF values>], <class 'scapy.layers.x509.X509_GeneralName'>: [<scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.X509_ExtDistributionPointName'>: [<scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.X509_ExtPolicyInformation'>: [<ASN1F_SEQUENCE_OF policyQualifiers>], <class 'scapy.layers.x509.X509_ExtDistributionPoint'>: [<scapy.asn1fields.ASN1F_PACKET object>, <ASN1F_SEQUENCE_OF cRLIssuer>], <class 'scapy.layers.x509.X509_AccessDescription'>: [<scapy.asn1fields.ASN1F_PACKET object>], <class 'scapy.layers.x509.X509_ExtQcStatement'>: [], <class 'scapy.layers.x509.X509_ExtBasicConstraints'>: [], <class 'scapy.layers.x509.X509_AlgorithmIdentifier'>: [<scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.RSAPrivateKey'>: [<ASN1F_SEQUENCE_OF otherPrimeInfos>], <class 'scapy.layers.x509.ECParameters'>: [<scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.ECDSAPrivateKey'>: [<scapy.asn1fields.ASN1F_PACKET object>, <scapy.asn1fields.ASN1F_PACKET object>], <class 'scapy.layers.x509.X509_Validity'>: [<scapy.asn1fields.ASN1F_CHOICE object>, <scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.X509_SubjectPublicKeyInfo'>: [<scapy.asn1fields.ASN1F_PACKET object>], <class 'scapy.layers.x509.X509_Extension'>: [<scapy.asn1fields.ASN1F_PACKET object>], <class 'scapy.layers.x509.X509_TBSCertificate'>: [<scapy.asn1fields.ASN1F_PACKET object>, <ASN1F_SEQUENCE_OF issuer>, <scapy.asn1fields.ASN1F_PACKET object>, <ASN1F_SEQUENCE_OF subject>, <scapy.asn1fields.ASN1F_PACKET object>, <ASN1F_SEQUENCE_OF extensions>], <class 'scapy.layers.x509.X509_TBSCertList'>: [<scapy.asn1fields.ASN1F_PACKET object>, <ASN1F_SEQUENCE_OF issuer>, <ASN1F_SEQUENCE_OF revokedCertificates>, <ASN1F_SEQUENCE_OF crlExtensions>], <class 'scapy.layers.x509.OCSP_GoodInfo'>: [], <class 'scapy.layers.x509.OCSP_RevokedInfo'>: [<scapy.asn1fields.ASN1F_PACKET object>], <class 'scapy.layers.x509.OCSP_UnknownInfo'>: [], <class 'scapy.layers.x509.OCSP_CertID'>: [<scapy.asn1fields.ASN1F_PACKET object>], <class 'scapy.layers.x509.OCSP_CertStatus'>: [<scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.OCSP_ByName'>: [<ASN1F_SEQUENCE_OF byName>], <class 'scapy.layers.x509.OCSP_ByKey'>: [], <class 'scapy.layers.x509.OCSP_ResponderID'>: [<scapy.asn1fields.ASN1F_CHOICE object>], <class 'scapy.layers.x509.OCSP_ResponseData'>: [<scapy.asn1fields.ASN1F_PACKET object>, <ASN1F_SEQUENCE_OF responses>, <ASN1F_SEQUENCE_OF responseExtensions>], <class 'scapy.contrib.loraphy2wan.LinkADRAns_Status'>: [], <class 'scapy.contrib.oncrpc.Object_Name'>: [], <class 'scapy.contrib.oncrpc.Auth_Unix'>: [<Field (Auth_Unix).mname>], <class 'scapy.contrib.nfs.Fattr3'>: [], <class 'scapy.contrib.nfs.File_Object'>: [], <class 'scapy.contrib.nfs.WCC_Attr'>: [], <class 'scapy.contrib.nfs.Sattr3'>: [], <class 'scapy.contrib.mount.Path'>: [], <class 'scapy.contrib.nlm.NLM4_Cookie'>: [], <class 'scapy.layers.dot15d4.Dot15d4AuxSecurityHeader'>: []}¶
-
clear_cache
()¶ Clear the raw packet cache for the field and all its subfields
-
clone_with
(payload=None, share_time=False, **kargs)¶
-
command
()¶ Returns a string representing the command you have to type to obtain the same packet
-
classmethod
convert_packet
(pkt, **kwargs)¶ Converts another packet to be this type.
This is not guaranteed to be a lossless process.
- Parameters
pkt (scapy.packet.Packet) – The packet to convert.
- Returns
Converted form of the packet.
- Return type
cls
- Raises
TypeError – When conversion is not possible
-
classmethod
convert_packets
(pkts, **kwargs)¶ Converts many packets to this type.
This is implemented as a generator.
See
Packet.convert_packet
.
-
convert_to
(other_cls, **kwargs)¶ Converts this Packet to another type.
This is not guaranteed to be a lossless process.
By default, this only implements conversion to
Raw
.- Parameters
other_cls (Type[scapy.packet.Packet]) – Reference to a Packet class to convert to.
- Returns
Converted form of the packet.
- Return type
other_cls
- Raises
TypeError – When conversion is not possible
-
copy
()¶ Returns a deep copy of the instance.
-
copy_field_value
(fieldname, value)¶
-
copy_fields_dict
(fields)¶
-
decode_payload_as
(cls)¶ Reassembles the payload and decode it using another packet class
-
default_fields
¶
-
default_payload_class
(payload)¶ DEV: Returns the default payload class if nothing has been found by the guess_payload_class() method.
- Parameters
payload (str) – the layer’s payload
- Returns
the default payload class define inside the configuration file
-
delfieldval
(attr)¶
-
deprecated_fields
= {}¶
-
direction
¶
-
display
(*args, **kargs)¶ Deprecated. Use show() method.
-
dissect
(s)¶
-
dissection_done
(pkt)¶ DEV: will be called after a dissection is completed
-
do_build
()¶ Create the default version of the layer
- Returns
a string of the packet with the payload
-
do_build_payload
()¶ Create the default version of the payload layer
- Returns
a string of payload layer
-
do_build_ps
()¶
-
do_dissect
(s)¶
-
do_dissect_payload
(s)¶ Perform the dissection of the layer’s payload
- Parameters
s (str) – the raw layer
-
do_init_cached_fields
()¶ Initialize each fields of the fields_desc dict, or use the cached fields information
-
do_init_fields
(flist)¶ Initialize each fields of the fields_desc dict
-
explicit
¶
-
extract_padding
(s)¶ DEV: to be overloaded to extract current layer’s padding.
- Parameters
s (str) – the current layer
- Returns
a couple of strings (actual layer, padding)
-
fields
¶
-
fields_desc
¶
-
fieldtype
¶
-
firstlayer
()¶
-
fragment
(*args, **kargs)¶
-
classmethod
from_hexcap
()¶
-
get_field
(fld)¶ DEV: returns the field instance from the name of the field
-
getfield_and_val
(attr)¶
-
getfieldval
(attr)¶
-
getlayer
(cls, nb=1, _track=None, _subclass=None, **flt)¶ Return the nb^th layer that is an instance of cls, matching flt values.
-
guess_payload_class
(payload)¶ DEV: Guesses the next payload class from layer bonds. Can be overloaded to use a different mechanism.
- Parameters
payload (str) – the layer’s payload
- Returns
the payload class
-
hashret
()¶ DEV: returns a string that has the same value for a request and its answer.
-
haslayer
(cls, _subclass=None)¶ true if self has a layer that is an instance of cls. Superseded by “cls in self” syntax.
-
hide_defaults
()¶ Removes fields’ values that are the same as default values.
-
init_fields
()¶ Initialize each fields of the fields_desc dict
-
iterpayloads
()¶ Used to iter through the payloads of a Packet. Useful for DNS or 802.11 for instance.
-
lastlayer
(layer=None)¶ Returns the uppest layer of the packet
-
layers
()¶ returns a list of layer classes (including subclasses) in this packet
-
classmethod
lower_bonds
()¶
-
match_subclass
= False¶
-
mysummary
()¶ DEV: can be overloaded to return a string that summarizes the layer. Only one mysummary() is used in a whole packet summary: the one of the upper layer, # noqa: E501 except if a mysummary() also returns (as a couple) a list of layers whose # noqa: E501 mysummary() must be called if they are present.
-
name
¶
-
original
¶
-
overload_fields
¶
-
overloaded_fields
¶
-
packetfields
¶
-
payload
¶
-
payload_guess
¶
-
post_build
(pkt, pay)¶ DEV: called right after the current layer is build.
- Parameters
pkt (str) – the current packet (build by self_buil function)
pay (str) – the packet payload (build by do_build_payload function)
- Returns
a string of the packet with the payload
-
post_dissect
(s)¶ DEV: is called right after the current layer has been dissected
-
post_dissection
(pkt)¶ DEV: is called after the dissection of the whole packet
-
post_transforms
¶
-
pre_dissect
(s)¶ DEV: is called right before the current layer is dissected
-
prepare_cached_fields
(flist)¶ Prepare the cached fields of the fields_desc dict
-
raw_packet_cache
¶
-
raw_packet_cache_fields
¶
-
remove_payload
()¶
-
remove_underlayer
(other)¶
-
route
()¶
-
self_build
(field_pos_list=None)¶ Create the default layer regarding fields_desc dict
- Parameters
field_pos_list –
-
sent_time
¶
-
setfieldval
(attr, val)¶
-
show
(dump=False, indent=3, lvl='', label_lvl='')¶ Prints or returns (when “dump” is true) a hierarchical view of the packet.
- Parameters
dump – determine if it prints or returns the string value
indent (int) – the size of indentation for each layer
lvl (str) – additional information about the layer lvl
label_lvl (str) – additional information about the layer fields
- Returns
return a hierarchical view if dump, else print it
-
show2
(dump=False, indent=3, lvl='', label_lvl='')¶ Prints or returns (when “dump” is true) a hierarchical view of an assembled version of the packet, so that automatic fields are calculated (checksums, etc.)
- Parameters
dump – determine if it prints or returns the string value
indent (int) – the size of indentation for each layer
lvl (str) – additional information about the layer lvl
label_lvl (str) – additional information about the layer fields
- Returns
return a hierarchical view if dump, else print it
-
show_indent
= 1¶
-
show_summary
= True¶
-
sniffed_on
¶
-
sprintf
(format[, relax=1]) → str¶ Where format is a string that can include directives. A directive begins and ends by % and has the following format:
%[fmt[r],][cls[:nb].]field%
- Parameters
fmt –
is a classic printf directive, “r” can be appended for raw substitution: (ex: IP.flags=0x18 instead of SA), nb is the number of the layer (ex: for IP/IP packets, IP:2.src is the src of the upper IP layer). Special case : “%.time%” is the creation time. Ex:
p.sprintf( "%.time% %-15s,IP.src% -> %-15s,IP.dst% %IP.chksum% " "%03xr,IP.proto% %r,TCP.flags%" )
Moreover, the format string can include conditional statements. A conditional statement looks like : {layer:string} where layer is a layer name, and string is the string to insert in place of the condition if it is true, i.e. if layer is present. If layer is preceded by a “!”, the result is inverted. Conditions can be imbricated. A valid statement can be:
p.sprintf("This is a{TCP: TCP}{UDP: UDP}{ICMP:n ICMP} packet") p.sprintf("{IP:%IP.dst% {ICMP:%ICMP.type%}{TCP:%TCP.dport%}}")
A side effect is that, to obtain “{” and “}” characters, you must use “%(” and “%)”.
-
summary
(intern=0)¶ Prints a one line summary of a packet.
-
time
¶
-
underlayer
¶
-
update_sent_time
(time)¶ Use by clone_with to share the sent_time value
-
classmethod
upper_bonds
()¶
-
wirelen
¶
-
-
class
scapy.packet.
Padding
(*args, **kargs)¶ Bases:
scapy.packet.Raw
-
aliastypes
¶
-
build_padding
()¶
-
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LOAD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. Padding
Padding fields¶ load
b''
-
self_build
()¶
-
-
class
scapy.packet.
Raw
(*args, **kargs)¶ Bases:
scapy.packet.Packet
-
aliastypes
¶
-
answers
(other)¶
-
classmethod
convert_packet
(pkt, **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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LOAD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. Raw
Raw fields¶ load
b''
-
mysummary
()¶
-
-
class
scapy.packet.
RawVal
(val='')¶ Bases:
object
-
scapy.packet.
bind_bottom_up
(lower, upper, __fval=None, **fval)¶ Bind 2 layers for dissection. The upper layer will be chosen for dissection on top of the lower layer, if ALL the passed arguments are validated. If multiple calls are made with the same layers, the last one will be used as default.
- ex:
>>> bind_bottom_up(Ether, SNAP, type=0x1234) >>> Ether(b'\xff\xff\xff\xff\xff\xff\xd0P\x99V\xdd\xf9\x124\x00\x00\x00\x00\x00') # noqa: E501 <Ether dst=ff:ff:ff:ff:ff:ff src=d0:50:99:56:dd:f9 type=0x1234 |<SNAP OUI=0x0 code=0x0 |>> # noqa: E501
-
scapy.packet.
bind_layers
(lower, upper, __fval=None, **fval)¶ Bind 2 layers on some specific fields’ values.
It makes the packet being built and dissected when the arguments are present.
This function calls both bind_bottom_up and bind_top_down, with all passed arguments.
- Please have a look at their docs:
help(bind_bottom_up)
help(bind_top_down)
-
scapy.packet.
bind_top_down
(lower, upper, __fval=None, **fval)¶ Bind 2 layers for building. When the upper layer is added as a payload of the lower layer, all the arguments will be applied to them.
- ex:
>>> bind_top_down(Ether, SNAP, type=0x1234) >>> Ether()/SNAP() <Ether type=0x1234 |<SNAP |>>
-
scapy.packet.
explore
(layer=None)¶ Function used to discover the Scapy layers and protocols. It helps to see which packets exists in contrib or layer files.
- params:
- layer: If specified, the function will explore the layer. If not,
the GUI mode will be activated, to browse the available layers
Examples
>>> explore() # Launches the GUI >>> explore("dns") # Explore scapy.layers.dns >>> explore("http2") # Explore scapy.contrib.http2 >>> explore(scapy.layers.bluetooth4LE)
Note: to search a packet by name, use ls(“name”) rather than explore.
-
scapy.packet.
fuzz
(p, _inplace=0)¶ Transform a layer into a fuzzy layer by replacing some default values by random objects.
- Parameters
p – the Packet instance to fuzz
- Returns
the fuzzed packet.
-
scapy.packet.
ls
(obj=None, case_sensitive=False, verbose=False)¶ List available layers, or infos on a given layer class or name.
- Parameters
obj – Packet / packet name to use
case_sensitive – if obj is a string, is it case sensitive?
verbose –
-
scapy.packet.
rfc
(cls, ret=False, legend=True)¶ Generate an RFC-like representation of a packet def.
- Parameters
cls – the Packet class
ret – return the result instead of printing (def. False)
legend – show text under the diagram (default True)
Ex:
>>> rfc(Ether)
-
scapy.packet.
split_bottom_up
(lower, upper, __fval=None, **fval)¶ This call un-links an association that was made using bind_bottom_up. Have a look at help(bind_bottom_up)
-
scapy.packet.
split_layers
(lower, upper, __fval=None, **fval)¶ Split 2 layers previously bound. This call un-links calls bind_top_down and bind_bottom_up. It is the opposite of # noqa: E501 bind_layers.
- Please have a look at their docs:
help(split_bottom_up)
help(split_top_down)
-
scapy.packet.
split_top_down
(lower, upper, __fval=None, **fval)¶ This call un-links an association that was made using bind_top_down. Have a look at help(bind_top_down)