Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
176 lines (149 loc) · 6.93 KB
/
Copy pathMakefile
File metadata and controls
176 lines (149 loc) · 6.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
.PHONY: all build test test-short bench docs-flags clean lint tidy tui run run-verbose run-custom require-domain \
simulate simulate-verbose simulate-custom wordlist wordlist-gen docker-build docker-run docker-simulate help
# Default Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=subenum
WORDLIST_GEN=wordlist-gen
VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || echo dev)
LDFLAGS = -ldflags "-X main.Version=$(VERSION)"
# Default run parameters. Live targets (run, run-verbose, run-custom,
# docker-run) have no default DOMAIN: they send real DNS queries, so you must
# name a domain you own or are authorized to test, e.g. make run DOMAIN=...
# Parameters use ?= so both `make VAR=x target` and `VAR=x make target` work.
WORDLIST ?= examples/sample_wordlist.txt
CONCURRENCY ?= 100
TIMEOUT ?= 1000
DNS_SERVER ?= 8.8.8.8:53
# Simulation parameters. Simulated targets send no DNS traffic, so they fall
# back to example.com when DOMAIN is not set.
HIT_RATE ?= 15
SIM_DOMAIN=$(or $(DOMAIN),example.com)
# Wordlist generator parameters
WL_DOMAIN ?= $(SIM_DOMAIN)
WL_COMBINE ?= dev,staging,test,api
WL_OUTPUT ?= custom-wordlist.txt
all: build
build:
$(GOBUILD) -buildvcs=false $(LDFLAGS) -o $(BINARY_NAME)
test:
$(GOTEST) -v ./...
test-short:
$(GOTEST) -v ./... -short
# Regenerate the site's flag table (docs/_includes/flags.md) from the CLI's
# flags; a test fails CI when it drifts (#64).
docs-flags:
UPDATE_DOCS=1 $(GOTEST) -run '^TestSiteFlagTableUpToDate$$' -count=1 .
# Dispatcher throughput on a 1M-entry simulated scan; overhead must stay
# linear in wordlist size (#49).
bench:
$(GOTEST) ./internal/scan -run '^$$' -bench BenchmarkRun1M -benchtime 1x
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_NAME).exe
rm -f tools/$(WORDLIST_GEN)
lint:
golangci-lint run
# go mod tidy. The go directive must stay go 1.26.0 (CI checks it; x/sys and x/text need it).
tidy:
go mod tidy
# Build wordlist generator
wordlist-gen:
$(GOBUILD) -buildvcs=false -o tools/$(WORDLIST_GEN) tools/wordlist-gen.go
# Generate a custom wordlist
wordlist: wordlist-gen
tools/$(WORDLIST_GEN) -f -domain $(WL_DOMAIN) -combine $(WL_COMBINE) -o $(WL_OUTPUT)
@echo "Generated wordlist: $(WL_OUTPUT)"
@echo "Use it with: make WORDLIST=$(WL_OUTPUT) DOMAIN=$(WL_DOMAIN) run-verbose"
# Launch the interactive TUI (one-click, no arguments needed)
tui: build
./$(BINARY_NAME) -tui
# Live targets refuse to run without an explicit DOMAIN.
require-domain:
ifndef DOMAIN
$(error Live scans send real DNS queries. Set DOMAIN to a domain you own or are authorized to test, e.g. make run DOMAIN=yourdomain.com, or use make simulate)
endif
# Run with default parameters (LIVE)
run: require-domain build
./$(BINARY_NAME) -w $(WORDLIST) -t $(CONCURRENCY) -timeout $(TIMEOUT) -dns-server $(DNS_SERVER) $(DOMAIN)
# Run with verbose output (LIVE)
run-verbose: require-domain build
./$(BINARY_NAME) -w $(WORDLIST) -t $(CONCURRENCY) -timeout $(TIMEOUT) -dns-server $(DNS_SERVER) -v $(DOMAIN)
# Run in simulation mode (safe, no actual DNS queries)
simulate: build
./$(BINARY_NAME) -simulate -hit-rate $(HIT_RATE) -w $(WORDLIST) -t $(CONCURRENCY) -timeout $(TIMEOUT) $(SIM_DOMAIN)
# Run in simulation mode with verbose output (safe, no actual DNS queries)
simulate-verbose: build
./$(BINARY_NAME) -simulate -hit-rate $(HIT_RATE) -w $(WORDLIST) -t $(CONCURRENCY) -timeout $(TIMEOUT) -v $(SIM_DOMAIN)
# Generate a wordlist and use it with simulation mode
simulate-custom: wordlist build
./$(BINARY_NAME) -simulate -hit-rate $(HIT_RATE) -w $(WL_OUTPUT) -t $(CONCURRENCY) -timeout $(TIMEOUT) -v $(WL_DOMAIN)
# Generate a wordlist and immediately use it (LIVE)
run-custom: require-domain wordlist build
./$(BINARY_NAME) -w $(WL_OUTPUT) -t $(CONCURRENCY) -timeout $(TIMEOUT) -dns-server $(DNS_SERVER) -v $(DOMAIN)
# Docker commands
docker-build:
docker build --build-arg VERSION=$(VERSION) -t $(BINARY_NAME) .
# LIVE. $(CURDIR) rather than $(PWD), which is empty under Windows make.
docker-run: require-domain
docker run --rm -v "$(CURDIR)/data:/data" $(BINARY_NAME) -w /data/wordlist.txt -v $(DOMAIN)
# Run Docker in simulation mode (completely safe)
docker-simulate:
docker build --build-arg VERSION=$(VERSION) -t $(BINARY_NAME) .
docker run --rm $(BINARY_NAME) -simulate -hit-rate $(HIT_RATE) -w /home/nonroot/examples/sample_wordlist.txt -v $(SIM_DOMAIN)
# Help command
help:
@echo "Available commands:"
@echo " make build - Build the binary (also: make all)"
@echo " make test - Run all tests (CI also uses -race -shuffle=on)"
@echo " make test-short - Run short tests"
@echo " make bench - Dispatcher benchmark on a 1M-entry simulated scan"
@echo " make docs-flags - Regenerate docs/_includes/flags.md from the CLI flags"
@echo " make clean - Clean build artifacts"
@echo " make lint - Run linter"
@echo " make tidy - go mod tidy (keeps go 1.26.0)"
@echo " make tui - Launch the interactive terminal UI (no arguments needed)"
@echo ""
@echo " LIVE MODE (performs real DNS queries):"
@echo " make run DOMAIN=x - Build and scan DOMAIN (required, no default)"
@echo " make run-verbose DOMAIN=x - Build and scan DOMAIN with verbose output"
@echo " make run-custom DOMAIN=x - Generate a wordlist and scan DOMAIN with it"
@echo ""
@echo " SIMULATION MODE (safe, no real DNS queries):"
@echo " make simulate - Run in simulation mode (no actual DNS queries)"
@echo " make simulate-verbose - Run in simulation mode with verbose output"
@echo " make simulate-custom - Generate a wordlist and simulate scan with it"
@echo ""
@echo " WORDLIST GENERATION:"
@echo " make wordlist-gen - Build the wordlist generator tool"
@echo " make wordlist - Generate a custom wordlist"
@echo ""
@echo " DOCKER:"
@echo " make docker-build - Build Docker image"
@echo " make docker-run DOMAIN=x - Run Docker container (live mode)"
@echo " make docker-simulate - Run Docker container in simulation mode"
@echo ""
@echo "IMPORTANT: Only use live mode against domains you own or have explicit permission to test."
@echo ""
@echo "Default parameters:"
@echo " WORDLIST=$(WORDLIST)"
@echo " DOMAIN=$(DOMAIN) (required for live targets; simulate uses $(SIM_DOMAIN))"
@echo " CONCURRENCY=$(CONCURRENCY)"
@echo " TIMEOUT=$(TIMEOUT)"
@echo " DNS_SERVER=$(DNS_SERVER)"
@echo " HIT_RATE=$(HIT_RATE)% (simulation mode only)"
@echo ""
@echo "Wordlist generator parameters:"
@echo " WL_DOMAIN=$(WL_DOMAIN)"
@echo " WL_COMBINE=$(WL_COMBINE)"
@echo " WL_OUTPUT=$(WL_OUTPUT)"
@echo ""
@echo "Customize parameters on the command line or as environment variables, e.g.:"
@echo " make run DOMAIN=yourdomain.com WORDLIST=path/to/wordlist.txt"
@echo " DOMAIN=yourdomain.com WORDLIST=path/to/wordlist.txt make run"
@echo " WL_DOMAIN=yourdomain.com WL_COMBINE=dev,api,v1 make wordlist"
@echo " HIT_RATE=30 make simulate-verbose"