Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ No flags required. Fill in the form and press `ctrl+r` to start scanning. Last-u

<br>

Flags and a domain given with `-tui` fill the form, so a prepared command line opens ready to run: `./subenum -tui example.com -w big.txt -r resolvers.txt`. The form takes one wordlist (the first `-w`), and `-tui` warns about any flag it has no field for. **Wordlist is optional:** leave the field empty to scan with the bundled top-5000 list, as a missing `-w` does on the command line. The **Resolver Pool** and **Rate/Resolver** fields are `-r` and `-rate-per-resolver`; the pool is not used with Simulate on. **Auto Rate**, **Max Duration** (blank for none, or a duration such as `20m`) and **Retry Inconclusive** are `-auto-rate`, `-max-duration` and `-retry-inconclusive`. **Sources** takes what `-sources` does (`ct`, `wayback` or both; `-ct` fills in `ct`): the sources are asked while the wordlist loads, their names are scanned with the wordlist's, and a source that fails is a warning on the scan screen, not a failed scan; they are not asked with Simulate on. **Permute** is `-permute`: when the scan finishes, a second pass scans permutations of the names found, and its results are marked on the scan screen. With either field set, the results file says what proposed each name, as the CLI's does.
Flags and a domain given with `-tui` fill the form, so a prepared command line opens ready to run: `./subenum -tui example.com -w big.txt -r resolvers.txt`. The form takes one wordlist (the first `-w`), and `-tui` warns about flags it has no field for, except `-simulate-zone`: lab mode is rejected with exit 2 before the TUI opens. Run labs without `-tui`. **Wordlist is optional:** leave the field empty to scan with the bundled top-5000 list, as a missing `-w` does on the command line. The **Resolver Pool** and **Rate/Resolver** fields are `-r` and `-rate-per-resolver`; the pool is not used with Simulate on. **Auto Rate**, **Max Duration** (blank for none, or a duration such as `20m`) and **Retry Inconclusive** are `-auto-rate`, `-max-duration` and `-retry-inconclusive`. **Sources** takes what `-sources` does (`ct`, `wayback` or both; `-ct` fills in `ct`): the sources are asked while the wordlist loads, their names are scanned with the wordlist's, and a source that fails is a warning on the scan screen, not a failed scan; they are not asked with Simulate on. **Permute** is `-permute`: when the scan finishes, a second pass scans permutations of the names found, and its results are marked on the scan screen. With either field set, the results file says what proposed each name, as the CLI's does.

</details>

Expand Down
4 changes: 4 additions & 0 deletions docs/labs.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ L=examples/labs
W="-w $L/words.txt"
```

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.

## Lab 1: a first scan
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ func TestPrintConfigEffectiveAttempts(t *testing.T) {
// tuiOmittedFlags are flags the TUI form deliberately has no field for: they
// control CLI-only output, input sources, run state or modes the form does not
// offer, so a command-line, SUBENUM_* or config file value for them never
// seeds the form (-tui warns about one given on the command line). The one
// exception is -ct, which tuiOptions turns into ct in the Sources field (#348).
// seeds the form (-tui warns about one given on the command line). Lab zones
// are rejected before the form opens; -ct becomes ct in Sources (#348).
var tuiOmittedFlags = map[string]bool{
"tui": true, "print-config": true, "dry-run": true, "version": true, "v": true, "progress": true, "silent": true,
"simulate-zone": true, "retries": true, "show-records": true, "stats": true,
Expand Down
36 changes: 36 additions & 0 deletions internal/cli/lab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,42 @@ func TestE2ELabFlagConflicts(t *testing.T) {
}
}

// A lab request must be rejected before the TUI can discard it (#356).
func TestE2ETUIRefusesLab(t *testing.T) {
zone := filepath.Join("examples", "labs", "lab1-first-scan.zone")
cfg := writeFile(t, "config.json", `{"simulate-zone": "`+filepath.ToSlash(zone)+`"}`)
for _, tc := range []struct {
name, env, value, want string
args []string
}{
{name: "flags", want: "-simulate-zone", args: []string{"-tui", "-simulate-zone", zone, "lab.example"}},
{name: "interspersed", want: "-simulate-zone", args: []string{"-simulate-zone", zone, "lab.example", "--tui"}},
{name: "no domain", want: "-simulate-zone", args: []string{"-tui", "-simulate-zone", zone}},
{name: "environment", env: "SUBENUM_SIMULATE_ZONE", value: zone, want: "SUBENUM_SIMULATE_ZONE", args: []string{"-tui", "lab.example"}},
{name: "config", env: configEnv, value: cfg, want: "config file", args: []string{"-tui", "lab.example"}},
{name: "json", want: "-simulate-zone", args: []string{"-tui", "-simulate-zone", zone, "-log-format", "json", "lab.example"}},
} {
t.Run(tc.name, func(t *testing.T) {
if tc.env != "" {
t.Setenv(tc.env, tc.value)
}
code, stdout, stderr := runCLIStreams(t, tc.args...)
if code != exitUsage || stdout != "" {
t.Errorf("exit %d, stdout %q; want exit %d and no scan output", code, stdout, exitUsage)
}
if !strings.Contains(stderr, "-tui") || !strings.Contains(stderr, tc.want) || !strings.Contains(stderr, "run the lab without -tui") {
t.Errorf("missing lab/TUI conflict diagnostic naming %q: %s", tc.want, stderr)
}
if tc.name == "json" {
lines := parseLogLines(t, stderr)
if len(lines) != 1 || lines[0].Level != "error" {
t.Errorf("diagnostics = %+v, want one JSON error", lines)
}
}
})
}
}

// TestE2ELabRefusesEnvAndConfigResolvers covers #106: a resolver list or
// simulation mode from SUBENUM_* or the config file must not turn a lab run
// into one that sends queries off the machine.
Expand Down
5 changes: 5 additions & 0 deletions internal/cli/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ func (s *session) parse() (code int, done bool) {
// -tui counts only as a real flag, not as the value of another flag
// (-o -tui) or an argument after "--" (#58).
if f.tui {
// The form cannot represent lab zones; never discard a lab request.
if f.simZone != "" {
diag.Error("-tui cannot be combined with %s; run the lab without -tui", defaults.describe(fs, "simulate-zone"))
return exitUsage, true
}
return tui.Start(tuiOptions(f, fs, positionals, defaults, diag)), true
}

Expand Down
Loading