scapy.asn1fields

实现ASN.1数据结构的类.

class scapy.asn1fields.ASN1F_BIT_STRING(name, default, default_readable=True, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_field

ASN1_tag = <ASN1Tag BIT_STRING[3]>
randval()
class scapy.asn1fields.ASN1F_BIT_STRING_ENCAPS(name, default, cls, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_BIT_STRING

我们可以使用explicit_tag = 0x04来模拟简单的字符串封装,但是由于未使用的位等原因,我们需要一个特定的位字符串类.

holds_packets = 1
i2m(pkt, x)
m2i(pkt, s)
class scapy.asn1fields.ASN1F_BMP_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag BMP_STRING[30]>
class scapy.asn1fields.ASN1F_BOOLEAN(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_field

ASN1_tag = <ASN1Tag BOOLEAN[1]>
randval()
class scapy.asn1fields.ASN1F_CHOICE(name, default, *args, **kwargs)

Bases: scapy.asn1fields.ASN1F_field

允许使用多种类型:ASN1_Packet,ASN1F_field和ASN1F_PACKET(),有关示例,请参见layers / x509.py. 除ASN1F_PACKET实例外,不得使用其他ASN1F_field实例.

ASN1_tag = <ASN1Tag ANY[0]>
holds_packets = 1
i2m(pkt, x)
m2i(pkt, s)

首先,我们必须检索适当的选择. 然后,根据此选择提取字段/数据包.

randval()
class scapy.asn1fields.ASN1F_ENUMERATED(name, default, enum, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_enum_INTEGER

ASN1_tag = <ASN1Tag ENUMERATED[10]>
class scapy.asn1fields.ASN1F_FLAGS(name, default, mapping, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_BIT_STRING

get_flags(pkt)
i2repr(pkt, x)
class scapy.asn1fields.ASN1F_GENERALIZED_TIME(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag GENERALIZED_TIME[24]>
randval()
class scapy.asn1fields.ASN1F_IA5_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag IA5_STRING[22]>
class scapy.asn1fields.ASN1F_INTEGER(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_field

ASN1_tag = <ASN1Tag INTEGER[2]>
randval()
class scapy.asn1fields.ASN1F_IPADDRESS(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag IPADDRESS[64]>
class scapy.asn1fields.ASN1F_ISO646_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag ISO646_STRING[26]>
class scapy.asn1fields.ASN1F_NULL(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_INTEGER

ASN1_tag = <ASN1Tag NULL[5]>
class scapy.asn1fields.ASN1F_NUMERIC_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag NUMERIC_STRING[18]>
class scapy.asn1fields.ASN1F_OID(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_field

ASN1_tag = <ASN1Tag OID[6]>
randval()
class scapy.asn1fields.ASN1F_PACKET(name, default, cls, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_field

holds_packets = 1
i2m(pkt, x)
m2i(pkt, s)
randval()
class scapy.asn1fields.ASN1F_PRINTABLE_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag PRINTABLE_STRING[19]>
class scapy.asn1fields.ASN1F_SEQUENCE(*seq, **kwargs)

Bases: scapy.asn1fields.ASN1F_field

ASN1_tag = <ASN1Tag SEQUENCE[48]>
build(pkt)
dissect(pkt, s)
get_fields_list()
holds_packets = 1
is_empty(pkt)
m2i(pkt, s)

ASN1F_SEQUENCE的行为透明,嵌套的ASN1_object被一一剖析. 因为我们使用obj.dissect(请参见下面的循环)而不是obj.m2i(因为我们相信Dissect可以执行适当的set_vals),所以我们不直接检索嵌套对象的列表. 因此,m2i返回一个空列表(以及适当的余数). 它被dissect()丢弃,并且不应在其他地方丢失.

class scapy.asn1fields.ASN1F_SEQUENCE_OF(name, default, cls, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_field

ASN1_tag = <ASN1Tag SEQUENCE[48]>
build(pkt)
holds_packets = 1
is_empty(pkt)
islist = 1
m2i(pkt, s)
randval()
class scapy.asn1fields.ASN1F_SET(*seq, **kwargs)

Bases: scapy.asn1fields.ASN1F_SEQUENCE

ASN1_tag = <ASN1Tag SET[49]>
class scapy.asn1fields.ASN1F_SET_OF(name, default, cls, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_SEQUENCE_OF

ASN1_tag = <ASN1Tag SET[49]>
class scapy.asn1fields.ASN1F_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_field

ASN1_tag = <ASN1Tag STRING[4]>
randval()
class scapy.asn1fields.ASN1F_T61_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag T61_STRING[20]>
class scapy.asn1fields.ASN1F_TIME_TICKS(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_INTEGER

ASN1_tag = <ASN1Tag TIME_TICKS[67]>
class scapy.asn1fields.ASN1F_UNIVERSAL_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag UNIVERSAL_STRING[28]>
class scapy.asn1fields.ASN1F_UTC_TIME(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag UTC_TIME[23]>
randval()
class scapy.asn1fields.ASN1F_UTF8_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag UTF8_STRING[12]>
class scapy.asn1fields.ASN1F_VIDEOTEX_STRING(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_STRING

ASN1_tag = <ASN1Tag VIDEOTEX_STRING[21]>
exception scapy.asn1fields.ASN1F_badsequence

Bases: Exception

class scapy.asn1fields.ASN1F_element

Bases: object

class scapy.asn1fields.ASN1F_enum_INTEGER(name, default, enum, context=None, implicit_tag=None, explicit_tag=None)

Bases: scapy.asn1fields.ASN1F_INTEGER

i2m(pkt, s)
i2repr(pkt, x)
class scapy.asn1fields.ASN1F_field(name, default, context=None, implicit_tag=None, explicit_tag=None, flexible_tag=False)

Bases: scapy.asn1fields.ASN1F_element

ASN1_tag = <ASN1Tag ANY[0]>
any2i(pkt, x)
build(pkt)
context

scapy.asn1.asn1.ASN1_Class_UNIVERSAL别名

dissect(pkt, s)
do_copy(x)
extract_packet(cls, s)
get_fields_list()
holds_packets = 0
i2h(pkt, x)
i2m(pkt, x)
i2repr(pkt, x)
is_empty(pkt)
islist = 0
m2i(pkt, s)

safedec的好处是,即使预期标签(self.ASN1_tag)与实际标签不匹配,它仍然可以解码ASN1; 解码后的ASN1对象将被简单地放入ASN1_BADTAG对象. 但是,safedec可以防止引发ASN1F_optional处理所需的异常. 因此,我们使用'flexible_tag',对于ASN1F_optional,它应该为False.

关于其他字段,我们可能需要知道编码是否按预期进行. 值得注意的是,来自cert.py的输入法希望引发某些异常. 因此,默认的flexible_tag为False.

randval()
set_val(pkt, val)
class scapy.asn1fields.ASN1F_optional(field)

Bases: scapy.asn1fields.ASN1F_element

any2i(pkt, x)
build(pkt)
dissect(pkt, s)
i2repr(pkt, x)
m2i(pkt, s)