-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
enum.go
658 lines (616 loc) · 20.9 KB
/
enum.go
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
// Copyright © by Jeff Foley 2017-2023. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// SPDX-License-Identifier: Apache-2.0
package main
import (
"bufio"
"bytes"
"context"
"flag"
"fmt"
"io"
"log"
"net"
"os"
"os/signal"
"path/filepath"
"regexp"
"strings"
"sync"
"syscall"
"time"
"github.com/caffix/netmap"
"github.com/caffix/stringset"
"github.com/fatih/color"
"github.com/owasp-amass/amass/v4/datasrcs"
"github.com/owasp-amass/amass/v4/enum"
"github.com/owasp-amass/amass/v4/format"
"github.com/owasp-amass/amass/v4/resources"
"github.com/owasp-amass/amass/v4/systems"
"github.com/owasp-amass/config/config"
)
const enumUsageMsg = "enum [options] -d DOMAIN"
type enumArgs struct {
Addresses format.ParseIPs
ASNs format.ParseInts
CIDRs format.ParseCIDRs
AltWordList *stringset.Set
AltWordListMask *stringset.Set
BruteWordList *stringset.Set
BruteWordListMask *stringset.Set
Blacklist *stringset.Set
Domains *stringset.Set
Excluded *stringset.Set
Included *stringset.Set
Interface string
MaxDNSQueries int
ResolverQPS int
TrustedQPS int
MaxDepth int
MinForRecursive int
Names *stringset.Set
Ports format.ParseInts
Resolvers *stringset.Set
Trusted *stringset.Set
Timeout int
Options struct {
Active bool
Alterations bool
BruteForcing bool
DemoMode bool
ListSources bool
NoAlts bool
NoColor bool
NoRecursive bool
Passive bool
Silent bool
Verbose bool
}
Filepaths struct {
AllFilePrefix string
AltWordlist format.ParseStrings
Blacklist string
BruteWordlist format.ParseStrings
ConfigFile string
Directory string
Domains format.ParseStrings
ExcludedSrcs string
IncludedSrcs string
JSONOutput string
LogFile string
Names format.ParseStrings
Resolvers format.ParseStrings
Trusted format.ParseStrings
ScriptsDirectory string
TermOut string
}
}
func defineEnumArgumentFlags(enumFlags *flag.FlagSet, args *enumArgs) {
enumFlags.Var(&args.Addresses, "addr", "IPs and ranges (192.168.1.1-254) separated by commas")
enumFlags.Var(args.AltWordListMask, "awm", "\"hashcat-style\" wordlist masks for name alterations")
enumFlags.Var(&args.ASNs, "asn", "ASNs separated by commas (can be used multiple times)")
enumFlags.Var(&args.CIDRs, "cidr", "CIDRs separated by commas (can be used multiple times)")
enumFlags.Var(args.Blacklist, "bl", "Blacklist of subdomain names that will not be investigated")
enumFlags.Var(args.BruteWordListMask, "wm", "\"hashcat-style\" wordlist masks for DNS brute forcing")
enumFlags.Var(args.Domains, "d", "Domain names separated by commas (can be used multiple times)")
enumFlags.Var(args.Excluded, "exclude", "Data source names separated by commas to be excluded")
enumFlags.Var(args.Included, "include", "Data source names separated by commas to be included")
enumFlags.StringVar(&args.Interface, "iface", "", "Provide the network interface to send traffic through")
enumFlags.IntVar(&args.MaxDNSQueries, "max-dns-queries", 0, "Deprecated flag to be replaced by dns-qps in version 4.0")
enumFlags.IntVar(&args.MaxDNSQueries, "dns-qps", 0, "Maximum number of DNS queries per second across all resolvers")
enumFlags.IntVar(&args.ResolverQPS, "rqps", 0, "Maximum number of DNS queries per second for each untrusted resolver")
enumFlags.IntVar(&args.TrustedQPS, "trqps", 0, "Maximum number of DNS queries per second for each trusted resolver")
enumFlags.IntVar(&args.MaxDepth, "max-depth", 0, "Maximum number of subdomain labels for brute forcing")
enumFlags.IntVar(&args.MinForRecursive, "min-for-recursive", 1, "Subdomain labels seen before recursive brute forcing (Default: 1)")
enumFlags.Var(&args.Ports, "p", "Ports separated by commas (default: 80, 443)")
enumFlags.Var(args.Resolvers, "r", "IP addresses of untrusted DNS resolvers (can be used multiple times)")
enumFlags.Var(args.Resolvers, "tr", "IP addresses of trusted DNS resolvers (can be used multiple times)")
enumFlags.IntVar(&args.Timeout, "timeout", 0, "Number of minutes to let enumeration run before quitting")
}
func defineEnumOptionFlags(enumFlags *flag.FlagSet, args *enumArgs) {
enumFlags.BoolVar(&args.Options.Active, "active", false, "Attempt zone transfers and certificate name grabs")
enumFlags.BoolVar(&args.Options.BruteForcing, "brute", false, "Execute brute forcing after searches")
enumFlags.BoolVar(&args.Options.DemoMode, "demo", false, "Censor output to make it suitable for demonstrations")
enumFlags.BoolVar(&args.Options.ListSources, "list", false, "Print the names of all available data sources")
enumFlags.BoolVar(&args.Options.Alterations, "alts", false, "Enable generation of altered names")
enumFlags.BoolVar(&args.Options.NoColor, "nocolor", false, "Disable colorized output")
enumFlags.BoolVar(&args.Options.NoRecursive, "norecursive", false, "Turn off recursive brute forcing")
enumFlags.BoolVar(&args.Options.Passive, "passive", false, "Deprecated since passive is the default setting")
enumFlags.BoolVar(&args.Options.Silent, "silent", false, "Disable all output during execution")
enumFlags.BoolVar(&args.Options.Verbose, "v", false, "Output status / debug / troubleshooting info")
}
func defineEnumFilepathFlags(enumFlags *flag.FlagSet, args *enumArgs) {
enumFlags.StringVar(&args.Filepaths.AllFilePrefix, "oA", "", "Path prefix used for naming all output files")
enumFlags.Var(&args.Filepaths.AltWordlist, "aw", "Path to a different wordlist file for alterations")
enumFlags.StringVar(&args.Filepaths.Blacklist, "blf", "", "Path to a file providing blacklisted subdomains")
enumFlags.Var(&args.Filepaths.BruteWordlist, "w", "Path to a different wordlist file for brute forcing")
enumFlags.StringVar(&args.Filepaths.ConfigFile, "config", "", "Path to the YAML configuration file. Additional details below")
enumFlags.StringVar(&args.Filepaths.Directory, "dir", "", "Path to the directory containing the output files")
enumFlags.Var(&args.Filepaths.Domains, "df", "Path to a file providing root domain names")
enumFlags.StringVar(&args.Filepaths.ExcludedSrcs, "ef", "", "Path to a file providing data sources to exclude")
enumFlags.StringVar(&args.Filepaths.IncludedSrcs, "if", "", "Path to a file providing data sources to include")
enumFlags.StringVar(&args.Filepaths.LogFile, "log", "", "Path to the log file where errors will be written")
enumFlags.Var(&args.Filepaths.Names, "nf", "Path to a file providing already known subdomain names (from other tools/sources)")
enumFlags.Var(&args.Filepaths.Resolvers, "rf", "Path to a file providing untrusted DNS resolvers")
enumFlags.Var(&args.Filepaths.Trusted, "trf", "Path to a file providing trusted DNS resolvers")
enumFlags.StringVar(&args.Filepaths.ScriptsDirectory, "scripts", "", "Path to a directory containing ADS scripts")
enumFlags.StringVar(&args.Filepaths.TermOut, "o", "", "Path to the text file containing terminal stdout/stderr")
}
func runEnumCommand(clArgs []string) {
// Extract the correct config from the user provided arguments and/or configuration file
cfg, args := argsAndConfig(clArgs)
if cfg == nil {
return
}
createOutputDirectory(cfg)
rLog, wLog := io.Pipe()
dir := config.OutputDirectory(cfg.Dir)
// Setup logging so that messages can be written to the file and used by the program
cfg.Log = log.New(wLog, "", log.Lmicroseconds)
logfile := filepath.Join(dir, "amass.log")
if args.Filepaths.LogFile != "" {
logfile = args.Filepaths.LogFile
}
// Start handling the log messages
go writeLogsAndMessages(rLog, logfile, args.Options.Verbose)
// Create the System that will provide architecture to this enumeration
sys, err := systems.NewLocalSystem(cfg)
if err != nil {
r.Fprintf(color.Error, "%v\n", err)
os.Exit(1)
}
defer func() { _ = sys.Shutdown() }()
if err := sys.SetDataSources(datasrcs.GetAllSources(sys)); err != nil {
r.Fprintf(color.Error, "%v\n", err)
os.Exit(1)
}
// Setup the new enumeration
e := enum.NewEnumeration(cfg, sys, sys.GraphDatabases()[0])
if e == nil {
r.Fprintf(color.Error, "%s\n", "Failed to setup the enumeration")
os.Exit(1)
}
var wg sync.WaitGroup
var outChans []chan string
// This channel sends the signal for goroutines to terminate
done := make(chan struct{})
// Print output only if JSONOutput is not meant for STDOUT
if args.Filepaths.JSONOutput != "-" {
wg.Add(1)
// This goroutine will handle printing the output
printOutChan := make(chan string, 10)
go printOutput(e, args, printOutChan, &wg)
outChans = append(outChans, printOutChan)
}
wg.Add(1)
// This goroutine will handle saving the output to the text file
txtOutChan := make(chan string, 10)
go saveTextOutput(e, args, txtOutChan, &wg)
outChans = append(outChans, txtOutChan)
var ctx context.Context
var cancel context.CancelFunc
if args.Timeout == 0 {
ctx, cancel = context.WithCancel(context.Background())
} else {
ctx, cancel = context.WithTimeout(context.Background(), time.Duration(args.Timeout)*time.Minute)
}
defer cancel()
wg.Add(1)
go processOutput(ctx, sys.GraphDatabases()[0], e, outChans, done, &wg)
// Monitor for cancellation by the user
go func(d chan struct{}, c context.Context, f context.CancelFunc) {
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt, syscall.SIGTERM)
defer signal.Stop(quit)
select {
case <-quit:
f()
case <-d:
case <-c.Done():
}
}(done, ctx, cancel)
// Start the enumeration process
if err := e.Start(ctx); err != nil {
r.Println(err)
os.Exit(1)
}
// Let all the output goroutines know that the enumeration has finished
close(done)
wg.Wait()
fmt.Fprintf(color.Error, "\n%s\n", green("The enumeration has finished"))
}
func argsAndConfig(clArgs []string) (*config.Config, *enumArgs) {
args := enumArgs{
AltWordList: stringset.New(),
AltWordListMask: stringset.New(),
BruteWordList: stringset.New(),
BruteWordListMask: stringset.New(),
Blacklist: stringset.New(),
Domains: stringset.New(),
Excluded: stringset.New(),
Included: stringset.New(),
Names: stringset.New(),
Resolvers: stringset.New(),
Trusted: stringset.New(),
}
var help1, help2 bool
enumCommand := flag.NewFlagSet("enum", flag.ContinueOnError)
enumBuf := new(bytes.Buffer)
enumCommand.SetOutput(enumBuf)
enumCommand.BoolVar(&help1, "h", false, "Show the program usage message")
enumCommand.BoolVar(&help2, "help", false, "Show the program usage message")
defineEnumArgumentFlags(enumCommand, &args)
defineEnumOptionFlags(enumCommand, &args)
defineEnumFilepathFlags(enumCommand, &args)
if len(clArgs) < 1 {
commandUsage(enumUsageMsg, enumCommand, enumBuf)
return nil, &args
}
if err := enumCommand.Parse(clArgs); err != nil {
r.Fprintf(color.Error, "%v\n", err)
os.Exit(1)
}
if help1 || help2 {
commandUsage(enumUsageMsg, enumCommand, enumBuf)
return nil, &args
}
if args.Interface != "" {
iface, err := net.InterfaceByName(args.Interface)
if err != nil || iface == nil {
fmt.Fprint(color.Output, format.InterfaceInfo())
os.Exit(1)
}
if err := assignNetInterface(iface); err != nil {
r.Fprintf(color.Error, "%v\n", err)
os.Exit(1)
}
}
if args.Options.NoColor {
color.NoColor = true
}
if args.Options.Silent {
color.Output = io.Discard
color.Error = io.Discard
}
if args.AltWordListMask.Len() > 0 {
args.AltWordList.Union(args.AltWordListMask)
}
if args.BruteWordListMask.Len() > 0 {
args.BruteWordList.Union(args.BruteWordListMask)
}
if (args.Excluded.Len() > 0 || args.Filepaths.ExcludedSrcs != "") &&
(args.Included.Len() > 0 || args.Filepaths.IncludedSrcs != "") {
r.Fprintln(color.Error, "Cannot provide both include and exclude arguments")
commandUsage(enumUsageMsg, enumCommand, enumBuf)
os.Exit(1)
}
if err := processEnumInputFiles(&args); err != nil {
fmt.Fprintf(color.Error, "%v\n", err)
os.Exit(1)
}
cfg := config.NewConfig()
// Check if a configuration file was provided, and if so, load the settings
if err := config.AcquireConfig(args.Filepaths.Directory, args.Filepaths.ConfigFile, cfg); err == nil {
// Check if a config file was provided that has DNS resolvers specified
if len(cfg.Resolvers) > 0 && args.Resolvers.Len() == 0 {
args.Resolvers = stringset.New(cfg.Resolvers...)
}
} else if args.Filepaths.ConfigFile != "" {
r.Fprintf(color.Error, "Failed to load the configuration file: %v\n", err)
os.Exit(1)
}
// Override configuration file settings with command-line arguments
if err := cfg.UpdateConfig(args); err != nil {
r.Fprintf(color.Error, "Configuration error: %v\n", err)
os.Exit(1)
}
// Check if the user has requested the data source names
if args.Options.ListSources {
for _, line := range GetAllSourceInfo(cfg) {
fmt.Fprintln(color.Output, line)
}
return nil, &args
}
// Some input validation
if !cfg.Active && len(args.Ports) > 0 {
r.Fprintln(color.Error, "Ports can only be scanned in the active mode")
os.Exit(1)
}
if len(cfg.Domains()) == 0 {
r.Fprintln(color.Error, "Configuration error: No root domain names were provided")
os.Exit(1)
}
return cfg, &args
}
func printOutput(e *enum.Enumeration, args *enumArgs, output chan string, wg *sync.WaitGroup) {
defer wg.Done()
var total int
// Print all the output returned by the enumeration
for out := range output {
fmt.Fprintf(color.Output, "%s\n", out)
total++
}
if total == 0 {
r.Println("No assets were discovered")
}
}
func saveTextOutput(e *enum.Enumeration, args *enumArgs, output chan string, wg *sync.WaitGroup) {
defer wg.Done()
dir := config.OutputDirectory(e.Config.Dir)
txtfile := filepath.Join(dir, "amass.txt")
if args.Filepaths.TermOut != "" {
txtfile = args.Filepaths.TermOut
}
if args.Filepaths.AllFilePrefix != "" {
txtfile = args.Filepaths.AllFilePrefix + ".txt"
}
if txtfile == "" {
return
}
outptr, err := os.OpenFile(txtfile, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
r.Fprintf(color.Error, "Failed to open the text output file: %v\n", err)
os.Exit(1)
}
defer func() {
_ = outptr.Sync()
_ = outptr.Close()
}()
_ = outptr.Truncate(0)
_, _ = outptr.Seek(0, 0)
// Save all the output returned by the enumeration
for out := range output {
// Write the line to the output file
fmt.Fprintf(outptr, "%s\n", out)
}
}
func processOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, outputs []chan string, done chan struct{}, wg *sync.WaitGroup) {
defer wg.Done()
defer func() {
// Signal all the other output goroutines to terminate
for _, ch := range outputs {
close(ch)
}
}()
// This filter ensures that we only get new names
known := stringset.New()
defer known.Close()
// The function that obtains output from the enum and puts it on the channel
extract := func(since time.Time) {
for _, o := range NewOutput(ctx, g, e, known, since) {
for _, ch := range outputs {
ch <- o
}
}
}
t := time.NewTimer(10 * time.Second)
defer t.Stop()
last := e.Config.CollectionStartTime
for {
select {
case <-ctx.Done():
extract(last)
return
case <-done:
extract(last)
return
case <-t.C:
next := time.Now()
extract(last)
t.Reset(10 * time.Second)
last = next
}
}
}
func writeLogsAndMessages(logs *io.PipeReader, logfile string, verbose bool) {
wildcard := regexp.MustCompile("DNS wildcard")
queries := regexp.MustCompile("Querying")
var filePtr *os.File
if logfile != "" {
var err error
filePtr, err = os.OpenFile(logfile, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
r.Fprintf(color.Error, "Failed to open the log file: %v\n", err)
} else {
defer func() {
_ = filePtr.Sync()
_ = filePtr.Close()
}()
_ = filePtr.Truncate(0)
_, _ = filePtr.Seek(0, 0)
}
}
scanner := bufio.NewScanner(logs)
for scanner.Scan() {
line := scanner.Text()
if err := scanner.Err(); err != nil {
fmt.Fprintf(color.Error, "Error reading the Amass logs: %v\n", err)
break
}
if filePtr != nil {
fmt.Fprintln(filePtr, line)
}
// Remove the timestamp
parts := strings.Split(line, " ")
line = strings.Join(parts[1:], " ")
// Check for Amass DNS wildcard messages
if verbose && wildcard.FindString(line) != "" {
fgR.Fprintln(color.Error, line)
}
// Let the user know when data sources are being queried
if verbose && queries.FindString(line) != "" {
fgY.Fprintln(color.Error, line)
}
}
}
// Obtain parameters from provided input files
func processEnumInputFiles(args *enumArgs) error {
if args.Options.BruteForcing {
if len(args.Filepaths.BruteWordlist) > 0 {
for _, f := range args.Filepaths.BruteWordlist {
list, err := config.GetListFromFile(f)
if err != nil {
return fmt.Errorf("failed to parse the brute force wordlist file: %v", err)
}
args.BruteWordList.InsertMany(list...)
}
} else {
if f, err := resources.GetResourceFile("namelist.txt"); err == nil {
if list, err := getWordList(f); err == nil {
args.BruteWordList.InsertMany(list...)
}
}
}
}
if !args.Options.NoAlts {
if len(args.Filepaths.AltWordlist) > 0 {
for _, f := range args.Filepaths.AltWordlist {
list, err := config.GetListFromFile(f)
if err != nil {
return fmt.Errorf("failed to parse the alterations wordlist file: %v", err)
}
args.AltWordList.InsertMany(list...)
}
} else {
if f, err := resources.GetResourceFile("alterations.txt"); err == nil {
if list, err := getWordList(f); err == nil {
args.AltWordList.InsertMany(list...)
}
}
}
}
if args.Filepaths.Blacklist != "" {
list, err := config.GetListFromFile(args.Filepaths.Blacklist)
if err != nil {
return fmt.Errorf("failed to parse the blacklist file: %v", err)
}
args.Blacklist.InsertMany(list...)
}
if args.Filepaths.ExcludedSrcs != "" {
list, err := config.GetListFromFile(args.Filepaths.ExcludedSrcs)
if err != nil {
return fmt.Errorf("failed to parse the exclude file: %v", err)
}
args.Excluded.InsertMany(list...)
}
if args.Filepaths.IncludedSrcs != "" {
list, err := config.GetListFromFile(args.Filepaths.IncludedSrcs)
if err != nil {
return fmt.Errorf("failed to parse the include file: %v", err)
}
args.Included.InsertMany(list...)
}
if len(args.Filepaths.Names) > 0 {
for _, f := range args.Filepaths.Names {
list, err := config.GetListFromFile(f)
if err != nil {
return fmt.Errorf("failed to parse the subdomain names file: %v", err)
}
args.Names.InsertMany(list...)
}
}
if len(args.Filepaths.Domains) > 0 {
for _, f := range args.Filepaths.Domains {
list, err := config.GetListFromFile(f)
if err != nil {
return fmt.Errorf("failed to parse the domain names file: %v", err)
}
args.Domains.InsertMany(list...)
}
}
if len(args.Filepaths.Resolvers) > 0 {
for _, f := range args.Filepaths.Resolvers {
list, err := config.GetListFromFile(f)
if err != nil {
return fmt.Errorf("failed to parse the esolver file: %v", err)
}
args.Resolvers.InsertMany(list...)
}
}
return nil
}
// Setup the amass enumeration settings
func (e enumArgs) OverrideConfig(conf *config.Config) error {
if len(e.Addresses) > 0 {
conf.Scope.Addresses = e.Addresses
}
if len(e.ASNs) > 0 {
conf.Scope.ASNs = e.ASNs
}
if len(e.CIDRs) > 0 {
conf.Scope.CIDRs = e.CIDRs
}
if len(e.Ports) > 0 {
conf.Scope.Ports = e.Ports
}
if e.Filepaths.Directory != "" {
conf.Dir = e.Filepaths.Directory
}
if e.Filepaths.ScriptsDirectory != "" {
conf.ScriptsDirectory = e.Filepaths.ScriptsDirectory
}
if e.Names.Len() > 0 {
conf.ProvidedNames = e.Names.Slice()
}
if e.BruteWordList.Len() > 0 {
conf.Wordlist = e.BruteWordList.Slice()
}
if e.AltWordList.Len() > 0 {
conf.AltWordlist = e.AltWordList.Slice()
}
if e.Options.BruteForcing {
conf.BruteForcing = true
}
if e.Options.Alterations {
conf.Alterations = true
}
if e.Options.NoRecursive {
conf.Recursive = false
}
if e.MinForRecursive != 1 {
conf.MinForRecursive = e.MinForRecursive
}
if e.MaxDepth != 0 {
conf.MaxDepth = e.MaxDepth
}
if e.Options.Active {
conf.Active = true
conf.Passive = false
}
if e.Blacklist.Len() > 0 {
conf.Scope.Blacklist = e.Blacklist.Slice()
}
if e.Options.Verbose {
conf.Verbose = true
}
if e.ResolverQPS > 0 {
conf.ResolversQPS = e.ResolverQPS
}
if e.TrustedQPS > 0 {
conf.TrustedQPS = e.TrustedQPS
}
if e.Resolvers.Len() > 0 {
conf.SetResolvers(e.Resolvers.Slice()...)
}
if e.Trusted.Len() > 0 {
conf.SetTrustedResolvers(e.Trusted.Slice()...)
}
if e.MaxDNSQueries > 0 {
conf.MaxDNSQueries = e.MaxDNSQueries
}
// Attempt to add the provided domains to the configuration
conf.AddDomains(e.Domains.Slice()...)
return nil
}
func getWordList(reader io.Reader) ([]string, error) {
var words []string
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
// Get the next word in the list
w := strings.TrimSpace(scanner.Text())
if err := scanner.Err(); err == nil && w != "" {
words = append(words, w)
}
}
return stringset.Deduplicate(words), nil
}