scapy.layers.dns
DNS: Domain Name System
This implements: - RFC1035: Domain Names - RFC6762: Multicast DNS - RFC6763: DNS-Based Service Discovery
- class scapy.layers.dns.ClientSubnetv4(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[source]
Bases:
StrLenField- af_default = b'\xc0'
- af_familly = 2
- af_length = 32
- class scapy.layers.dns.ClientSubnetv6(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[source]
Bases:
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=[])[source]
Bases:
DNSCompressedPacket- FORCE_TCP = False
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LENGTH | ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Q| OPCODE|A|T|R|R|Z|A|C| RCODE | QDCOUNT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ANCOUNT | NSCOUNT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ARCOUNT | QD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AN | NS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSDNS fields length
ShortField(Cond)Noneid
0qr
BitField(1 bit)0opcode
0aa
BitField(1 bit)0tc
BitField(1 bit)0rd
BitField(1 bit)1ra
BitField(1 bit)0z
BitField(1 bit)0ad
BitField(1 bit)0cd
BitField(1 bit)0rcode
0qdcount
Noneancount
Nonenscount
Nonearcount
Noneqd
_DNSPacketListField[<DNSQR |>]an
_DNSPacketListField[]ns
_DNSPacketListField[]ar
_DNSPacketListField[]
- class scapy.layers.dns.DNSCompressedPacket(_pkt, /)[source]
Bases:
PacketClass to mark that a packet contains DNSStrField and supports compression
- aliastypes
- class scapy.layers.dns.DNSQR(_pkt, /, *, qname=b'www.example.com.', qtype=1, unicastresponse=0, qclass=1)[source]
Bases:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | QNAME | QTYPE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |U| QCLASS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSQRDNSQR fields qname
b'www.example.com.'qtype
1unicastresponse
BitField(1 bit)0qclass
1
- show_indent = 0
- class scapy.layers.dns.DNSRR(_pkt, /, *, rrname=b'.', type=1, cacheflush=0, rclass=1, ttl=0, rdlen=None, rdata=None)[source]
Bases:
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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | RDATA | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRDNSRR fields rrname
b'.'type
1cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonerdata
MultipleTypeField(IPField, IP6Field, DNSStrField, DNSTextField, StrLenField)b''
- show_indent = 0
- class scapy.layers.dns.DNSRRDLV(_pkt, /, *, rrname=b'.', type=43, cacheflush=0, rclass=1, ttl=0, rdlen=None, keytag=0, algorithm=5, digesttype=5, digest=b'')[source]
Bases:
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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | KEYTAG | ALGORITHM | DIGESTTYPE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DIGEST | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRDLVDNSRRDLV fields rrname
b'.'type
43cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonekeytag
0algorithm
5digesttype
5digest
b''
- class scapy.layers.dns.DNSRRDNSKEY(_pkt, /, *, rrname=b'.', type=48, cacheflush=0, rclass=1, ttl=0, rdlen=None, flags=<Flag 256 (Z)>, protocol=3, algorithm=5, publickey=b'')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | FLAGS | PROTOCOL | ALGORITHM | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PUBLICKEY | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRDNSKEYDNSRRDNSKEY fields rrname
b'.'type
48cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Noneflags
<Flag 256 (Z)>protocol
3algorithm
5publickey
b''
- class scapy.layers.dns.DNSRRDS(_pkt, /, *, rrname=b'.', type=43, cacheflush=0, rclass=1, ttl=0, rdlen=None, keytag=0, algorithm=5, digesttype=5, digest=b'')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | KEYTAG | ALGORITHM | DIGESTTYPE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DIGEST | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRDSDNSRRDS fields rrname
b'.'type
43cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonekeytag
0algorithm
5digesttype
5digest
b''
- class scapy.layers.dns.DNSRRHINFO(_pkt, /, *, rrname=b'.', type=13, cacheflush=0, rclass=1, ttl=0, rdlen=None, cpulen=None, cpu=b'', oslen=None, os=b'')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CPULEN | CPU | OSLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | OS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRHINFODNSRRHINFO fields rrname
b'.'type
13cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonecpulen
Nonecpu
b''oslen
Noneos
b''
- class scapy.layers.dns.DNSRRHTTPS(_pkt, /, *, rrname=b'.', type=65, cacheflush=0, rclass=1, ttl=0, rdlen=None, svc_priority=0, target_name=b'.', svc_params=[])[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SVC PRIORITY | TARGET NAME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SVC PARAMS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRHTTPSDNSRRHTTPS fields rrname
b'.'type
65cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonesvc_priority
0target_name
b'.'svc_params
[]
- class scapy.layers.dns.DNSRRMX(_pkt, /, *, rrname=b'.', type=15, cacheflush=0, rclass=1, ttl=0, rdlen=None, preference=0, exchange=b'.')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PREFERENCE | EXCHANGE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRMXDNSRRMX fields rrname
b'.'type
15cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonepreference
0exchange
b'.'
- class scapy.layers.dns.DNSRRNAPTR(_pkt, /, *, rrname=b'.', type=35, cacheflush=0, rclass=1, ttl=0, rdlen=None, order=0, preference=0, flags_len=None, flags=b'', services_len=None, services=b'', regexp_len=None, regexp=b'', replacement=b'.')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ORDER | PREFERENCE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | FLAGS LEN | FLAGS | SERVICES LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SERVICES | REGEXP LEN | REGEXP | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | REPLACEMENT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRNAPTRDNSRRNAPTR fields rrname
b'.'type
35cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Noneorder
0preference
0flags_len
Noneflags
b''services_len
Noneservices
b''regexp_len
Noneregexp
b''replacement
b'.'
- class scapy.layers.dns.DNSRRNSEC(_pkt, /, *, rrname=b'.', type=47, cacheflush=0, rclass=1, ttl=0, rdlen=None, nextname=b'.', typebitmaps=[])[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NEXTNAME | TYPEBITMAPS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRNSECDNSRRNSEC fields rrname
b'.'type
47cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonenextname
b'.'typebitmaps
[]
- class scapy.layers.dns.DNSRRNSEC3(_pkt, /, *, rrname=b'.', type=50, cacheflush=0, rclass=1, ttl=0, rdlen=None, hashalg=0, flags=0, iterations=0, saltlength=0, salt=b'', hashlength=0, nexthashedownername=b'', typebitmaps=[])[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HASHALG | FLAGS | ITERATIONS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SALTLENGTH | SALT | HASHLENGTH | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NEXTHASHEDOWNERNAME | TYPEBITMAPS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRNSEC3DNSRRNSEC3 fields rrname
b'.'type
50cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonehashalg
0flags
0iterations
0saltlength
0salt
b''hashlength
0nexthashedownername
b''typebitmaps
[]
- class scapy.layers.dns.DNSRRNSEC3PARAM(_pkt, /, *, rrname=b'.', type=51, cacheflush=0, rclass=1, ttl=0, rdlen=None, hashalg=0, flags=0, iterations=0, saltlength=0, salt=b'')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | HASHALG | FLAGS | ITERATIONS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SALTLENGTH | SALT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRNSEC3PARAMDNSRRNSEC3PARAM fields rrname
b'.'type
51cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonehashalg
0flags
0iterations
0saltlength
0salt
b''
- class scapy.layers.dns.DNSRROPT(_pkt, /, *, rrname=b'.', type=41, rclass=4096, extrcode=0, version=0, z=32768, rdlen=None, rdata=[])[source]
Bases:
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. DNSRROPTDNSRROPT fields rrname
b'.'type
41rclass
4096extrcode
0version
0z
32768rdlen
Nonerdata
[]
- class scapy.layers.dns.DNSRRRSIG(_pkt, /, *, rrname=b'.', type=46, cacheflush=0, rclass=1, ttl=0, rdlen=None, typecovered=1, algorithm=5, labels=0, originalttl=0, expiration=0, inception=0, keytag=0, signersname=b'.', signature=b'')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | TYPECOVERED | ALGORITHM | LABELS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ORIGINALTTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | EXPIRATION | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | INCEPTION | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | KEYTAG | SIGNERSNAME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SIGNATURE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRRSIGDNSRRRSIG fields rrname
b'.'type
46cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonetypecovered
1algorithm
5labels
0originalttl
0expiration
0inception
0keytag
0signersname
b'.'signature
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)[source]
Bases:
_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. DNSRRSOADNSRRSOA fields rrname
b'.'type
6rclass
1ttl
0rdlen
Nonemname
b'.'rname
b'.'serial
0refresh
0retry
0expire
0minimum
0
- class scapy.layers.dns.DNSRRSRV(_pkt, /, *, rrname=b'.', type=33, cacheflush=0, rclass=1, ttl=0, rdlen=None, priority=0, weight=0, port=0, target=b'.')[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PRIORITY | WEIGHT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PORT | TARGET | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRSRVDNSRRSRV fields rrname
b'.'type
33cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonepriority
0weight
0port
0target
b'.'
- class scapy.layers.dns.DNSRRSVCB(_pkt, /, *, rrname=b'.', type=64, cacheflush=0, rclass=1, ttl=0, rdlen=None, svc_priority=0, target_name=b'.', svc_params=[])[source]
Bases:
_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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |C| RCLASS | TTL | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | RDLEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SVC PRIORITY | TARGET NAME | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SVC PARAMS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSRRSVCBDNSRRSVCB fields rrname
b'.'type
64cacheflush
BitField(1 bit)0rclass
1ttl
0rdlen
Nonesvc_priority
0target_name
b'.'svc_params
[]
- 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'')[source]
Bases:
_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. DNSRRTSIGDNSRRTSIG fields rrname
b'.'type
250rclass
1ttl
0rdlen
Nonealgo_name
b'hmac-sha1.'time_signed
0fudge
0mac_len
20mac_data
b''original_id
0error
0other_len
0other_data
b''
- class scapy.layers.dns.DNSSDResult(res=None, name='DNS-SD', stats=None)[source]
Bases:
SndRcvList
- class scapy.layers.dns.DNSStrField(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[source]
Bases:
StrLenFieldSpecial StrField that handles DNS encoding/decoding. It will also handle DNS decompression. (may be StrLenField if a length_from is passed),
- class scapy.layers.dns.DNSTCP(_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=[])[source]
Bases:
DNSA DNS packet that is always under TCP
- FORCE_TCP = True
- 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LENGTH | ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Q| OPCODE|A|T|R|R|Z|A|C| RCODE | QDCOUNT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ANCOUNT | NSCOUNT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ARCOUNT | QD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AN | NS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | AR | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. DNSTCPDNSTCP fields length
ShortField(Cond)Noneid
0qr
BitField(1 bit)0opcode
0aa
BitField(1 bit)0tc
BitField(1 bit)0rd
BitField(1 bit)1ra
BitField(1 bit)0z
BitField(1 bit)0ad
BitField(1 bit)0cd
BitField(1 bit)0rcode
0qdcount
Noneancount
Nonenscount
Nonearcount
Noneqd
_DNSPacketListField[<DNSQR |>]an
_DNSPacketListField[]ns
_DNSPacketListField[]ar
_DNSPacketListField[]
- match_subclass = True
- class scapy.layers.dns.DNSTextField(name: str, default: bytes, length_from: Callable[[Packet], int] | None = None, max_length: Any | None = None)[source]
Bases:
StrLenFieldSpecial StrLenField that handles DNS TEXT data (16)
- islist = 1
- class scapy.layers.dns.DNS_am(self, joker=None, match=None, srvmatch=None, joker6=False, send_error=False, relay=False, from_ip=True, from_ip6=False, src_ip=None, src_ip6=None, ttl=10, jokerarpa=False)[source]
Bases:
AnsweringMachine- filter: str | None = 'udp port 53'
- function_name = 'dnsd'
- 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, send_error=False, relay=False, from_ip=True, from_ip6=False, src_ip=None, src_ip6=None, ttl=10, jokerarpa=False)[source]
Simple DNS answering machine.
- Parameters:
joker – default IPv4 for unresolved domains. Set to False to disable, None to mirror the interface’s IP. Defaults to None, unless ‘match’ is used, then it defaults to False.
joker6 – default IPv6 for unresolved domains. Set to False to disable, None to mirror the interface’s IPv6. Defaults to False.
match – queries to match. This can be 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. If val is a single element, (A, None) is assumed. This can also be a list or names, in which case joker(6) are used as a response.
jokerarpa – answer for .in-addr.arpa PTR requests. (Default: False)
relay – relay unresolved domains to conf.nameservers (Default: False).
send_error – send an error message when this server can’t answer (Default: False)
srvmatch – a dictionary of {name: (port, target)} used for SRV
from_ip – an source IP to filter. Can contain a netmask. True for all, False for none. Default True
from_ip6 – an source IPv6 to filter. Can contain a netmask. True for all, False for none. Default False
ttl – the DNS time to live (in seconds)
src_ip – override the source IP
src_ip6
Examples:
Answer all ‘A’ and ‘AAAA’ requests:
$ sudo iptables -I OUTPUT -p icmp --icmp-type 3/3 -j DROP >>> dnsd(joker="192.168.0.2", joker6="fe80::260:8ff:fe52:f9d8", ... iface="eth0")
Answer only ‘A’ query for google.com with 192.168.0.2:
>>> dnsd(match={"google.com": "192.168.0.2"}, iface="eth0")
Answer DNS for a Windows domain controller (‘SRV’, ‘A’ and ‘AAAA’):
>>> dnsd( ... srvmatch={ ... "_ldap._tcp.dc._msdcs.DOMAIN.LOCAL.": (389, ... "srv1.domain.local"), ... }, ... match={"src1.domain.local": ("192.168.0.102", ... "fe80::260:8ff:fe52:f9d8")}, ... )
Relay all queries to another DNS server, except some:
>>> conf.nameservers = ["1.1.1.1"] # server to relay to >>> dnsd( ... match={"test.com": "1.1.1.1"}, ... relay=True, ... )
- class scapy.layers.dns.EDNS0COOKIE(_pkt, /, *, optcode=10, optlen=None, client_cookie=b'\x00\x00\x00\x00\x00\x00\x00\x00', server_cookie=b'')[source]
Bases:
_EDNS0Dummy- 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CLIENT COOKIE | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SERVER COOKIE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. EDNS0COOKIEEDNS0COOKIE fields optcode
10optlen
Noneclient_cookie
b'\x00\x00\x00\x00\x00\x00\x00\x00'server_cookie
b''
- class scapy.layers.dns.EDNS0ClientSubnet(_pkt, /, *, optcode=8, optlen=None, family=1, source_plen=None, scope_plen=0, address=None)[source]
Bases:
_EDNS0Dummy- 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. EDNS0ClientSubnetEDNS0ClientSubnet fields optcode
8optlen
Nonefamily
1source_plen
Nonescope_plen
0address
MultipleTypeField(ClientSubnetv4, ClientSubnetv6, ClientSubnetv4)b'192.168.0.0'
- class scapy.layers.dns.EDNS0DAU(_pkt, /, *, optcode=5, optlen=None, alg_code=[])[source]
Bases:
_EDNS0Dummy- 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ALG CODE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. EDNS0DAUEDNS0DAU fields optcode
5optlen
Nonealg_code
[]
- class scapy.layers.dns.EDNS0DHU(_pkt, /, *, optcode=6, optlen=None, alg_code=[])[source]
Bases:
_EDNS0Dummy- 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ALG CODE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. EDNS0DHUEDNS0DHU fields optcode
6optlen
Nonealg_code
[]
- class scapy.layers.dns.EDNS0ExtendedDNSError(_pkt, /, *, optcode=15, optlen=None, info_code=0, extra_text=b'')[source]
Bases:
_EDNS0Dummy- 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | INFO CODE | EXTRA TEXT | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. EDNS0ExtendedDNSErrorEDNS0ExtendedDNSError fields optcode
15optlen
Noneinfo_code
0extra_text
b''
- class scapy.layers.dns.EDNS0N3U(_pkt, /, *, optcode=7, optlen=None, alg_code=[])[source]
Bases:
_EDNS0Dummy- 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ALG CODE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. EDNS0N3UEDNS0N3U fields optcode
7optlen
Nonealg_code
[]
- class scapy.layers.dns.EDNS0OWN(_pkt, /, *, optcode=4, optlen=None, v=0, s=0, primary_mac='00:00:00:00:00:00', wakeup_mac='00:00:00:00:00:00', password=b'')[source]
Bases:
_EDNS0Dummy- 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 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | V | S | PRIMARY MAC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | WAKEUP MAC | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | PASSWORD | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. EDNS0OWNEDNS0OWN fields optcode
4optlen
Nonev
0s
0primary_mac
'00:00:00:00:00:00'wakeup_mac
MACField(Cond)'00:00:00:00:00:00'password
StrLenField(Cond)b''
- class scapy.layers.dns.EDNS0TLV(_pkt, /, *, optcode=0, optlen=None, optdata=b'')[source]
Bases:
_EDNS0Dummy- aliastypes
- classmethod dispatch_hook(_pkt: bytes | None = None, *args: Any, **kargs: Any) Type[Packet][source]
- 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. EDNS0TLVEDNS0TLV fields optcode
0optlen
Noneoptdata
b''
- scapy.layers.dns.RRlist2bitmap(lst)[source]
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)[source]
Bases:
StrField- islist = 1
- class scapy.layers.dns.SvcParam(_pkt, /, *, key=0, len=None, value=None)[source]
Bases:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | KEY | LEN | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | VALUE | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Fig. SvcParamSvcParam fields key
0len
Nonevalue
MultipleTypeField(FieldListField, DNSTextField, ShortField, FieldListField, FieldListField, StrLenField)b''
- class scapy.layers.dns.TimeSignedField(name, default)[source]
Bases:
Field[int,bytes]- i2m(pkt, seconds)[source]
Convert the number of seconds since 1-Jan-70 UTC to the packed representation.
- scapy.layers.dns.bitmap2RRlist(bitmap)[source]
Decode the ‘Type Bit Maps’ field of the NSEC Resource Record into an integer list.
- scapy.layers.dns.dns_compress(pkt)[source]
This function compresses a DNS packet according to compression rules.
- scapy.layers.dns.dns_encode(x, check_built=False)[source]
Encodes a bytes string into the DNS format
- Parameters:
x – the string
check_built – detect already-built strings and ignore them
- Returns:
the encoded bytes string
- scapy.layers.dns.dns_get_str(s, full=None, _ignore_compression=False)[source]
This function decompresses a string s, starting from the given pointer.
- Parameters:
s – the string to decompress
full – (optional) the full packet (used for decompression)
- Returns:
(decoded_string, end_index, left_string)
- scapy.layers.dns.dns_resolve(qname, qtype='A', raw=False, tcp=False, verbose=1, timeout=3, **kwargs)[source]
Perform a simple DNS resolution using conf.nameservers with caching
- Parameters:
qname – the name to query
qtype – the type to query (default A)
raw – return the whole DNS packet (default False)
tcp – whether to use directly TCP instead of UDP. If truncated is received, UDP automatically retries in TCP. (default: False)
verbose – show verbose errors
timeout – seconds until timeout (per server)
- Raises:
TimeoutError – if no DNS servers were reached in time.
- scapy.layers.dns.dnssd(service='_services._dns-sd._udp.local', af=AddressFamily.AF_INET, qtype='PTR', iface=None, verbose=2, timeout=3)[source]
Performs a DNS-SD (RFC6763) request
- Parameters:
service – the service name to query (e.g. _spotify-connect._tcp.local)
af – the transport to use. socket.AF_INET or socket.AF_INET6
qtype – the type to use in the mDNS. Either TXT, PTR or SRV.
iface – the interface to do this discovery on.
- scapy.layers.dns.dyndns_add(nameserver, name, rdata, type='A', ttl=10)[source]
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)[source]
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
- class scapy.layers.dns.mDNS_am(self, joker=None, match=None, srvmatch=None, joker6=False, send_error=False, relay=False, from_ip=True, from_ip6=False, src_ip=None, src_ip6=None, ttl=10, jokerarpa=False)[source]
Bases:
DNS_ammDNS answering machine.
This has the same arguments as DNS_am. See help(DNS_am)
Example:
- Answer for 'TEST.local' with local IPv4:: >>> mdnsd(match=["TEST.local"]) - Answer all requests with other IP:: >>> mdnsd(joker="192.168.0.2", joker6="fe80::260:8ff:fe52:f9d8", ... iface="eth0") - Answer for multiple different mDNS names:: >>> mdnsd(match={"TEST.local": "192.168.0.100", ... "BOB.local": "192.168.0.101"}) - Answer with both A and AAAA records:: >>> mdnsd(match={"TEST.local": ("192.168.0.100", ... "fe80::260:8ff:fe52:f9d8")})
- filter: str | None = 'udp port 5353'
- function_name = 'mdnsd'
- optam0: Dict[str, Any]
- optam1: Dict[str, Any]
- optam2: Dict[str, Any]
- optsend: Dict[str, Any]
- optsniff: Dict[str, Any]