| layout | default |
|---|---|
| title | Labs |
| numbered | false |
These exercises teach subdomain enumeration on fictional zones. -simulate-zone
loads a scenario file and answers every query from a DNS server that subenum
runs on 127.0.0.1 for the length of the scan. No DNS traffic leaves your
machine, so labs are safe in a classroom, a CTF or an air-gapped VM.
Unlike -simulate, which invents results from a hit rate, a lab runs the real
resolver against the scenario. Wildcard detection, -rate pacing, retries, the
reliability guard and the run-quality report all behave exactly as they would
against a live zone, and the results are the same on every run.
You need a subenum binary (see Installation).
The scenarios and their wordlist are built into it, so the labs run from any
directory: -simulate-zone lab1 (or lab1-first-scan) picks the built-in
scenario, and without -w the scan uses the labs' short wordlist. For a
zero-install classroom, open the labs in GitHub Codespaces:
the container builds ./subenum, opens this page and the first scenario, and
prints the lab 1 command.
Every lab scans lab.example. To edit a scenario or write your own, copy one
from examples/labs
and pass its path instead, for example -simulate-zone ./my-lab.zone; a path
uses the bundled 5,000-word list unless you add -w.
Labs run from the command line. Combining -tui with an active -simulate-zone
setting (including SUBENUM_SIMULATE_ZONE or a config-file value) exits with
usage error 2 before the interface opens. Remove -tui to run the lab.
Each lab ends with questions. The answers are folded underneath; try first.
subenum -simulate-zone lab1 -show-records lab.example-show-records prints the records behind each name.
- How many subdomains did the scan find?
- Which host has an IPv6 address?
shophas the same address aswww. Why?- The scenario file defines
blog, but it is not in the results. Rerun with-type A,AAAA,CNAME. What isblog, and why did the default scan miss it?
Answers
- Five:
www,mail,vpn,jenkinsandshop. www(2001:db8::10).shopis a CNAME (an alias) forwww. The resolver follows the alias and returnswww's addresses. The CNAME run showsCNAME=www.lab.example.blogis a CNAME toghost-lab.example.net, a host that does not exist. The default lookups (A and AAAA) find no address, so the name looks empty. With CNAME lookups, subenum shows the alias and flags itTAKEOVER?=dangling: the alias points at a name nobody has registered. If that were a cloud service, whoever claimed the name would controlblog.lab.example. This is how subdomain takeovers start. See takeover hints in the README.
subenum -simulate-zone lab2 lab.example- What does subenum report, and why does it refuse to continue?
- Rerun with
-force. Which names are reported now, and how does subenum tell them apart from the wildcard?
Answers
- "Wildcard DNS detected": the zone has a
*record, so every name, even a random one, resolves to192.0.2.250. Without filtering, every word in the list would be reported as a "finding". www,portalandintranet. Before scanning, subenum queries several random names to fingerprint the wildcard's answer. With-forceit then drops every result that matches that fingerprint; these three have their own addresses, so they are real hosts. Thewildcard-filteredline counts the rest.
This resolver answers REFUSED once it gets more than 40 queries in a second, as many public and corporate resolvers do.
subenum -simulate-zone lab3 -stats lab3.json lab.example
subenum -simulate-zone lab3 -stats lab3-paced.json -rate 30 lab.example- Compare the
refusedcounts of the two runs. - Open both
-statsreports. What is each run'sverdict? - Why can the first run still list some real names, and why should you not trust it anyway?
Answers
- The first run bursts with 100 workers and most of its lookups are refused.
The paced run (
-rate 30, under the resolver's 40-per-second limit) has none. unreliablefor the burst,completefor the paced run.- The first queries arrived before the limit kicked in, so whatever they found is real. But a REFUSED name was never actually checked: it might exist. A run with many refusals says nothing about the names it missed, which is why the report calls it unreliable. Slower is faster here.
subenum -simulate-zone lab4 lab.example
subenum -simulate-zone lab4 -recursive -depth 3 lab.example- How many names does the flat scan find? How many does the recursive scan find?
- Which name needed
-depth 3? - Try the recursive scan with the bundled 5,000-word list (add
-w ""). What happens, and why?
Answers
- Three (
www,dev,corp) against eight. Recursion takes every name it finds and enumerates the wordlist under it, which turns upapi.dev,git.dev,staging.devandvpn.corp, thenadmin.staging.dev. admin.staging.dev, three labels belowlab.example.- subenum refuses to start: with 5,000 words, depth 3 could mean over 100
billion queries. Recursion multiplies the wordlist at every level, so it
asks you to set
-max-queries(or-force) first. Against a real target, that guard is what keeps a scan from becoming a flood. A shorter list for the deeper levels also keeps it small:-recursive-wnames the labels tried under each name found, so-wwith 5,000 words and-recursive-wwith 100 cost 5,000 queries for depth 1 and 100 for each name found.
subenum -simulate-zone lab5 -timeout 300 -stats lab5.json lab.example- Which outcome lines in the breakdown are non-zero besides
resolvedandnxdomain? - What is the run's
verdictinlab5.json, and what does it mean for the names that failed?
Answers
timeout(legacyandoldnever answer),refused(beta) andother(backupanswers SERVFAIL).degraded: the scan finished, but some names could not be checked. A failed lookup is not "does not exist". Those names need a retry (-attempts) or a different resolver before you can rule them out.
subenum -simulate-zone lab6 -show-records lab.example
subenum -simulate-zone lab6 -type A -show-records lab.example
subenum -simulate-zone lab6 -type AAAA -show-records lab.example- Which three names does the default scan find, and which address families does each have?
- Which name disappears with
-type A? Does that mean the service is absent? - Which name disappears with
-type AAAA? Why does the default scan find both?
Answers
wwwhas bothA=192.0.2.10andAAAA=2001:db8::10;apihas onlyAAAA=2001:db8::20;legacyhas onlyA=192.0.2.30.apidisappears. It exists but has no IPv4 address: an A-only lookup cannot discover an IPv6-only service.legacydisappears because it has no IPv6 address. The default types areA,AAAA, and a record of either type is enough to report a name. Querying both families does not require the machine to have IPv6 connectivity: this lab's DNS server still answers on IPv4 loopback (127.0.0.1).
subenum -simulate-zone lab7 -format jsonl lab.example
subenum -simulate-zone lab7 -axfr -format jsonl lab.exampleThe lab's name server hands its whole zone to anyone who asks, the
misconfiguration -axfr looks for. In lab mode the transfer goes to the lab
server, never to the name server's real address.
- Which names does the second run find that the first does not, and what is
their
sources? - What does the second run print on stderr about the name server?
- Copy
examples/labs/lab7-zone-transfer.zone, delete its$TRANSFER allowline and run the copy with-axfr -v. What changes?
Answers
billing-legacy,k8s-ingress-eu2andns1: no wordlist holds them. Theirsourcesis["axfr"], whilewww,mailandvpnsay["wordlist", "axfr"]. Every transferred name is still looked up, so a stale entry would not be reported.- That
ns1.lab.exampleallowed a transfer oflab.exampleand that anyone can list the zone: a finding to report in itself.-statsnames the server underaxfr_allowed. - The server refuses, as most do. The scan is the wordlist's alone, and
-vsays that no name server allowed a transfer.
subenum -simulate-zone lab8 -format jsonl lab.example
subenum -simulate-zone lab8 -nsec-walk -format jsonl lab.exampleThe zone is signed with plain DNSSEC NSEC and refuses transfers. Every
answer that says a name does not exist also names the next name that does,
so -nsec-walk can list the whole zone, one query per name. In lab mode
the walk goes to the lab server.
- Which names does the second run find that the first does not, and what is
their
sources? - How many queries did the walk take, and why that many?
- Copy
examples/labs/lab8-nsec-walk.zone, change$DNSSEC nsecto$DNSSEC nsec3and run the copy with-nsec-walk. What changes?
Answers
payroll-archive,qa.build-farmandns1: no wordlist holds them. Theirsourcesis["nsec"], whilewww,mailandvpnsay["wordlist", "nsec"]. Every walked name is still looked up.- Seven: one per name in the chain, the apex included, until the last
record leads back to the apex.
-statscounts the names undernsec_names. - NSEC3 records hold hashes of names, not names, so there is nothing to follow: subenum says it is not walking the zone and why, and the scan is the wordlist's alone.
subenum -simulate-zone lab9 -format jsonl lab.example
subenum -simulate-zone lab9 -type A,NS -format jsonl -stats run.json lab.examplelegacy is a subzone delegated to two name servers that no longer exist, so
the lab's resolver, which cannot reach either, answers SERVFAIL for it, as a
real one would. Whoever registers legacy-dns.example would answer for every
name under legacy. staging is delegated to a name server that still
answers. With NS in -type, subenum asks the zone's own name server about a
name that ends SERVFAIL, without asking it to recurse, and gets the
delegation back as a referral. In lab mode that query goes to the lab
server.
- How does
legacyend in the first run, and in the second? - What does the second run's report say about the extra queries?
- Why is
stagingnot marked?
Answers
- The first run counts it under
other(inconclusive): withoutNSnothing asks the zone. The second reports it with its two NS records and"takeover_candidate":"dangling-ns", because both name servers are NXDOMAIN. parent_checksis 1 (one name was asked about) andparent_queriesis 1;queries_sentincludes it. The query takes a-rateslot like any other.- Its name server,
ns1.lab.example, exists, so a resolver gets its NS records directly and there is nothing to take over.
subenum -simulate-zone lab10 -format jsonl lab.example
subenum -simulate-zone lab10 -type A,CNAME -format jsonl lab.exampleshop and docs are aliases for apps on two hosting providers, Heroku and
GitHub Pages, and both apps were deleted: the alias targets no longer exist.
Whoever creates an app with the same name on the provider would serve those
names, which is a subdomain takeover. old points at a host that is gone too,
but on no provider subenum knows. blog is an alias that still works. In lab
mode every name outside lab.example is NXDOMAIN, so the deleted apps behave
as they would on the real providers.
- Which names does the first run report, and why not the others?
- What does each name get as
takeover_candidatein the second run? - Why is
blognot marked, although it is a CNAME too?
Answers
www,mailandblog. WithoutCNAMEin-type, a name counts as found only when its A or AAAA lookup answers, and the A lookups ofshop,docsandoldfollow the alias to a target that does not exist, so they end NXDOMAIN like a name that was never there.shopisdangling:herokuanddocsisdangling:github-pages: the target does not exist and its suffix (.herokudns.com,.github.io) belongs to a provider where an unclaimed name can be registered.oldis plaindangling: worth cleaning up, but there is no known provider to claim it on. The run-quality report counts all three intakeover_candidates.- Its target,
www.lab.example, exists, so there is nothing to claim. A CNAME to a provider whose target does exist is markedprovider:<name>instead, a lead to check by hand rather than a finding.
Lab 11: SRV records and a dangling SRV target{% include unreleased.html value="simulate-zone=lab11" %}
subenum -simulate-zone lab11 -type A,SRV -format jsonl lab.example
subenum -simulate-zone lab11 -srv -type A,SRV -format jsonl lab.exampleAn SRV record names the host and port a service runs on, and it lives at a
service name such as _sip._tcp, not at a host name, so a host-name wordlist
never finds it. -srv adds about 50 common service names to every target.
Here the voice service (_sip._tcp) and the directory (_ldap._tcp) point at
hosts in the zone, while the mail clients' autodiscover record still names a
hosted mail service that was cancelled.
- What does the second run find that the first does not, and what are its
sources? - Which service is a
takeover_candidate, and why does that matter? - What happens if you run the second command with
-type Ainstead of-type A,SRV?
Answers
_sip._tcp,_ldap._tcpand_autodiscover._tcp, each with"sources":["srv"]: they came from the built-in service list, not the wordlist. Their records read<priority> <weight> <port> <target>, such as10 60 5060 sip.lab.example._autodiscover._tcpisdangling-srv: its target,autodiscover.old-mail-host.example, does not exist. Whoever registers it receives the mail clients' autodiscover requests, and with them their logins.- subenum refuses to start (usage error, exit 2) and asks you to add
SRVto-type: the service names have SRV records only, so their A lookups would all end NXDOMAIN and the pass would find nothing.
A scenario is a plain text file. Names are relative to the domain you scan,
and # starts a comment:
$DELAY 20ms # every answer waits this long
$REFUSE-ABOVE 50 # answer REFUSED past 50 queries a second
$TRANSFER allow # answer a zone transfer (-axfr); the default is refuse
$DNSSEC nsec # prove absent names with NSEC (-nsec-walk), or nsec3; the default is none
@ A 192.0.2.1 # the scanned domain itself
www A 192.0.2.10
www AAAA 2001:db8::10
shop CNAME www # relative target
blog CNAME ghost.example.net. # absolute target (trailing dot)
*.dev A 192.0.2.99 # wildcard under dev
mail MX 10 mx1 # preference and host (relative or absolute)
@ TXT "v=spf1 -all" # the rest of the line; quotes optional
@ HTTPS 1 . alpn=h2,h3 port=443 # priority, host ("." or a name), alpn and port (-type HTTPS)
cdn HTTPS 0 edge.example.net. # AliasMode: points cdn at another host, like a CNAME
sub NS ns1.gone.example. # a delegated subzone (scan with -type NS)
slow TIMEOUT # never answered
broken SERVFAIL # also: REFUSED, NXDOMAIN
192.0.2.10 PTR host-12.dc1 # reverse DNS of an address (-ptr); relative or absolute host
Start a scenario in examples/labs with a comment saying what it teaches
(# Lab 6: <title>. <what to look for>): subenum mcp shows that comment,
without the lab number and any indented command line, to agents choosing a
scenario.
Names the file does not define are NXDOMAIN. The scenario is the whole world
during a lab, so names outside the scanned domain (such as an external CNAME
target) are NXDOMAIN too. A CNAME to a name in the scenario is followed as a
recursive resolver follows it, through further CNAMEs (up to 8) and
wildcards, so a CNAME b, b CNAME www answers with www's addresses. An
AAAA value must be a real IPv6 address: an IPv4-mapped one such as
::ffff:192.0.2.1 is rejected. An answer too big for the client's UDP
buffer comes back truncated, so the client asks again over TCP. Use the
documentation ranges (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24,
2001:db8::/32) and reserved names such as lab.example, so nothing in a
lab points at a real host.
Scenarios work with the other flags, such as -dL (each listed domain gets
the same zone), -permute, -diff, -format json and -stats, which
records the scenario file under zone. With -axfr or -nsec-walk, the
transfer, the DNSSEC probe and the walk go to the lab server, whatever
address the scenario gives its name servers. With $DNSSEC nsec, an answer
for a name the file does not define carries the NSEC record that covers it,
from a chain of the apex, the defined names (not failing ones) and the
wildcards. A delegation none of whose name servers has an address in the
scenario (such as sub above) answers SERVFAIL for itself and every name
under it, as a resolver that cannot reach them does, and a query that does
not ask for recursion gets a referral to them, as from the parent zone's
server; a delegation with one name server that answers is served from the
file. -simulate-zone cannot be combined
with -simulate, -dns-server, -r, -ct or -sources, whether they
come from the command line, a SUBENUM_* variable or the config file: a lab run refuses to start
rather than send a query off the machine.