scapy.layers.dns

DNS: Domain Name System.

class scapy.layers.dns.ClientSubnetv4(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[源代码]

基类:StrLenField

af_default = b'\xc0'
af_familly = 2
af_length = 32
getfield(pkt: Packet, s: bytes) Tuple[bytes, I][源代码]
i2len(pkt: Packet, x: Any) int[源代码]
i2m(pkt: Packet | None, x: str | Net | None) bytes[源代码]
m2i(pkt: Packet | None, x: bytes) str[源代码]
class scapy.layers.dns.ClientSubnetv6(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[源代码]

基类:ClientSubnetv4

af_default = b' '
af_familly = 10
af_length = 128
class scapy.layers.dns.DNS(_pkt, /, *, length=None, id=0, qr=0, opcode=0, aa=0, tc=0, rd=1, ra=0, z=0, ad=0, cd=0, rcode=0, qdcount=None, ancount=None, nscount=None, arcount=None, qd=[<DNSQR  |>], an=[], ns=[], ar=[])[源代码]

基类:DNSCompressedPacket

aliastypes
answers(other)[源代码]
compress()[源代码]

Return the compressed DNS packet (using dns_compress())

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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             LENGTH            |               ID              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Q| OPCODE|A|T|R|R|Z|A|C| RCODE |            QDCOUNT            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            ANCOUNT            |            NSCOUNT            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            ARCOUNT            |               QD              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               AN              |               NS              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               AR              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                             Fig. DNS                             
DNS fields

length

ShortField (Cond)

None

id

ShortField

0

qr

BitField (1 bit)

0

opcode

BitEnumField

0

aa

BitField (1 bit)

0

tc

BitField (1 bit)

0

rd

BitField (1 bit)

1

ra

BitField (1 bit)

0

z

BitField (1 bit)

0

ad

BitField (1 bit)

0

cd

BitField (1 bit)

0

rcode

BitEnumField

0

qdcount

FieldLenField

None

ancount

FieldLenField

None

nscount

FieldLenField

None

arcount

FieldLenField

None

qd

_DNSPacketListField

[<DNSQR  |>]

an

_DNSPacketListField

[]

ns

_DNSPacketListField

[]

ar

_DNSPacketListField

[]

get_full()[源代码]
mysummary()[源代码]
post_build(pkt, pay)[源代码]
pre_dissect(s)[源代码]

Check that a valid DNS over TCP message can be decoded

class scapy.layers.dns.DNSCompressedPacket(_pkt, /)[源代码]

基类:Packet

Class to mark that a packet contains DNSStrField and supports compression

aliastypes
abstract get_full()[源代码]
class scapy.layers.dns.DNSQR(_pkt, /, *, qname=b'www.example.com.', qtype=1, qclass=1)[源代码]

基类:Packet

aliastypes
default_payload_class(payload)[源代码]
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             QNAME             |             QTYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             QCLASS            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                            Fig. DNSQR                            
DNSQR fields

qname

DNSStrField

b'www.example.com.'

qtype

ShortEnumField

1

qclass

ShortEnumField

1

show_indent = 0
class scapy.layers.dns.DNSRR(_pkt, /, *, rrname=b'.', type=1, rclass=1, ttl=0, rdlen=None, rdata=None)[源代码]

基类:Packet

aliastypes
default_payload_class(payload)[源代码]
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RDATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                            Fig. DNSRR                            
DNSRR fields

rrname

DNSStrField

b'.'

type

ShortEnumField

1

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

FieldLenField

None

rdata

MultipleTypeField (IPField, IP6Field, DNSStrField, DNSTextField, StrLenField)

b''

show_indent = 0
class scapy.layers.dns.DNSRRDLV(_pkt, /, *, rrname=b'.', type=43, rclass=1, ttl=0, rdlen=None, keytag=0, algorithm=5, digesttype=5, digest=b'')[源代码]

基类:DNSRRDS

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             KEYTAG            |   ALGORITHM   |   DIGESTTYPE  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             DIGEST            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. DNSRRDLV                           
DNSRRDLV fields

rrname

DNSStrField

b'.'

type

ShortEnumField

43

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

keytag

ShortField

0

algorithm

ByteEnumField

5

digesttype

ByteEnumField

5

digest

StrField

b''

class scapy.layers.dns.DNSRRDNSKEY(_pkt, /, *, rrname=b'.', type=48, rclass=1, ttl=0, rdlen=None, flags=<Flag 256 (Z)>, protocol=3, algorithm=5, publickey=b'')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             FLAGS             |    PROTOCOL   |   ALGORITHM   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           PUBLICKEY           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. DNSRRDNSKEY                         
DNSRRDNSKEY fields

rrname

DNSStrField

b'.'

type

ShortEnumField

48

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

flags

FlagsField

<Flag 256 (Z)>

protocol

ByteField

3

algorithm

ByteEnumField

5

publickey

StrField

b''

class scapy.layers.dns.DNSRRDS(_pkt, /, *, rrname=b'.', type=43, rclass=1, ttl=0, rdlen=None, keytag=0, algorithm=5, digesttype=5, digest=b'')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             KEYTAG            |   ALGORITHM   |   DIGESTTYPE  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             DIGEST            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                           Fig. DNSRRDS                           
DNSRRDS fields

rrname

DNSStrField

b'.'

type

ShortEnumField

43

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

keytag

ShortField

0

algorithm

ByteEnumField

5

digesttype

ByteEnumField

5

digest

StrField

b''

class scapy.layers.dns.DNSRRMX(_pkt, /, *, rrname=b'.', type=6, rclass=1, ttl=0, rdlen=None, preference=0, exchange=b'.')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           PREFERENCE          |            EXCHANGE           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                           Fig. DNSRRMX                           
DNSRRMX fields

rrname

DNSStrField

b'.'

type

ShortEnumField

6

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

preference

ShortField

0

exchange

DNSStrField

b'.'

class scapy.layers.dns.DNSRRNSEC(_pkt, /, *, rrname=b'.', type=47, rclass=1, ttl=0, rdlen=None, nextname=b'.', typebitmaps=b'')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            NEXTNAME           |          TYPEBITMAPS          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. DNSRRNSEC                          
DNSRRNSEC fields

rrname

DNSStrField

b'.'

type

ShortEnumField

47

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

nextname

DNSStrField

b'.'

typebitmaps

RRlistField

b''

class scapy.layers.dns.DNSRRNSEC3(_pkt, /, *, rrname=b'.', type=50, rclass=1, ttl=0, rdlen=None, hashalg=0, flags=0, iterations=0, saltlength=0, salt=b'', hashlength=0, nexthashedownername=b'', typebitmaps=b'')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    HASHALG    |     FLAGS     |           ITERATIONS          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   SALTLENGTH  |              SALT             |   HASHLENGTH  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      NEXTHASHEDOWNERNAME      |          TYPEBITMAPS          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. DNSRRNSEC3                          
DNSRRNSEC3 fields

rrname

DNSStrField

b'.'

type

ShortEnumField

50

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

hashalg

ByteField

0

flags

BitEnumField

0

iterations

ShortField

0

saltlength

FieldLenField

0

salt

StrLenField

b''

hashlength

FieldLenField

0

nexthashedownername

StrLenField

b''

typebitmaps

RRlistField

b''

class scapy.layers.dns.DNSRRNSEC3PARAM(_pkt, /, *, rrname=b'.', type=51, rclass=1, ttl=0, rdlen=None, hashalg=0, flags=0, iterations=0, saltlength=0, salt=b'')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    HASHALG    |     FLAGS     |           ITERATIONS          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   SALTLENGTH  |              SALT             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. DNSRRNSEC3PARAM                       
DNSRRNSEC3PARAM fields

rrname

DNSStrField

b'.'

type

ShortEnumField

51

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

hashalg

ByteField

0

flags

ByteField

0

iterations

ShortField

0

saltlength

FieldLenField

0

salt

StrLenField

b''

class scapy.layers.dns.DNSRROPT(_pkt, /, *, rrname=b'.', type=41, rclass=4096, extrcode=0, version=0, z=32768, rdlen=None, rdata=[])[源代码]

基类:Packet

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |    EXTRCODE   |    VERSION    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               Z               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RDATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. DNSRROPT                           
DNSRROPT fields

rrname

DNSStrField

b'.'

type

ShortEnumField

41

rclass

ShortField

4096

extrcode

ByteField

0

version

ByteField

0

z

BitEnumField

32768

rdlen

FieldLenField

None

rdata

PacketListField

[]

class scapy.layers.dns.DNSRRRSIG(_pkt, /, *, rrname=b'.', type=46, rclass=1, ttl=0, rdlen=None, typecovered=1, algorithm=5, labels=0, originalttl=0, expiration=0, inception=0, keytag=0, signersname=b'.', signature=b'')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          TYPECOVERED          |   ALGORITHM   |     LABELS    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          ORIGINALTTL                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           EXPIRATION                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           INCEPTION                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             KEYTAG            |          SIGNERSNAME          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           SIGNATURE           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. DNSRRRSIG                          
DNSRRRSIG fields

rrname

DNSStrField

b'.'

type

ShortEnumField

46

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

typecovered

ShortEnumField

1

algorithm

ByteEnumField

5

labels

ByteField

0

originalttl

IntField

0

expiration

UTCTimeField

0

inception

UTCTimeField

0

keytag

ShortField

0

signersname

DNSStrField

b'.'

signature

StrField

b''

class scapy.layers.dns.DNSRRSOA(_pkt, /, *, rrname=b'.', type=6, rclass=1, ttl=0, rdlen=None, mname=b'.', rname=b'.', serial=0, refresh=0, retry=0, expire=0, minimum=0)[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             MNAME             |             RNAME             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             SERIAL                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            REFRESH                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             RETRY                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             EXPIRE                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            MINIMUM                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. DNSRRSOA                           
DNSRRSOA fields

rrname

DNSStrField

b'.'

type

ShortEnumField

6

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

mname

DNSStrField

b'.'

rname

DNSStrField

b'.'

serial

IntField

0

refresh

IntField

0

retry

IntField

0

expire

IntField

0

minimum

IntField

0

class scapy.layers.dns.DNSRRSRV(_pkt, /, *, rrname=b'.', type=33, rclass=1, ttl=0, rdlen=None, priority=0, weight=0, port=0, target=b'.')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            PRIORITY           |             WEIGHT            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              PORT             |             TARGET            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. DNSRRSRV                           
DNSRRSRV fields

rrname

DNSStrField

b'.'

type

ShortEnumField

33

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

priority

ShortField

0

weight

ShortField

0

port

ShortField

0

target

DNSStrField

b'.'

class scapy.layers.dns.DNSRRTSIG(_pkt, /, *, rrname=b'.', type=250, rclass=1, ttl=0, rdlen=None, algo_name=b'hmac-sha1.', time_signed=0, fudge=0, mac_len=20, mac_data=b'', original_id=0, error=0, other_len=0, other_data=b'')[源代码]

基类:_DNSRRdummy

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RRNAME            |              TYPE             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             RCLASS            |              TTL              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |             RDLEN             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           ALGO NAME           |          TIME SIGNED          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             FUDGE             |            MAC LEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            MAC DATA           |          ORIGINAL ID          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             ERROR             |           OTHER LEN           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           OTHER DATA          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. DNSRRTSIG                          
DNSRRTSIG fields

rrname

DNSStrField

b'.'

type

ShortEnumField

250

rclass

ShortEnumField

1

ttl

IntField

0

rdlen

ShortField

None

algo_name

DNSStrField

b'hmac-sha1.'

time_signed

TimeSignedField

0

fudge

ShortField

0

mac_len

FieldLenField

20

mac_data

StrLenField

b''

original_id

ShortField

0

error

ShortField

0

other_len

FieldLenField

0

other_data

StrLenField

b''

class scapy.layers.dns.DNSStrField(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[源代码]

基类:StrLenField

Special StrField that handles DNS encoding/decoding. It will also handle DNS decompression. (may be StrLenField if a length_from is passed),

get_full(pkt)[源代码]
getfield(pkt, s)[源代码]
h2i(pkt, x)[源代码]
i2len(pkt, x)[源代码]
i2m(pkt, x)[源代码]
class scapy.layers.dns.DNSTextField(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[源代码]

基类:StrLenField

Special StrLenField that handles DNS TEXT data (16)

any2i(pkt, x)[源代码]
i2len(pkt, x)[源代码]
i2m(pkt, s)[源代码]
islist = 1
m2i(pkt, s)[源代码]
class scapy.layers.dns.DNS_am(self, joker=None, match=None, srvmatch=None, joker6=False, from_ip=None, from_ip6=None, src_ip=None, src_ip6=None, ttl=10)[源代码]

基类:AnsweringMachine

cls[源代码]

DNS 的别名

filter: str | None = 'udp port 53'
function_name = 'dns_spoof'
is_request(req)[源代码]
make_reply(req)[源代码]
optam0: Dict[str, Any]
optam1: Dict[str, Any]
optam2: Dict[str, Any]
optsend: Dict[str, Any]
optsniff: Dict[str, Any]
parse_options(joker=None, match=None, srvmatch=None, joker6=False, from_ip=None, from_ip6=None, src_ip=None, src_ip6=None, ttl=10)[源代码]
参数:
  • joker -- default IPv4 for unresolved domains. (Default: None) Set to False to disable, None to mirror the interface's IP.

  • joker6 -- default IPv6 for unresolved domains (Default: False) set to False to disable, None to mirror the interface's IPv6.

  • match -- a dictionary of {name: val} where name is a string representing a domain name (A, AAAA) and val is a tuple of 2 elements, each representing an IP or a list of IPs

  • srvmatch -- a dictionary of {name: (port, target)} used for SRV

  • from_ip -- an source IP to filter. Can contain a netmask

  • from_ip6 -- an source IPv6 to filter. Can contain a netmask

  • ttl -- the DNS time to live (in seconds)

  • src_ip --

  • src_ip6 --

示例

>>> dns_spoof(joker="192.168.0.2", iface="eth0")
>>> dns_spoof(match={
...     "_ldap._tcp.dc._msdcs.DOMAIN.LOCAL.": (389, "srv1.domain.local")
... })
scapy.layers.dns.DNSgetstr(*args, **kwargs)[源代码]

Legacy function. Deprecated

class scapy.layers.dns.EDNS0ClientSubnet(_pkt, /, *, optcode=8, optlen=None, family=1, source_plen=None, scope_plen=0, address=None)[源代码]

基类:Packet

aliastypes
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            OPTCODE            |             OPTLEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             FAMILY            |  SOURCE PLEN  |   SCOPE PLEN  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            ADDRESS            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Fig. EDNS0ClientSubnet                      
EDNS0ClientSubnet fields

optcode

ShortEnumField

8

optlen

FieldLenField

None

family

ShortField

1

source_plen

FieldLenField

None

scope_plen

ByteField

0

address

MultipleTypeField (ClientSubnetv4, ClientSubnetv6, ClientSubnetv4)

b'192.168.0.0'

class scapy.layers.dns.EDNS0TLV(_pkt, /, *, optcode=0, optlen=None, optdata=b'')[源代码]

基类:Packet

aliastypes
classmethod dispatch_hook(_pkt: bytes | None = None, *args: Any, **kargs: Any) Type[Packet][源代码]
extract_padding(p: bytes) Tuple[bytes, bytes | None][源代码]
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            OPTCODE            |             OPTLEN            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            OPTDATA            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. EDNS0TLV                           
EDNS0TLV fields

optcode

ShortEnumField

0

optlen

FieldLenField

None

optdata

StrLenField

b''

scapy.layers.dns.RRlist2bitmap(lst)[源代码]

Encode a list of integers representing Resource Records to a bitmap field used in the NSEC Resource Record.

class scapy.layers.dns.RRlistField(name: str, default: I | None, fmt: str = 'H', remain: int = 0)[源代码]

基类:StrField

h2i(pkt, x)[源代码]
i2repr(pkt, x)[源代码]
class scapy.layers.dns.TimeSignedField(name, default)[源代码]

基类:Field[int, bytes]

i2m(pkt, seconds)[源代码]

Convert the number of seconds since 1-Jan-70 UTC to the packed representation.

i2repr(pkt, packed_seconds)[源代码]

Convert the internal representation to a nice one using the RFC format.

m2i(pkt, packed_seconds)[源代码]

Convert the internal representation to the number of seconds since 1-Jan-70 UTC.

scapy.layers.dns.bitmap2RRlist(bitmap)[源代码]

Decode the 'Type Bit Maps' field of the NSEC Resource Record into an integer list.

scapy.layers.dns.dns_compress(pkt)[源代码]

This function compresses a DNS packet according to compression rules.

scapy.layers.dns.dns_encode(x, check_built=False)[源代码]

Encodes a bytes string into the DNS format

参数:
  • x -- the string

  • check_built -- detect already-built strings and ignore them

返回:

the encoded bytes string

scapy.layers.dns.dns_get_str(s, full=None, _ignore_compression=False)[源代码]

This function decompresses a string s, starting from the given pointer.

参数:
  • s -- the string to decompress

  • full -- (optional) the full packet (used for decompression)

返回:

(decoded_string, end_index, left_string)

scapy.layers.dns.dns_resolve(qname, qtype='A', raw=False, verbose=1, **kwargs)[源代码]

Perform a simple DNS resolution using conf.nameservers with caching

参数:
  • qname -- the name to query

  • qtype -- the type to query (default A)

  • raw -- return the whole DNS packet (default False)

scapy.layers.dns.dyndns_add(nameserver, name, rdata, type='A', ttl=10)[源代码]

Send a DNS add message to a nameserver for "name" to have a new "rdata" dyndns_add(nameserver, name, rdata, type="A", ttl=10) -> result code (0=ok)

example: dyndns_add("ns1.toto.com", "dyn.toto.com", "127.0.0.1") RFC2136

scapy.layers.dns.dyndns_del(nameserver, name, type='ALL', ttl=10)[源代码]

Send a DNS delete message to a nameserver for "name" dyndns_del(nameserver, name, type="ANY", ttl=10) -> result code (0=ok)

example: dyndns_del("ns1.toto.com", "dyn.toto.com") RFC2136