Skip to content

Latest commit

 

History

History
92 lines (77 loc) · 4.57 KB

dns.md

File metadata and controls

92 lines (77 loc) · 4.57 KB

DNS [r]

Structured log of every DNS query and response seen on UDP/53.

Protocol

DNS (Domain Name System, RFC 1034

  • RFC 1035) is the lookup service that turns names into IPs. The wire format is plaintext over UDP/53 (TCP/53 for large responses + zone transfers). Sloth parses the header (12 bytes), the question section, and the first answer record — it does not call out to a resolver; only what's already crossing the wire.

This view was always passive. What changed in #84 slice 2 is the rest of sloth: the reverse-DNS resolver behind the hostname columns elsewhere in the TUI is now off by default, its worker thread is never started without --allow-active, and --strict locks that for the run. So the names sloth shows come from this snooped traffic unless an operator explicitly opted into asking.

What sloth captures

Per entry: source IP, qname (query name), qtype (A, AAAA, PTR, MX, NS, CNAME, TXT, SRV), the first A/AAAA answer or NXDOMAIN, and the Q/R flag. For a PTR question the answer is the first PTR record's target name (#165, RFC 1035 §3.3.12), in the last column and cut only where the row meets the screen's edge; a PTR record answering any other qtype is ignored, and a target that would be cut at 63 bytes, is the root name, reads NXDOMAIN, or does not fill its RDATA exactly is skipped. A PTR row's answer is never read as an address: it stays out of the host cache, the IP index, the captive-portal DNS check and the dashboard's IP colouring. src/dns_log.c walks the message itself but decodes names through dns_read_name() in src/dns_wire.c (#131), the one RFC 1035 §4.1.4 reader every DNS-family parser shares (dns_snoop, mdns_snoop, nbns_snoop). A compression loop ends after 20 pointers followed, and the reserved label types 01/10 are refused rather than read as lengths. The qname is marked (netstr_copy, #138) when it is stored here, and again when dns_snoop stores it in the passive DNS cache.

View

 ── DNS log  /chrome/ ───────────────────────────────────────────────
 Time      Src              Q/R  Type   Name                  Answer
 18:16:40  192.168.1.5      R    A      google.com            142.250.80.46
 18:16:40  192.168.1.5      Q    AAAA   reddit.com            -
 18:16:40  192.168.1.10     R    A      ghost.local           NXDOMAIN
 18:16:40  192.168.1.5      R    A      cloudflare.com        104.16.132.229
 18:16:40  10.0.0.50        R    A      <random>.example.org  93.184.216.34
                                        └──────────────┘
                                        brand-coloured: google
                                        rainbow, cloudflare red,
                                        firefox orange, example.org grey

Q-row colour: dim. R-row with IP answer: bright Fallout phosphor. NXDOMAIN: heat orange. AAAA: cool teal.

What's normal

  • Most queries are A and AAAA for popular domains; responses come back within a fraction of a second.
  • A burst on startup, then steady-state of 1–10 q/s per active client.
  • NXDOMAIN ratio under 5% — typos, autofill misses.

What's suspicious

  • NXDOMAIN burst: ≥10 NXDOMAIN responses to one source in 60 s. Triggers ALERT_NXDOMAIN_BURST. Common signal for DGA-based malware — the implant tries hundreds of random-looking names until one resolves.
  • High-entropy qnames: gfh3jksdfh92.example.com-style labels — DGA, DNS tunnelling (data exfil), or cache busting.
  • Long TXT queries: TXT records carrying base64 are a tunnel signature (iodine, dnscat2).
  • Threat-intel hits: qname matches the IOC list → ALERT_THREAT_DOMAIN fires CRIT. The shipped list is synthetic demo data — it matches nothing real, so this fires only once you replace it with your own feed. See [[threat-intel]].
  • Resolver redirection: queries going to an IP that isn't your configured resolver may indicate DNS hijack (router compromise, ARP spoof + transparent proxy).

See also

  • The brand colouriser highlights google letter-by-letter (Google logo colours), and firefox / cloudflare / example.org in their brand colours.
  • Threat intel list lives in src/threat_intel.c — synthetic demo data, not a feed ([[threat-intel]]).