• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

isc/H10-Jan-2019-242175

m4/H07-May-2022-9,3038,415

plugins/H11-Mar-2021-32,73529,919

src/H03-May-2022-26,44521,792

.clang-formatH A D23-Apr-2020145 76

CONTRIBUTORSH A D23-Apr-2020394 1817

LICENSEH A D12-Feb-20211.5 KiB3427

Makefile.amH A D03-May-2022269 148

Makefile.inH A D11-Mar-202127.5 KiB883782

README.mdH A D15-Dec-20208.4 KiB248187

aclocal.m4H A D11-Mar-202153.9 KiB1,4991,358

ar-libH A D11-Mar-20215.7 KiB271210

compileH A D11-Mar-20217.2 KiB349259

config.guessH A D11-Mar-202143.2 KiB1,4811,288

config.subH A D11-Mar-202135.3 KiB1,8021,661

configureH A D11-Mar-2021492.8 KiB16,78414,075

configure.acH A D03-May-20225.7 KiB161145

depcompH A D11-Mar-202123 KiB792502

fmt.shH A D03-Jun-2020161 107

install-shH A D11-Mar-202115 KiB519337

ltmain.shH A D11-Mar-2021319.6 KiB11,2528,044

missingH A D11-Mar-20216.7 KiB216143

test-driverH A D11-Mar-20214.5 KiB14987

README.md

1# dnscap
2
3[![Build Status](https://travis-ci.com/DNS-OARC/dnscap.svg?branch=develop)](https://travis-ci.com/DNS-OARC/dnscap) [![Total alerts](https://img.shields.io/lgtm/alerts/g/DNS-OARC/dnscap.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/DNS-OARC/dnscap/alerts/) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=dns-oarc%3Adnscap&metric=bugs)](https://sonarcloud.io/dashboard?id=dns-oarc%3Adnscap) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=dns-oarc%3Adnscap&metric=security_rating)](https://sonarcloud.io/dashboard?id=dns-oarc%3Adnscap)
4
5`dnscap` is a network capture utility designed specifically for DNS traffic.
6It produces binary data in `pcap(3)` and other format. This utility is similar
7to `tcpdump(1)`, but has a number of features tailored to DNS transactions
8and protocol options. DNS-OARC uses `dnscap` for DITL data collections.
9
10Some of its features include:
11- Understands both IPv4 and IPv6
12- Captures UDP, TCP, and IP fragments.
13- Collect only queries, responses, or both (`-s` option)
14- Collect for only certain source/destination addresses (`-a` `-z` `-A` `-Z` options)
15- Periodically creates new pcap files (`-t` option)
16- Spawns an upload script after closing a pcap file (`-k` option)
17- Will start and stop collecting at specific times (`-B` `-E` options)
18
19More information may be found here:
20- https://www.dns-oarc.net/tools/dnscap
21- https://www.dns-oarc.net/oarc/data/ditl
22
23Issues should be reported here:
24- https://github.com/DNS-OARC/dnscap/issues
25
26General support and discussion:
27- Mattermost: https://chat.dns-oarc.net/community/channels/oarc-software
28- mailing-list: https://lists.dns-oarc.net/mailman/listinfo/dnscap-users
29
30## Dependencies
31
32`dnscap` requires a couple of libraries beside a normal C compiling
33environment with autoconf, automake, libtool and pkgconfig.
34
35`dnscap` has a non-optional dependency on the PCAP library and LDNS.
36
37To install the dependencies under Debian/Ubuntu:
38```
39apt-get install -y libpcap-dev libldns-dev zlib1g-dev libyaml-perl libssl-dev
40```
41
42To install the dependencies under CentOS (with EPEL enabled):
43```
44yum install -y libpcap-devel ldns-devel openssl-devel zlib-devel perl-YAML
45```
46
47For the following OS you will need to install some of the dependencies
48from source or Ports, these instructions are not included.
49
50To install some of the dependencies under FreeBSD 10+ using `pkg`:
51```
52pkg install -y libpcap ldns p5-YAML openssl-devel
53```
54
55To install some of the dependencies under OpenBSD 5+ using `pkg_add`:
56```
57pkg_add libldns p5-YAML
58```
59
60NOTE: It is recommended to install the PCAP library from source/ports on
61OpenBSD since the bundled version is an older and modified version.
62
63### Dependencies for `cryptopant.so` plugin
64
65For this plugin a library call `cryptopANT` is required and the original
66can be found here: https://ant.isi.edu/software/cryptopANT/index.html .
67
68For DNS-OARC packages we build our own fork, with slight modifications to
69conform across distributions, of this library which is included in the same
70package repository as `dnscap`. The modifications and packaging files can be
71found here: https://github.com/DNS-OARC/cryptopANT .
72
73## Building from source tarball
74
75The [source tarball from DNS-OARC](https://www.dns-oarc.net/tools/dnscap)
76comes prepared with `configure`:
77
78```
79tar zxvf dnscap-version.tar.gz
80cd dnscap-version
81./configure [options]
82make
83make install
84```
85
86## Building from Git repository
87
88If you are building `dnscap` from it's Git repository you will first need
89to initiate the Git submodules that exists and later create autoconf/automake
90files, this will require a build environment with autoconf, automake, libtool
91and pkg-config to be installed.
92
93```
94git clone https://github.com/DNS-OARC/dnscap.git
95cd dnscap
96git submodule update --init
97./autogen.sh
98./configure [options]
99make
100make install
101```
102
103### 64-bit libraries
104
105If you need to link against 64-bit libraries found in non-standard
106locations, provide the location by setting LDFLAGS before running
107configure:
108
109```
110$ env LDFLAGS=-L/usr/lib64 ./configure
111```
112
113### OpenBSD
114
115For OpenBSD you probably installed libpcap in `/usr/local` so you will need
116to tell `configure` where to find the libraries and header files:
117
118```
119$ env CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure
120```
121
122## Plugins
123
124`dnscap` comes bundled with a set of plugins, see `-P` option.
125
126- `anonaes128.so`: Anonymize IP addresses using AES128
127- `anonmask.so`: Pseudo-anonymize IP addresses by masking them
128- `cryptopan.so`: Anonymize IP addresses using an extension to Crypto-PAn (College of Computing, Georgia Tech) made by David Stott (Lucent)
129- `cryptopant.so`: Anonymize IP addresses using cryptopANT, a different implementation of Crypto-PAn made by the ANT project at USC/ISI
130- `ipcrypt.so`: Anonymize IP addresses using ipcrypt create by Jean-Philippe Aumasson
131- `pcapdump.so`: Dump DNS into a PCAP with some filtering options
132- `royparse.so`: Splits a PCAP into two streams; queries in PCAP format and responses in ASCII format
133- `rssm.so`: Root Server Scaling Measurement plugin, see it's [README.md](plugins/rssm/README.md) for more information
134- `rzkeychange.so`: RFC8145 key tag signal collection and reporting plugin
135- `txtout.so`: Dump DNS as one-line text
136- `eventlog.so`: Syslog style output for easy parsing, use with a SIEM, etc.
137
138There is also a `template` plugin in the source repository to help others
139develop new plugins.
140
141## CBOR DNS Stream Format
142
143This is an experimental format for representing DNS information in CBOR
144with the goals to:
145- Be able to stream the information
146- Support incomplete, broken and/or invalid DNS
147- Have close to no data quality and signature degradation
148- Support additional non-DNS meta data (such as ICMP/TCP attributes)
149
150Read [CBOR_DNS_STREAM.md](https://github.com/DNS-OARC/dnscap/blob/develop/CBOR_DNS_STREAM.md) for more information.
151
152To enable this output please follow the instructions below for Enabling
153CBOR Output, note that this only requires Tinycbor.
154
155### Outputting to CBOR DNS Stream (CDS)
156
157To output to the CDS format you tell `dnscap` to write to a file and set
158the format to CDS.  CDS is a stream of CBOR objects and you can control how
159many objects are kept in memory until flushed to the file by setting
160`cds_cbor_size`, note that this is bytes of memory and not number of objects.
161When it reaches this limit it will write the output and start on a new file.
162Read `dnscap`'s man page for all CDS extended options.
163
164```
165src/dnscap [...] -w <file> -F cds [ -o cds_cbor_size=<bytes> ]
166```
167
168## CBOR
169
170There is experimental support for CBOR output using LDNS and Tinycbor with
171a data structure described in the DNS-in-JSON draft.
172
173https://datatracker.ietf.org/doc/draft-hoffman-dns-in-json/
174
175### Enabling CBOR Output
176
177To enable the CBOR output support you will need to install it's dependencies
178before running `configure`, LDNS exists for most distributions but Tinycbor
179is new so you need to download and compile it, you do not necessary need to
180install it as shown in the example below.
181
182```sh
183git clone https://github.com/DNS-OARC/dnscap.git
184cd dnscap
185git submodule update --init
186git clone https://github.com/01org/tinycbor.git
187cd tinycbor
188git checkout v0.4.2
189make
190cd ..
191sh autogen.sh
192CFLAGS="-I$PWD/tinycbor/src" LDFLAGS="-L$PWD/tinycbor/lib" LIBS="-ltinycbor" ./configure
193make
194```
195
196**NOTE**: Paths in `CFLAGS` and `LDFLAGS` must be absolute.
197
198### CBOR to JSON
199
200Tinycbor comes with a tool to convert CBOR to JSON, check `bin/cbordump -h`
201in the Tinycbor directory after having compiled it.
202
203### Outputting to CBOR
204
205To output to the CBOR format you tell `dnscap` to write to a file and set
206the format to CBOR.  Since Tinycbor constructs everything in memory there
207is a limit and when it is reached it will write the output and start on a
208new file.  You can control the number of bytes with the extended option
209`cbor_chunk_size`.
210
211```
212src/dnscap [...] -w <file> -F cbor [ -o cbor_chunk_size=<bytes> ]
213```
214
215### Additional attributes
216
217There is currently an additional attribute added to the CBOR object which
218contains the IP information as following:
219
220```
221"ip": [
222  <proto>,
223  "<source ip address>",
224  <source port>
225  "<destination ip address>",
226  <destination port>
227]
228```
229
230Example:
231
232```json
233"ip": [
234  17,
235  "127.0.0.1",
236  34856,
237  "127.0.0.1",
238  53
239]
240```
241
242### Limitations, deviations and issues
243
244Since this is still experimental there are of course some issues:
245- RDATA is in binary format
246- DNS packet are parsed by LDNS which can fail if malformed packets
247- `dateSeconds` is added as a C `double` which might loose some of the time precision
248