May 2019
Intermediate to advanced
478 pages
11h 21m
English
To perform a simple DNS query, we would put an arbitrary number into ID, set the RD bit to 1, and set QDCOUNT to 1. We would then add a question after the header. That data would be sent as a UDP packet to port 53 of a DNS server.
A hand-constructed DNS for example.com in C is as follows:
char dns_query[] = {0xAB, 0xCD, /* ID */ 0x01, 0x00, /* Recursion */ 0x00, 0x01, /* QDCOUNT */ 0x00, 0x00, /* ANCOUNT */ 0x00, 0x00, /* NSCOUNT */ 0x00, 0x00, /* ARCOUNT */ 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', /* label */ 3, 'c', 'o', 'm', /* label */ 0, /* End of name */ 0x00, 0x01, /* QTYPE = A */ 0x00, 0x01 /* QCLASS */ };
This data could be sent as is to a DNS server over port 53.
The DNS server, if successful, sends a UDP packet ...
Read now
Unlock full access