-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
205 lines (144 loc) · 8.32 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
---
output: rmarkdown::github_document
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
```
```{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```
## NOTE
Requires [`getdns`](https://getdnsapi.net/) to be installed and available for compilation (no guard rails setup yet):
- Use `brew install getdns` on macOS
- Install `libgetdns-dev` or `libgetdns-devel` on debian/ubuntu (version 1.5.1 or higher)
- Windows support is likely in 2020 since getdns moved to a cmake build system with a primary intent to make Windows a first-class citizen.
You're going to need version 1.5.1+ of `getdns` for this package to install.
I've gotten this running on macOS and Ubuntu 16.04. For the latter I had to ensure `libidn2-0-dev` and
`libunbound-dev` were installed then had to grab the 1.5.1 tarball (e.g. `aria2c https://getdnsapi.net/releases/getdns-1-5-1/getdns-1.5.1.tar.gz`), extract it and `config`/`make`/`make install` (plus `ldconfig` after).
## TODO/WAT
I finally grok the getdns api so the package api is going to change wildly and fast. The default mode will be to perform queries using DNS over TLS but also supports UDP and TCP transports along with support for DNS over HTTPS.
## Why?
Well, for starters, to help research DNS over TLS/DNS over HTTPS servers. Plus, for fun!
If you're asking "Why DNS over TLS/HTTPS at all?" then "faux" privacy. Why "faux"? Well, _something_ is handing your query and that something knows your IP address and what you looked for. So, you're relying on the good faith, honest nature and technical capability of the destination server to not mess with you. I don't trust Cloudflare or Google and am witholding judgement on Quad9 either way (they've been doing good things and are less "look at how cool we are" than CF is).
Also "faux" in that you're going to be using (for DoT) a standard port (853) and a TLS session for the queries so your internet provider will know you're doing _something_ and the current, sorry state of SSL certificates, certificate authorities, and authoritarian companies and regimes combined means confidentiality and integrity are always kinda in question unless done super-well.
## What's Different About This vs Regular DNS?
Well, if we lookup the addresses for `yahoo.com` the old-fashioned way it's cleartext UDP on the wire:
1 0.000000 10.1.10.57 → 10.1.10.200 DNS 80 Standard query 0x8af8 A yahoo.com OPT
2 0.003297 10.1.10.200 → 10.1.10.57 DNS 176 Standard query response 0x8af8 A yahoo.com A 72.30.35.10 A 98.138.219.231 A 72.30.35.9 A 98.137.246.7 A 98.138.219.232 A 98.137.246.8 OPT
I watched for port 53 UDP traffic with `tshark` as `yahoo.com` was being looked up. Notice the fast and diminuitive — and plaintext — response. (I'm fibbing a bit since I pre-loaded the local home DNS server with this query since I tested it alot before knitting this readme. My home server forwards all queries to a custom DNS over TLS server since I really don't trust any of the providers when it comes down to it. So, in reality for me, it's even slower than the below — at least initially).
This is the same query via DNS over TLS
1 0.000000 10.1.10.57 → 9.9.9.9 TCP 78 52128 → 853 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=64 TSval=602885491 TSecr=0 SACK_PERM=1 TFO=R
2 0.021188 9.9.9.9 → 10.1.10.57 TCP 74 853 → 52128 [SYN, ACK] Seq=0 Ack=1 Win=28960 Len=0 MSS=1460 SACK_PERM=1 TSval=3426782438 TSecr=602885491 WS=256
3 0.021308 10.1.10.57 → 9.9.9.9 TLSv1 373 Client Hello
4 0.045324 9.9.9.9 → 10.1.10.57 TLSv1.2 1514 Server Hello
5 0.045333 9.9.9.9 → 10.1.10.57 TLSv1.2 73 [TCP Previous segment not captured] , Ignored Unknown Record
6 0.045334 9.9.9.9 → 10.1.10.57 TCP 1514 [TCP Out-Of-Order] 853 → 52128 [ACK] Seq=1449 Ack=308 Win=30208 Len=1448 TSval=3426782459 TSecr=602885512
7 0.045491 10.1.10.57 → 9.9.9.9 TCP 78 52128 → 853 [ACK] Seq=308 Ack=1449 Win=130304 Len=0 TSval=602885536 TSecr=3426782459 SLE=2897 SRE=2904
8 0.045492 10.1.10.57 → 9.9.9.9 TCP 66 52128 → 853 [ACK] Seq=308 Ack=2904 Win=128832 Len=0 TSval=602885536 TSecr=3426782459
9 0.050527 10.1.10.57 → 9.9.9.9 TLSv1.2 192 Client Key Exchange, Change Cipher Spec, Encrypted Handshake Message
10 0.069107 9.9.9.9 → 10.1.10.57 TLSv1.2 117 Change Cipher Spec, Encrypted Handshake Message
11 0.069255 10.1.10.57 → 9.9.9.9 TCP 66 52128 → 853 [ACK] Seq=434 Ack=2955 Win=131008 Len=0 TSval=602885559 TSecr=3426782487
12 0.069516 10.1.10.57 → 9.9.9.9 TLSv1.2 225 Application Data
13 0.091087 9.9.9.9 → 10.1.10.57 TLSv1.2 303 Application Data
14 0.091207 10.1.10.57 → 9.9.9.9 TLSv1.2 225 Application Data
15 0.106738 9.9.9.9 → 10.1.10.57 TLSv1.2 231 Application Data
16 0.106836 10.1.10.57 → 9.9.9.9 TCP 66 52128 → 853 [ACK] Seq=752 Ack=3357 Win=130880 Len=0 TSval=602885595 TSecr=3426782525
17 0.107200 10.1.10.57 → 9.9.9.9 TLSv1.2 97 Encrypted Alert
18 0.107411 10.1.10.57 → 9.9.9.9 TCP 66 52128 → 853 [FIN, ACK] Seq=783 Ack=3357 Win=131072 Len=0 TSval=602885595 TSecr=3426782525
19 0.126603 9.9.9.9 → 10.1.10.57 TLSv1.2 97 Encrypted Alert
20 0.126608 9.9.9.9 → 10.1.10.57 TCP 66 853 → 52128 [FIN, ACK] Seq=3388 Ack=784 Win=32256 Len=0 TSval=3426782545 TSecr=602885595
21 0.126717 10.1.10.57 → 9.9.9.9 TCP 54 52128 → 853 [RST] Seq=784 Win=0 Len=0
22 0.126718 10.1.10.57 → 9.9.9.9 TCP 54 52128 → 853 [RST] Seq=784 Win=0 Len=0
It's stupid slow, consumes more CPU and bandwidth but forces adversaries to work pretty hard to try to figure out what you're looking for.
## What's Inside The Tin
The following functions are implemented:
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```
## Installation
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```
## Usage
```{r lib-ex}
library(clandnstine)
# current version
packageVersion("clandnstine")
```
### Get an address(es) from a name:
```{r addr}
gdns_lib_version()
(x <- gdns_context())
(x <- gdns_context("1.1.1.1"))
(x <- gdns_context(c("8.8.8.8", "1.1.1.1", "9.9.9.9")))
(gdns_set_timeout(x, 2000))
(gdns_update_resolvers(x, "1.1.1.1"))
(gdns_set_transports(x, c("udp", "tls", "tcp")))
(gdns_get_address(x, "rud.is"))
(gdns_get_address(x, "yahoo.com"))
(gdns_get_address(x, "yahoo.commmm"))
```
### Any record type query:
```{r generic}
str(leno <- gdns_query(x, "lenovo.com", "txt"), 1)
sort(unlist(leno$replies_tree$answer[[1]]$rdata$txt_strings))
```
Yep. Advertising even in DNS `TXT` records (see item number 8).
### DOH
```{r doh}
str(doh_post("rud.is")$answer)
```
```{r doh2}
a <- doh_post("apple.com", "A")
tidy(a)
aaaa <- doh_post("rud.is", "AAAA")
tidy(aaaa)
mx <- doh_post("rud.is", "MX")
tidy(mx)
txt <- doh_post("lenovo.com", "TXT")
tidy(txt)
cname <- doh_post("dataassurance.pwc.com", "CNAME")
tidy(cname)
ns <- doh_post("rud.is", "NS")
tidy(ns)
soa <- doh_post("rud.is", "SOA")
tidy(soa)
ptr <- doh_post(to_inaddr_arpa("104.244.13.104"), "PTR")
tidy(ptr)
```
### If you _happen_ to have a DNS wireformat record…
```{r wf}
str(
from_wireformat(
as.raw(c(
0x00, 0x00, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
0x01, 0x00, 0x01, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00,
0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x04,
0xC0, 0x00, 0x02, 0x01
))
)
)
str(
from_wireformat(
as.raw(c(
0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x77, 0x77, 0x77, 0x07, 0x65, 0x78, 0x61,
0x6d, 0x70, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x00, 0x00,
0x01, 0x00, 0x01
))
)
)
```
## clandnstine Metrics
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```
## Code of Conduct
Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.