Skip to content

Targets and Input

Choosing templates decides what is asked; this chapter is about who gets asked. Nuclei accepts targets three ways, and the lab used all three, because each suits a different shape of work.

One target, or a few: -u

$ nuclei -duc -nc -ni -id http-missing-security-headers -u http://127.0.0.1:18084

-u (also -target) takes a URL or a host, and can be given several times or with several values. A full URL — scheme, host, port, path — is the unambiguous form, and every chapter so far has used it.

A bare host works too. The lab verified it against the fixture:

$ nuclei -duc -nc -ni -silent -t examples/lab-server-banner.yaml -u 127.0.0.1:18084
[lab-server-banner] [http] [info] http://127.0.0.1:18084/

Given no scheme, nuclei works out how to talk to the target — the match was reported against http://…, because plain HTTP is what the fixture speaks. Convenience, with a caution: on a target that answers on both HTTP and HTTPS, the bare form tests what it reaches, which may not be the service you meant. For anything you care about, write the scheme.

A list: -l

Real scanning is list-shaped — every web service on a network, every host in an inventory. -l (also -list) reads targets from a text file, one per line:

$ cat examples/targets.txt
http://127.0.0.1:18084
http://127.0.0.1:18085
http://127.0.0.1:18086

$ nuclei -duc -nc -ni -t examples/ -l examples/targets.txt

The lab ran exactly this against three fixture instances on three ports: three templates times three targets produced nine findings (the rate-limit chapter times this same run). A list file is also the natural hand-off from other tools — an inventory, a port scan's survivors, a subnet's web servers — with one discipline attached: a line in a target file is a door you are about to knock on, so the file deserves the same "is this mine to test?" reading as any single -u, once per line, before the run.

A pipe: standard input

With no -u and no -l, nuclei reads targets from standard input, which makes it a citizen of shell pipelines:

$ echo http://127.0.0.1:18084 | nuclei -duc -nc -ni -silent -t examples/lab-server-banner.yaml
[lab-server-banner] [http] [info] http://127.0.0.1:18084/

This guide can testify to the behaviour from an unexpected angle: the lab's first attempts to run nuclei inside its own build scripts appeared to hang, banner printed and then silence, because the engine was politely waiting for targets on a pipe nobody was going to fill. Chapter 12 has the symptom and the fix. The rule for scripts is simple: if targets are not coming from the pipe, say so — redirect input from /dev/null — or pass targets explicitly.

What a target becomes

However it arrives, each target is expanded by every template's paths: give the engine a host and a template that asks for /status, and the request that leaves is for the host's /status. Two consequences worth knowing:

  • Targets are multiplied by templates. Three targets and three templates were nine checks; three hundred targets and the full collection is over four million. The politeness chapter is mostly arithmetic like this, done before the run instead of after.
  • Not every template speaks to every target. A DNS template needs a hostname, a network template a socket; targets a template can't use are skipped for that template. A scan of a mixed list is several overlapping scans, and the loaded/target counts in the output header describe the whole, not each pairing.

Check: whatever the input shape, the run should open by telling you how many targets it loaded — and that number should be the one you expected, from a list you can defend line by line.