-
Notifications
You must be signed in to change notification settings - Fork 104
/
optionsTargetSpecification.go
58 lines (50 loc) · 1.53 KB
/
optionsTargetSpecification.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
package nmap
import (
"fmt"
"strings"
)
// WithTargets sets the target of a scanner.
func WithTargets(targets ...string) Option {
return func(s *Scanner) {
s.args = append(s.args, targets...)
}
}
// WithTargetExclusions sets the excluded targets of a scanner.
func WithTargetExclusions(targets ...string) Option {
targetList := strings.Join(targets, ",")
return func(s *Scanner) {
s.args = append(s.args, "--exclude")
s.args = append(s.args, targetList)
}
}
// WithTargetInput sets the input file name to set the targets.
func WithTargetInput(inputFileName string) Option {
return func(s *Scanner) {
s.args = append(s.args, "-iL")
s.args = append(s.args, inputFileName)
}
}
// WithTargetExclusionInput sets the input file name to set the target exclusions.
func WithTargetExclusionInput(inputFileName string) Option {
return func(s *Scanner) {
s.args = append(s.args, "--excludefile")
s.args = append(s.args, inputFileName)
}
}
// WithRandomTargets sets the amount of targets to randomly choose from the targets.
func WithRandomTargets(randomTargets int) Option {
return func(s *Scanner) {
s.args = append(s.args, "-iR")
s.args = append(s.args, fmt.Sprint(randomTargets))
}
}
// WithUnique makes each address be scanned only once.
// The default behavior is to scan each address as many times
// as it is specified in the target list, such as when network
// ranges overlap or different hostnames resolve to the same
// address.
func WithUnique() Option {
return func(s *Scanner) {
s.args = append(s.args, "--unique")
}
}