Last active
December 14, 2024 10:10
-
-
Save klzgrad/f124065c0616022b65e5 to your computer and use it in GitHub Desktop.
DNS compression pointer mutation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ LD_PRELOAD=$PWD/sendmsg.so dig twitter.com @8.8.8.8 | |
;; Warning: Message parser reports malformed message packet. <-- malformed 因为把压缩指针当作域名一部分了 | |
;; Question section mismatch: got twitter.com/RESERVED0/CLASS256 | |
; <<>> DiG 9.9.5-3-Ubuntu <<>> twitter.com @8.8.8.8 | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44722 | |
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1 | |
;; OPT PSEUDOSECTION: | |
; EDNS: version: 0, flags:; udp: 512 | |
;; QUESTION SECTION: | |
;twitter.com. IN A | |
;; ANSWER SECTION: | |
twitter.com. 12 IN A 199.59.150.7 | |
twitter.com. 12 IN A 199.59.148.82 | |
twitter.com. 12 IN A 199.59.149.198 | |
twitter.com. 12 IN A 199.59.149.230 | |
;; Query time: 400 msec | |
;; SERVER: 8.8.8.8#53(8.8.8.8) | |
;; WHEN: Sat Nov 15 -------- CST 2014 | |
;; MSG SIZE rcvd: 104 | |
$ LD_PRELOAD=$PWD/sendmsg.so host twitter.com 8.8.8.8 | |
Using domain server: | |
Name: 8.8.8.8 | |
Address: 8.8.8.8#53 | |
Aliases: | |
twitter.com has address 199.59.148.82 | |
twitter.com has address 199.59.149.230 | |
twitter.com has address 199.59.149.198 | |
twitter.com has address 199.59.148.10 | |
twitter.com mail is handled by 30 ASPMX2.GOOGLEMAIL.com. | |
twitter.com mail is handled by 10 aspmx.l.google.com. | |
twitter.com mail is handled by 20 alt2.aspmx.l.google.com. | |
twitter.com mail is handled by 20 alt1.aspmx.l.google.com. | |
twitter.com mail is handled by 30 ASPMX3.GOOGLEMAIL.com. | |
$ host twitter.com 8.8.8.8 | |
Using domain server: | |
Name: 8.8.8.8 | |
Address: 8.8.8.8#53 | |
Aliases: | |
twitter.com has address 59.24.3.173 | |
twitter.com has address 59.24.3.173 | |
twitter.com has address 37.61.54.158 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example.com normal google-dns1 NOERROR example.com. 20087 IN A 93.184.216.119 | |
example.com normal google-dns2 NOERROR example.com. 20098 IN A 93.184.216.119 | |
example.com normal opendns1 NOERROR example.com. 68574 IN A 93.184.216.119 | |
example.com normal opendns2 NOERROR example.com. 74046 IN A 93.184.216.119 | |
example.com normal twitter-ns1 NOERROR | |
example.com normal twitter-ns2 NOERROR | |
example.com normal he-dns NOERROR example.com. 86160 IN A 93.184.216.119 | |
example.com normal level3 NOERROR example.com. 86400 IN A 93.184.216.119 | |
example.com normal alidns1 NOERROR example.com. 57929 IN A 93.184.216.119 | |
example.com normal alidns2 NOERROR example.com. 32633 IN A 93.184.216.119 | |
example.com normal cnnic-dns1 NOERROR example.com. 84765 IN A 93.184.216.119 | |
example.com normal v2ex-dns1 NOERROR example.com. 4074 IN A 93.184.216.119 | |
example.com normal unicom-sh1 NOERROR example.com. 60682 IN A 93.184.216.119 | |
example.com normal unicom-sh2 NOERROR example.com. 79776 IN A 93.184.216.119 | |
example.com normal china-blackhole-1 | |
example.com normal china-blackhole-2 | |
example.com normal china-blackhole-3 | |
example.com normal china-blackhole-4 | |
twitter.com normal google-dns1 NOERROR twitter.com. 37569 IN A 37.61.54.158 | |
twitter.com normal google-dns2 NOERROR twitter.com. 41492 IN A 59.24.3.173 | |
twitter.com normal opendns1 NOERROR twitter.com. 13193 IN A 59.24.3.173 | |
twitter.com normal opendns2 NOERROR twitter.com. 8768 IN A 37.61.54.158 | |
twitter.com normal twitter-ns1 NOERROR twitter.com. 33232 IN A 37.61.54.158 | |
twitter.com normal twitter-ns2 NOERROR twitter.com. 30 IN A 199.59.150.7 twitter.com. 30 IN A 199.59.148.10 twitter.com. 30 IN A 199.59.149.230 twitter.com. 30 IN A 199.59.150.39 | |
twitter.com normal he-dns NOERROR twitter.com. 41492 IN A 59.24.3.173 | |
twitter.com normal level3 NOERROR twitter.com. 30851 IN A 37.61.54.158 | |
twitter.com normal alidns1 NOERROR twitter.com. 38987 IN A 59.24.3.173 | |
twitter.com normal alidns2 NOERROR twitter.com. 38987 IN A 59.24.3.173 | |
twitter.com normal cnnic-dns1 NOERROR twitter.com. 23292 IN A 37.61.54.158 | |
twitter.com normal v2ex-dns1 NOERROR twitter.com. 31559 IN A 59.24.3.173 | |
twitter.com normal unicom-sh1 NOERROR twitter.com. 19662 IN A 59.24.3.173 | |
twitter.com normal unicom-sh2 NOERROR twitter.com. 246 IN A 37.61.54.158 | |
twitter.com normal china-blackhole-1 | |
twitter.com normal china-blackhole-2 | |
twitter.com normal china-blackhole-3 | |
twitter.com normal china-blackhole-4 | |
example.com pointer-0 google-dns1 NOERROR example.com. 20069 IN A 93.184.216.119 | |
example.com pointer-0 google-dns2 NOERROR example.com. 20079 IN A 93.184.216.119 | |
example.com pointer-0 opendns1 NOERROR example.com. 68555 IN A 93.184.216.119 | |
example.com pointer-0 opendns2 NOERROR example.com. 74027 IN A 93.184.216.119 | |
example.com pointer-0 twitter-ns1 | |
example.com pointer-0 twitter-ns2 | |
example.com pointer-0 he-dns FORMERR | |
example.com pointer-0 level3 FORMERR | |
example.com pointer-0 alidns1 | |
example.com pointer-0 alidns2 | |
example.com pointer-0 cnnic-dns1 | |
example.com pointer-0 v2ex-dns1 NOERROR example.com. 4045 IN A 93.184.216.119 | |
example.com pointer-0 unicom-sh1 REFUSED | |
example.com pointer-0 unicom-sh2 | |
example.com pointer-0 china-blackhole-1 | |
example.com pointer-0 china-blackhole-2 | |
example.com pointer-0 china-blackhole-3 | |
example.com pointer-0 china-blackhole-4 | |
twitter.com pointer-0 google-dns1 NOERROR twitter.com. 21546 IN A 59.24.3.173 | |
twitter.com pointer-0 google-dns2 NOERROR twitter.com. 9482 IN A 59.24.3.173 | |
twitter.com pointer-0 opendns1 NOERROR twitter.com. 8377 IN A 59.24.3.173 | |
twitter.com pointer-0 opendns2 NOERROR twitter.com. 21546 IN A 59.24.3.173 | |
twitter.com pointer-0 twitter-ns1 NOERROR twitter.com. 21546 IN A 59.24.3.173 | |
twitter.com pointer-0 twitter-ns2 NOERROR twitter.com. 21546 IN A 59.24.3.173 | |
twitter.com pointer-0 he-dns NOERROR twitter.com. 21546 IN A 59.24.3.173 | |
twitter.com pointer-0 level3 NOERROR twitter.com. 21546 IN A 59.24.3.173 | |
twitter.com pointer-0 alidns1 | |
twitter.com pointer-0 alidns2 | |
twitter.com pointer-0 cnnic-dns1 | |
twitter.com pointer-0 v2ex-dns1 NOERROR twitter.com. 4493 IN A 59.24.3.173 | |
twitter.com pointer-0 unicom-sh1 REFUSED | |
twitter.com pointer-0 unicom-sh2 | |
twitter.com pointer-0 china-blackhole-1 | |
twitter.com pointer-0 china-blackhole-2 | |
twitter.com pointer-0 china-blackhole-3 | |
twitter.com pointer-0 china-blackhole-4 | |
example.com pointer-1 google-dns1 NOERROR example.com. 20035 IN A 93.184.216.119 | |
example.com pointer-1 google-dns2 NOERROR example.com. 20041 IN A 93.184.216.119 | |
example.com pointer-1 opendns1 NOERROR example.com. 74071 IN A 93.184.216.119 | |
example.com pointer-1 opendns2 NOERROR example.com. 74070 IN A 93.184.216.119 | |
example.com pointer-1 twitter-ns1 | |
example.com pointer-1 twitter-ns2 | |
example.com pointer-1 he-dns FORMERR | |
example.com pointer-1 level3 FORMERR | |
example.com pointer-1 alidns1 | |
example.com pointer-1 alidns2 | |
example.com pointer-1 cnnic-dns1 | |
example.com pointer-1 v2ex-dns1 NOERROR example.com. 4007 IN A 93.184.216.119 | |
example.com pointer-1 unicom-sh1 REFUSED | |
example.com pointer-1 unicom-sh2 | |
example.com pointer-1 china-blackhole-1 | |
example.com pointer-1 china-blackhole-2 | |
example.com pointer-1 china-blackhole-3 | |
example.com pointer-1 china-blackhole-4 | |
twitter.com pointer-1 google-dns1 NOERROR twitter.com. 27 IN A 199.59.149.230 twitter.com. 27 IN A 199.59.148.82 twitter.com. 27 IN A 199.59.150.39 twitter.com. 27 IN A 199.59.148.10 | |
twitter.com pointer-1 google-dns2 NOERROR twitter.com. 27 IN A 199.59.149.198 twitter.com. 27 IN A 199.59.149.230 twitter.com. 27 IN A 199.59.150.39 twitter.com. 27 IN A 199.59.148.10 | |
twitter.com pointer-1 opendns1 NOERROR twitter.com. 19 IN A 199.59.149.198 twitter.com. 19 IN A 199.59.150.7 twitter.com. 19 IN A 199.59.149.230 twitter.com. 19 IN A 199.59.148.82 | |
twitter.com pointer-1 opendns2 NOERROR twitter.com. 19 IN A 199.59.148.82 twitter.com. 19 IN A 199.59.150.39 twitter.com. 19 IN A 199.59.150.7 twitter.com. 19 IN A 199.59.149.230 | |
twitter.com pointer-1 twitter-ns1 | |
twitter.com pointer-1 twitter-ns2 | |
twitter.com pointer-1 he-dns FORMERR | |
twitter.com pointer-1 level3 FORMERR | |
twitter.com pointer-1 alidns1 | |
twitter.com pointer-1 alidns2 | |
twitter.com pointer-1 cnnic-dns1 | |
twitter.com pointer-1 v2ex-dns1 NOERROR twitter.com. 19 IN A 199.59.150.7 twitter.com. 19 IN A 199.59.148.10 twitter.com. 19 IN A 199.59.148.82 twitter.com. 19 IN A 199.59.150.39 | |
twitter.com pointer-1 unicom-sh1 REFUSED | |
twitter.com pointer-1 unicom-sh2 | |
twitter.com pointer-1 china-blackhole-1 | |
twitter.com pointer-1 china-blackhole-2 | |
twitter.com pointer-1 china-blackhole-3 | |
twitter.com pointer-1 china-blackhole-4 | |
example.com pointer-4 google-dns1 NOERROR example.com. 20004 IN A 93.184.216.119 | |
example.com pointer-4 google-dns2 NOERROR example.com. 19989 IN A 93.184.216.119 | |
example.com pointer-4 opendns1 NOERROR example.com. 73946 IN A 93.184.216.119 | |
example.com pointer-4 opendns2 NOERROR example.com. 68474 IN A 93.184.216.119 | |
example.com pointer-4 twitter-ns1 | |
example.com pointer-4 twitter-ns2 | |
example.com pointer-4 he-dns FORMERR | |
example.com pointer-4 level3 FORMERR | |
example.com pointer-4 alidns1 | |
example.com pointer-4 alidns2 | |
example.com pointer-4 cnnic-dns1 | |
example.com pointer-4 v2ex-dns1 NOERROR example.com. 3964 IN A 93.184.216.119 | |
example.com pointer-4 unicom-sh1 REFUSED | |
example.com pointer-4 unicom-sh2 | |
example.com pointer-4 china-blackhole-1 | |
example.com pointer-4 china-blackhole-2 | |
example.com pointer-4 china-blackhole-3 | |
example.com pointer-4 china-blackhole-4 | |
twitter.com pointer-4 google-dns1 NOERROR twitter.com. 14 IN A 199.59.149.198 twitter.com. 14 IN A 199.59.148.10 twitter.com. 14 IN A 199.59.150.39 twitter.com. 14 IN A 199.59.149.230 | |
twitter.com pointer-4 google-dns2 NOERROR twitter.com. 13 IN A 199.59.150.39 twitter.com. 13 IN A 199.59.148.10 twitter.com. 13 IN A 199.59.149.230 twitter.com. 13 IN A 199.59.150.7 | |
twitter.com pointer-4 opendns1 NOERROR twitter.com. 30 IN A 199.59.150.39 twitter.com. 30 IN A 199.59.148.10 twitter.com. 30 IN A 199.59.148.82 twitter.com. 30 IN A 199.59.149.198 | |
twitter.com pointer-4 opendns2 NOERROR twitter.com. 29 IN A 199.59.148.82 twitter.com. 29 IN A 199.59.150.39 twitter.com. 29 IN A 199.59.150.7 twitter.com. 29 IN A 199.59.149.198 | |
twitter.com pointer-4 twitter-ns1 | |
twitter.com pointer-4 twitter-ns2 | |
twitter.com pointer-4 he-dns FORMERR | |
twitter.com pointer-4 level3 FORMERR | |
twitter.com pointer-4 alidns1 | |
twitter.com pointer-4 alidns2 | |
twitter.com pointer-4 cnnic-dns1 | |
twitter.com pointer-4 v2ex-dns1 NOERROR twitter.com. 4 IN A 199.59.148.82 twitter.com. 4 IN A 199.59.148.10 twitter.com. 4 IN A 199.59.150.7 twitter.com. 4 IN A 199.59.149.198 | |
twitter.com pointer-4 unicom-sh1 REFUSED | |
twitter.com pointer-4 unicom-sh2 | |
twitter.com pointer-4 china-blackhole-1 | |
twitter.com pointer-4 china-blackhole-2 | |
twitter.com pointer-4 china-blackhole-3 | |
twitter.com pointer-4 china-blackhole-4 | |
example.com pointer-append google-dns1 NOERROR example.com. 19947 IN A 93.184.216.119 | |
example.com pointer-append google-dns2 NOERROR example.com. 19946 IN A 93.184.216.119 | |
example.com pointer-append opendns1 FORMERR | |
example.com pointer-append opendns2 FORMERR | |
example.com pointer-append twitter-ns1 | |
example.com pointer-append twitter-ns2 | |
example.com pointer-append he-dns parse error | |
example.com pointer-append level3 parse error | |
example.com pointer-append alidns1 | |
example.com pointer-append alidns2 | |
example.com pointer-append cnnic-dns1 | |
example.com pointer-append v2ex-dns1 NOERROR example.com. 3921 IN A 93.184.216.119 | |
example.com pointer-append unicom-sh1 FORMERR | |
example.com pointer-append unicom-sh2 FORMERR | |
example.com pointer-append china-blackhole-1 | |
example.com pointer-append china-blackhole-2 | |
example.com pointer-append china-blackhole-3 | |
example.com pointer-append china-blackhole-4 | |
twitter.com pointer-append google-dns1 NOERROR twitter.com. 29 IN A 199.59.148.10 twitter.com. 29 IN A 199.59.149.230 twitter.com. 29 IN A 199.59.148.82 twitter.com. 29 IN A 199.59.149.198 | |
twitter.com pointer-append google-dns2 NOERROR twitter.com. 28 IN A 199.59.150.39 twitter.com. 28 IN A 199.59.149.230 twitter.com. 28 IN A 199.59.148.82 twitter.com. 28 IN A 199.59.149.198 | |
twitter.com pointer-append opendns1 FORMERR | |
twitter.com pointer-append opendns2 FORMERR | |
twitter.com pointer-append twitter-ns1 | |
twitter.com pointer-append twitter-ns2 | |
twitter.com pointer-append he-dns parse error | |
twitter.com pointer-append level3 parse error | |
twitter.com pointer-append alidns1 | |
twitter.com pointer-append alidns2 | |
twitter.com pointer-append cnnic-dns1 | |
twitter.com pointer-append v2ex-dns1 NOERROR twitter.com. 22 IN A 199.59.148.10 twitter.com. 22 IN A 199.59.149.198 twitter.com. 22 IN A 199.59.150.39 twitter.com. 22 IN A 199.59.149.230 | |
twitter.com pointer-append unicom-sh1 FORMERR | |
twitter.com pointer-append unicom-sh2 FORMERR | |
twitter.com pointer-append china-blackhole-1 | |
twitter.com pointer-append china-blackhole-2 | |
twitter.com pointer-append china-blackhole-3 | |
twitter.com pointer-append china-blackhole-4 | |
example.com pointer-append-rr google-dns1 NOERROR example.com. 19923 IN A 93.184.216.119 | |
example.com pointer-append-rr google-dns2 NOERROR example.com. 19915 IN A 93.184.216.119 | |
example.com pointer-append-rr opendns1 FORMERR | |
example.com pointer-append-rr opendns2 FORMERR | |
example.com pointer-append-rr twitter-ns1 | |
example.com pointer-append-rr twitter-ns2 | |
example.com pointer-append-rr he-dns parse error | |
example.com pointer-append-rr level3 parse error | |
example.com pointer-append-rr alidns1 | |
example.com pointer-append-rr alidns2 | |
example.com pointer-append-rr cnnic-dns1 | |
example.com pointer-append-rr v2ex-dns1 NOERROR example.com. 3881 IN A 93.184.216.119 | |
example.com pointer-append-rr unicom-sh1 FORMERR | |
example.com pointer-append-rr unicom-sh2 FORMERR | |
example.com pointer-append-rr china-blackhole-1 | |
example.com pointer-append-rr china-blackhole-2 | |
example.com pointer-append-rr china-blackhole-3 | |
example.com pointer-append-rr china-blackhole-4 | |
twitter.com pointer-append-rr google-dns1 NOERROR twitter.com. 21 IN A 199.59.148.10 twitter.com. 21 IN A 199.59.150.39 twitter.com. 21 IN A 199.59.148.82 twitter.com. 21 IN A 199.59.149.230 | |
twitter.com pointer-append-rr google-dns2 NOERROR twitter.com. 20 IN A 199.59.149.230 twitter.com. 20 IN A 199.59.150.7 twitter.com. 20 IN A 199.59.150.39 twitter.com. 20 IN A 199.59.148.82 | |
twitter.com pointer-append-rr opendns1 FORMERR | |
twitter.com pointer-append-rr opendns2 FORMERR | |
twitter.com pointer-append-rr twitter-ns1 | |
twitter.com pointer-append-rr twitter-ns2 | |
twitter.com pointer-append-rr he-dns parse error | |
twitter.com pointer-append-rr level3 parse error | |
twitter.com pointer-append-rr alidns1 | |
twitter.com pointer-append-rr alidns2 | |
twitter.com pointer-append-rr cnnic-dns1 | |
twitter.com pointer-append-rr v2ex-dns1 NOERROR twitter.com. 9 IN A 199.59.150.39 twitter.com. 9 IN A 199.59.148.82 twitter.com. 9 IN A 199.59.148.10 twitter.com. 9 IN A 199.59.150.7 | |
twitter.com pointer-append-rr unicom-sh1 FORMERR | |
twitter.com pointer-append-rr unicom-sh2 FORMERR | |
twitter.com pointer-append-rr china-blackhole-1 | |
twitter.com pointer-append-rr china-blackhole-2 | |
twitter.com pointer-append-rr china-blackhole-3 | |
twitter.com pointer-append-rr china-blackhole-4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
gcc -fPIC -shared sendmsg.c -o sendmsg.so -ldl | |
LD_PRELOAD=$PWD/sendmsg.so host twitter.com 8.8.8.8 | |
LD_PRELOAD=$PWD/sendmsg.so dig twitter.com @8.8.8.8 | |
*/ | |
#define _GNU_SOURCE | |
#include <dlfcn.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
static ssize_t (*_sendmsg)(int, const struct msghdr *, int); | |
ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags) | |
{ | |
if (!_sendmsg) { | |
_sendmsg = dlsym(RTLD_NEXT, "sendmsg"); | |
if (!_sendmsg) { | |
perror("dlsym"); | |
exit(1); | |
} | |
} | |
struct msghdr newmsg; | |
char buffer[512]; | |
struct iovec vec; | |
if (msg->msg_namelen == sizeof(struct sockaddr_in) && msg->msg_iovlen == 1) { | |
const struct sockaddr_in *addr = (const struct sockaddr_in *)msg->msg_name; | |
const unsigned char *bytes = msg->msg_iov[0].iov_base; | |
const unsigned short *shorts = msg->msg_iov[0].iov_base; | |
size_t len = msg->msg_iov[0].iov_len; | |
if (addr->sin_family == AF_INET && addr->sin_port == htons(53) && | |
len < sizeof(buffer) - 1 && len > 16 && shorts[2] == htons(1) && shorts[3] == 0) { | |
size_t off = 12; | |
int ended = 0; | |
while (off < len - 4) { | |
if (bytes[off] & 0xc0) | |
break; | |
if (bytes[off] == 0) { | |
ended = 1; | |
off++; | |
break; | |
} | |
off += 1 + bytes[off]; | |
} | |
if (ended) { | |
memcpy(buffer, bytes, off - 1); | |
memcpy(buffer + off + 1, bytes + off, len - off); | |
buffer[off - 1] = '\xc0'; | |
buffer[off] = '\x04'; | |
vec.iov_base = buffer; | |
vec.iov_len = len + 1; | |
newmsg = *msg; | |
newmsg.msg_iov = &vec; | |
msg = &newmsg; | |
} | |
} | |
} | |
return _sendmsg(sockfd, msg, flags); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import dns.message, dns.rcode | |
queries = [ | |
('example.com normal', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\x00\x00\x01\x00\x01"), | |
('twitter.com normal', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07twitter\x03com\x00\x00\x01\x00\x01"), | |
('example.com pointer-0', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\xc0\x00\x00\x01\x00\x01"), | |
('twitter.com pointer-0', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07twitter\x03com\xc0\x00\x00\x01\x00\x01"), | |
('example.com pointer-1', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\xc0\x01\x00\x01\x00\x01"), | |
('twitter.com pointer-1', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07twitter\x03com\xc0\x01\x00\x01\x00\x01"), | |
('example.com pointer-4', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07example\x03com\xc0\x04\x00\x01\x00\x01"), | |
('twitter.com pointer-4', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x07twitter\x03com\xc0\x04\x00\x01\x00\x01"), | |
('example.com pointer-append', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\xc0\x12\x00\x01\x00\x01\x07example\x03com\x00"), | |
('twitter.com pointer-append', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\xc0\x12\x00\x01\x00\x01\x07twitter\x03com\x00"), | |
('example.com pointer-append-rr', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x01\xc0\x12\x00\x01\x00\x01\x07example\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00"), | |
('twitter.com pointer-append-rr', "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x01\xc0\x12\x00\x01\x00\x01\x07twitter\x03com\x00\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00"), | |
] | |
resolvers = [ | |
('google-dns1', '8.8.8.8'), | |
('google-dns2', '8.8.4.4'), | |
('opendns1', '208.67.222.222'), | |
('opendns2', '208.67.220.220'), | |
('twitter-ns1', '208.78.70.34'), | |
('twitter-ns2', '204.13.250.34'), | |
('he-dns', '74.82.42.42'), | |
('level3', '4.2.2.2'), | |
('alidns1', '223.5.5.5'), | |
('alidns2', '223.6.6.6'), | |
('cnnic-dns1', '1.2.4.8'), | |
('v2ex-dns1', '199.91.73.222'), | |
('unicom-sh1', '210.22.70.3'), | |
('unicom-sh2', '210.22.84.3'), | |
('china-blackhole-1', '210.22.0.0'), | |
('china-blackhole-2', '210.21.0.0'), | |
('china-blackhole-3', '202.96.0.0'), | |
('china-blackhole-4', '116.228.0.0'), | |
] | |
def test_query(resolver, query): | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.settimeout(0.1) | |
result = '' | |
for i in range(20): | |
sock.sendto(query, (resolver, 53)) | |
try: | |
packet, addr = sock.recvfrom(2048) | |
try: | |
r = dns.message.from_wire(packet) | |
rc = dns.rcode.from_flags(r.flags, r.ednsflags) | |
result = dns.rcode.to_text(rc) + ' ' + ' '.join(str(rr) for rr in r.answer).replace('\n', ' ') | |
except: | |
result = 'parse error' | |
break | |
except socket.timeout: | |
pass | |
sock.close() | |
return result | |
for qname, query in queries: | |
for rname, resolver in resolvers: | |
print qname, rname, test_query(resolver, query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example.com normal google-dns1 NOERROR example.com. 4268 IN A 93.184.216.119 | |
example.com normal google-dns2 NOERROR example.com. 4268 IN A 93.184.216.119 | |
example.com normal opendns1 NOERROR example.com. 27992 IN A 93.184.216.119 | |
example.com normal opendns2 NOERROR example.com. 27992 IN A 93.184.216.119 | |
example.com normal twitter-ns1 NOERROR | |
example.com normal twitter-ns2 NOERROR | |
example.com normal he-dns NOERROR example.com. 86278 IN A 93.184.216.119 | |
example.com normal level3 NOERROR example.com. 69051 IN A 93.184.216.119 | |
example.com normal alidns1 NOERROR example.com. 73901 IN A 93.184.216.119 | |
example.com normal alidns2 NOERROR example.com. 73900 IN A 93.184.216.119 | |
example.com normal cnnic-dns1 NOERROR example.com. 61965 IN A 93.184.216.119 | |
example.com normal v2ex-dns1 NOERROR example.com. 14652 IN A 93.184.216.119 | |
example.com normal unicom-sh1 NOERROR example.com. 84929 IN A 93.184.216.119 | |
example.com normal unicom-sh2 NOERROR example.com. 80503 IN A 93.184.216.119 | |
example.com normal china-blackhole-1 | |
example.com normal china-blackhole-2 | |
example.com normal china-blackhole-3 | |
example.com normal china-blackhole-4 | |
twitter.com normal google-dns1 NOERROR twitter.com. 29 IN A 199.16.156.230 twitter.com. 29 IN A 199.16.156.38 twitter.com. 29 IN A 199.16.156.70 twitter.com. 29 IN A 199.16.156.102 | |
twitter.com normal google-dns2 NOERROR twitter.com. 29 IN A 199.16.156.230 twitter.com. 29 IN A 199.16.156.38 twitter.com. 29 IN A 199.16.156.70 twitter.com. 29 IN A 199.16.156.102 | |
twitter.com normal opendns1 NOERROR twitter.com. 26 IN A 199.16.156.102 twitter.com. 26 IN A 199.16.156.198 twitter.com. 26 IN A 199.16.156.38 twitter.com. 26 IN A 199.16.156.70 | |
twitter.com normal opendns2 NOERROR twitter.com. 19 IN A 199.16.156.198 twitter.com. 19 IN A 199.16.156.6 twitter.com. 19 IN A 199.16.156.38 twitter.com. 19 IN A 199.16.156.230 | |
twitter.com normal twitter-ns1 NOERROR twitter.com. 30 IN A 199.16.156.38 twitter.com. 30 IN A 199.16.156.70 twitter.com. 30 IN A 199.16.156.6 twitter.com. 30 IN A 199.16.156.198 | |
twitter.com normal twitter-ns2 NOERROR twitter.com. 30 IN A 199.16.156.6 twitter.com. 30 IN A 199.16.156.102 twitter.com. 30 IN A 199.16.156.38 twitter.com. 30 IN A 199.16.156.198 | |
twitter.com normal he-dns NOERROR twitter.com. 18 IN A 199.59.149.198 twitter.com. 18 IN A 199.59.150.39 twitter.com. 18 IN A 199.59.150.7 twitter.com. 18 IN A 199.59.149.230 | |
twitter.com normal level3 NOERROR twitter.com. 63 IN A 199.16.156.38 twitter.com. 63 IN A 199.16.156.70 twitter.com. 63 IN A 199.16.156.230 twitter.com. 63 IN A 199.16.156.6 | |
twitter.com normal alidns1 NOERROR twitter.com. 25877 IN A 37.61.54.158 | |
twitter.com normal alidns2 NOERROR twitter.com. 9962 IN A 37.61.54.158 | |
twitter.com normal cnnic-dns1 NOERROR twitter.com. 30 IN A 199.59.149.198 twitter.com. 30 IN A 199.59.150.7 twitter.com. 30 IN A 199.59.148.82 twitter.com. 30 IN A 199.59.150.39 | |
twitter.com normal v2ex-dns1 NOERROR twitter.com. 27 IN A 199.59.149.198 twitter.com. 27 IN A 199.59.148.82 twitter.com. 27 IN A 199.59.150.39 twitter.com. 27 IN A 199.59.150.7 | |
twitter.com normal unicom-sh1 NOERROR twitter.com. 9340 IN A 37.61.54.158 | |
twitter.com normal unicom-sh2 NOERROR twitter.com. 43022 IN A 37.61.54.158 | |
twitter.com normal china-blackhole-1 NOERROR twitter.com. 44055 IN A 59.24.3.173 | |
twitter.com normal china-blackhole-2 NOERROR twitter.com. 42928 IN A 37.61.54.158 | |
twitter.com normal china-blackhole-3 NOERROR twitter.com. 17089 IN A 37.61.54.158 | |
twitter.com normal china-blackhole-4 NOERROR twitter.com. 41669 IN A 37.61.54.158 | |
example.com pointer-0 google-dns1 NOERROR example.com. 4254 IN A 93.184.216.119 | |
example.com pointer-0 google-dns2 NOERROR example.com. 4254 IN A 93.184.216.119 | |
example.com pointer-0 opendns1 NOERROR example.com. 25344 IN A 93.184.216.119 | |
example.com pointer-0 opendns2 NOERROR example.com. 31465 IN A 93.184.216.119 | |
example.com pointer-0 twitter-ns1 | |
example.com pointer-0 twitter-ns2 | |
example.com pointer-0 he-dns FORMERR | |
example.com pointer-0 level3 NOERROR example.com. 69033 IN A 93.184.216.119 | |
example.com pointer-0 alidns1 | |
example.com pointer-0 alidns2 | |
example.com pointer-0 cnnic-dns1 | |
example.com pointer-0 v2ex-dns1 NOERROR example.com. 14629 IN A 93.184.216.119 | |
example.com pointer-0 unicom-sh1 REFUSED | |
example.com pointer-0 unicom-sh2 | |
example.com pointer-0 china-blackhole-1 | |
example.com pointer-0 china-blackhole-2 | |
example.com pointer-0 china-blackhole-3 | |
example.com pointer-0 china-blackhole-4 | |
twitter.com pointer-0 google-dns1 NOERROR twitter.com. 4 IN A 199.16.156.6 twitter.com. 4 IN A 199.16.156.70 twitter.com. 4 IN A 199.16.156.230 twitter.com. 4 IN A 199.16.156.198 | |
twitter.com pointer-0 google-dns2 NOERROR twitter.com. 4 IN A 199.16.156.102 twitter.com. 4 IN A 199.16.156.70 twitter.com. 4 IN A 199.16.156.6 twitter.com. 4 IN A 199.16.156.38 | |
twitter.com pointer-0 opendns1 NOERROR twitter.com. 29 IN A 199.16.156.198 twitter.com. 29 IN A 199.16.156.230 twitter.com. 29 IN A 199.16.156.6 twitter.com. 29 IN A 199.16.156.38 | |
twitter.com pointer-0 opendns2 NOERROR twitter.com. 21 IN A 199.16.156.198 twitter.com. 21 IN A 199.16.156.38 twitter.com. 21 IN A 199.16.156.6 twitter.com. 21 IN A 199.16.156.230 | |
twitter.com pointer-0 twitter-ns1 | |
twitter.com pointer-0 twitter-ns2 | |
twitter.com pointer-0 he-dns FORMERR | |
twitter.com pointer-0 level3 FORMERR | |
twitter.com pointer-0 alidns1 NOERROR twitter.com. 38584 IN A 59.24.3.173 | |
twitter.com pointer-0 alidns2 NOERROR twitter.com. 46742 IN A 59.24.3.173 | |
twitter.com pointer-0 cnnic-dns1 | |
twitter.com pointer-0 v2ex-dns1 NOERROR twitter.com. 26 IN A 199.59.149.198 twitter.com. 26 IN A 199.59.150.39 twitter.com. 26 IN A 199.59.148.82 twitter.com. 26 IN A 199.59.149.230 | |
twitter.com pointer-0 unicom-sh1 NOERROR twitter.com. 31863 IN A 59.24.3.173 | |
twitter.com pointer-0 unicom-sh2 NOERROR twitter.com. 31863 IN A 59.24.3.173 | |
twitter.com pointer-0 china-blackhole-1 NOERROR twitter.com. 31919 IN A 59.24.3.173 | |
twitter.com pointer-0 china-blackhole-2 NOERROR twitter.com. 31919 IN A 59.24.3.173 | |
twitter.com pointer-0 china-blackhole-3 NOERROR twitter.com. 31919 IN A 59.24.3.173 | |
twitter.com pointer-0 china-blackhole-4 NOERROR twitter.com. 11862 IN A 59.24.3.173 | |
example.com pointer-1 google-dns1 NOERROR example.com. 4224 IN A 93.184.216.119 | |
example.com pointer-1 google-dns2 NOERROR example.com. 4223 IN A 93.184.216.119 | |
example.com pointer-1 opendns1 NOERROR example.com. 27947 IN A 93.184.216.119 | |
example.com pointer-1 opendns2 NOERROR example.com. 31038 IN A 93.184.216.119 | |
example.com pointer-1 twitter-ns1 | |
example.com pointer-1 twitter-ns2 | |
example.com pointer-1 he-dns FORMERR | |
example.com pointer-1 level3 NOERROR example.com. 69002 IN A 93.184.216.119 | |
example.com pointer-1 alidns1 | |
example.com pointer-1 alidns2 | |
example.com pointer-1 cnnic-dns1 | |
example.com pointer-1 v2ex-dns1 NOERROR example.com. 14598 IN A 93.184.216.119 | |
example.com pointer-1 unicom-sh1 REFUSED | |
example.com pointer-1 unicom-sh2 | |
example.com pointer-1 china-blackhole-1 | |
example.com pointer-1 china-blackhole-2 | |
example.com pointer-1 china-blackhole-3 | |
example.com pointer-1 china-blackhole-4 | |
twitter.com pointer-1 google-dns1 NOERROR twitter.com. 3 IN A 199.16.156.198 twitter.com. 3 IN A 199.16.156.6 twitter.com. 3 IN A 199.16.156.102 twitter.com. 3 IN A 199.16.156.230 | |
twitter.com pointer-1 google-dns2 NOERROR twitter.com. 3 IN A 199.16.156.70 twitter.com. 3 IN A 199.16.156.102 twitter.com. 3 IN A 199.16.156.198 twitter.com. 3 IN A 199.16.156.38 | |
twitter.com pointer-1 opendns1 NOERROR twitter.com. 25 IN A 199.16.156.198 twitter.com. 25 IN A 199.16.156.102 twitter.com. 25 IN A 199.16.156.70 twitter.com. 25 IN A 199.16.156.230 | |
twitter.com pointer-1 opendns2 NOERROR twitter.com. 25 IN A 199.16.156.198 twitter.com. 25 IN A 199.16.156.102 twitter.com. 25 IN A 199.16.156.70 twitter.com. 25 IN A 199.16.156.230 | |
twitter.com pointer-1 twitter-ns1 | |
twitter.com pointer-1 twitter-ns2 | |
twitter.com pointer-1 he-dns FORMERR | |
twitter.com pointer-1 level3 NOERROR twitter.com. 18 IN A 199.16.156.38 twitter.com. 18 IN A 199.16.156.70 twitter.com. 18 IN A 199.16.156.6 twitter.com. 18 IN A 199.16.156.198 | |
twitter.com pointer-1 alidns1 | |
twitter.com pointer-1 alidns2 | |
twitter.com pointer-1 cnnic-dns1 | |
twitter.com pointer-1 v2ex-dns1 NOERROR twitter.com. 21 IN A 199.59.148.82 twitter.com. 21 IN A 199.59.149.198 twitter.com. 21 IN A 199.59.150.7 twitter.com. 21 IN A 199.59.148.10 | |
twitter.com pointer-1 unicom-sh1 REFUSED | |
twitter.com pointer-1 unicom-sh2 | |
twitter.com pointer-1 china-blackhole-1 | |
twitter.com pointer-1 china-blackhole-2 | |
twitter.com pointer-1 china-blackhole-3 | |
twitter.com pointer-1 china-blackhole-4 | |
example.com pointer-4 google-dns1 NOERROR example.com. 4182 IN A 93.184.216.119 | |
example.com pointer-4 google-dns2 NOERROR example.com. 4182 IN A 93.184.216.119 | |
example.com pointer-4 opendns1 NOERROR example.com. 28298 IN A 93.184.216.119 | |
example.com pointer-4 opendns2 NOERROR example.com. 30996 IN A 93.184.216.119 | |
example.com pointer-4 twitter-ns1 | |
example.com pointer-4 twitter-ns2 | |
example.com pointer-4 he-dns FORMERR | |
example.com pointer-4 level3 NOERROR example.com. 68961 IN A 93.184.216.119 | |
example.com pointer-4 alidns1 | |
example.com pointer-4 alidns2 | |
example.com pointer-4 cnnic-dns1 | |
example.com pointer-4 v2ex-dns1 NOERROR example.com. 14557 IN A 93.184.216.119 | |
example.com pointer-4 unicom-sh1 REFUSED | |
example.com pointer-4 unicom-sh2 | |
example.com pointer-4 china-blackhole-1 | |
example.com pointer-4 china-blackhole-2 | |
example.com pointer-4 china-blackhole-3 | |
example.com pointer-4 china-blackhole-4 | |
twitter.com pointer-4 google-dns1 NOERROR twitter.com. 19 IN A 199.16.156.38 twitter.com. 19 IN A 199.16.156.198 twitter.com. 19 IN A 199.16.156.6 twitter.com. 19 IN A 199.16.156.102 | |
twitter.com pointer-4 google-dns2 NOERROR twitter.com. 19 IN A 199.16.156.198 twitter.com. 19 IN A 199.16.156.38 twitter.com. 19 IN A 199.16.156.230 twitter.com. 19 IN A 199.16.156.70 | |
twitter.com pointer-4 opendns1 NOERROR twitter.com. 4 IN A 199.16.156.70 twitter.com. 4 IN A 199.16.156.6 twitter.com. 4 IN A 199.16.156.198 twitter.com. 4 IN A 199.16.156.38 | |
twitter.com pointer-4 opendns2 NOERROR twitter.com. 30 IN A 199.16.156.102 twitter.com. 30 IN A 199.16.156.230 twitter.com. 30 IN A 199.16.156.6 twitter.com. 30 IN A 199.16.156.38 | |
twitter.com pointer-4 twitter-ns1 | |
twitter.com pointer-4 twitter-ns2 | |
twitter.com pointer-4 he-dns FORMERR | |
twitter.com pointer-4 level3 FORMERR | |
twitter.com pointer-4 alidns1 | |
twitter.com pointer-4 alidns2 | |
twitter.com pointer-4 cnnic-dns1 | |
twitter.com pointer-4 v2ex-dns1 NOERROR twitter.com. 9 IN A 199.59.150.7 twitter.com. 9 IN A 199.59.148.82 twitter.com. 9 IN A 199.59.149.230 twitter.com. 9 IN A 199.59.148.10 | |
twitter.com pointer-4 unicom-sh1 REFUSED | |
twitter.com pointer-4 unicom-sh2 | |
twitter.com pointer-4 china-blackhole-1 | |
twitter.com pointer-4 china-blackhole-2 | |
twitter.com pointer-4 china-blackhole-3 | |
twitter.com pointer-4 china-blackhole-4 | |
example.com pointer-append google-dns1 NOERROR example.com. 4141 IN A 93.184.216.119 | |
example.com pointer-append google-dns2 NOERROR example.com. 4141 IN A 93.184.216.119 | |
example.com pointer-append opendns1 FORMERR | |
example.com pointer-append opendns2 FORMERR | |
example.com pointer-append twitter-ns1 | |
example.com pointer-append twitter-ns2 | |
example.com pointer-append he-dns parse error | |
example.com pointer-append level3 | |
example.com pointer-append alidns1 | |
example.com pointer-append alidns2 | |
example.com pointer-append cnnic-dns1 | |
example.com pointer-append v2ex-dns1 NOERROR example.com. 14513 IN A 93.184.216.119 | |
example.com pointer-append unicom-sh1 FORMERR | |
example.com pointer-append unicom-sh2 FORMERR | |
example.com pointer-append china-blackhole-1 | |
example.com pointer-append china-blackhole-2 | |
example.com pointer-append china-blackhole-3 | |
example.com pointer-append china-blackhole-4 | |
twitter.com pointer-append google-dns1 NOERROR twitter.com. 6 IN A 199.16.156.70 twitter.com. 6 IN A 199.16.156.230 twitter.com. 6 IN A 199.16.156.6 twitter.com. 6 IN A 199.16.156.198 | |
twitter.com pointer-append google-dns2 NOERROR twitter.com. 6 IN A 199.16.156.70 twitter.com. 6 IN A 199.16.156.38 twitter.com. 6 IN A 199.16.156.102 twitter.com. 6 IN A 199.16.156.6 | |
twitter.com pointer-append opendns1 FORMERR | |
twitter.com pointer-append opendns2 FORMERR | |
twitter.com pointer-append twitter-ns1 | |
twitter.com pointer-append twitter-ns2 | |
twitter.com pointer-append he-dns parse error | |
twitter.com pointer-append level3 parse error | |
twitter.com pointer-append alidns1 | |
twitter.com pointer-append alidns2 | |
twitter.com pointer-append cnnic-dns1 | |
twitter.com pointer-append v2ex-dns1 NOERROR twitter.com. 25 IN A 199.59.148.82 twitter.com. 25 IN A 199.59.149.198 twitter.com. 25 IN A 199.59.148.10 twitter.com. 25 IN A 199.59.150.39 | |
twitter.com pointer-append unicom-sh1 FORMERR | |
twitter.com pointer-append unicom-sh2 FORMERR | |
twitter.com pointer-append china-blackhole-1 | |
twitter.com pointer-append china-blackhole-2 | |
twitter.com pointer-append china-blackhole-3 | |
twitter.com pointer-append china-blackhole-4 | |
example.com pointer-append-rr google-dns1 NOERROR example.com. 4100 IN A 93.184.216.119 | |
example.com pointer-append-rr google-dns2 NOERROR example.com. 4100 IN A 93.184.216.119 | |
example.com pointer-append-rr opendns1 FORMERR | |
example.com pointer-append-rr opendns2 FORMERR | |
example.com pointer-append-rr twitter-ns1 | |
example.com pointer-append-rr twitter-ns2 | |
example.com pointer-append-rr he-dns parse error | |
example.com pointer-append-rr level3 parse error | |
example.com pointer-append-rr alidns1 | |
example.com pointer-append-rr alidns2 | |
example.com pointer-append-rr cnnic-dns1 | |
example.com pointer-append-rr v2ex-dns1 NOERROR example.com. 14474 IN A 93.184.216.119 | |
example.com pointer-append-rr unicom-sh1 FORMERR | |
example.com pointer-append-rr unicom-sh2 FORMERR | |
example.com pointer-append-rr china-blackhole-1 | |
example.com pointer-append-rr china-blackhole-2 | |
example.com pointer-append-rr china-blackhole-3 | |
example.com pointer-append-rr china-blackhole-4 | |
twitter.com pointer-append-rr google-dns1 NOERROR twitter.com. 26 IN A 199.16.156.102 twitter.com. 26 IN A 199.16.156.230 twitter.com. 26 IN A 199.16.156.38 twitter.com. 26 IN A 199.16.156.198 | |
twitter.com pointer-append-rr google-dns2 NOERROR twitter.com. 26 IN A 199.16.156.198 twitter.com. 26 IN A 199.16.156.230 twitter.com. 26 IN A 199.16.156.38 twitter.com. 26 IN A 199.16.156.70 | |
twitter.com pointer-append-rr opendns1 FORMERR | |
twitter.com pointer-append-rr opendns2 FORMERR | |
twitter.com pointer-append-rr twitter-ns1 | |
twitter.com pointer-append-rr twitter-ns2 | |
twitter.com pointer-append-rr he-dns parse error | |
twitter.com pointer-append-rr level3 NOERROR twitter.com. 4 IN A 199.16.156.230 twitter.com. 4 IN A 199.16.156.6 twitter.com. 4 IN A 199.16.156.198 twitter.com. 4 IN A 199.16.156.38 | |
twitter.com pointer-append-rr alidns1 | |
twitter.com pointer-append-rr alidns2 | |
twitter.com pointer-append-rr cnnic-dns1 | |
twitter.com pointer-append-rr v2ex-dns1 NOERROR twitter.com. 16 IN A 199.59.148.10 twitter.com. 16 IN A 199.59.148.82 twitter.com. 16 IN A 199.59.149.198 twitter.com. 16 IN A 199.59.150.7 | |
twitter.com pointer-append-rr unicom-sh1 FORMERR | |
twitter.com pointer-append-rr unicom-sh2 FORMERR | |
twitter.com pointer-append-rr china-blackhole-1 | |
twitter.com pointer-append-rr china-blackhole-2 | |
twitter.com pointer-append-rr china-blackhole-3 | |
twitter.com pointer-append-rr china-blackhole-4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment