-
Notifications
You must be signed in to change notification settings - Fork 105
/
optionsOutput.go
94 lines (81 loc) · 2.47 KB
/
optionsOutput.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
package nmap
import "fmt"
// WithVerbosity sets and increases the verbosity level of nmap.
func WithVerbosity(level int) Option {
return func(s *Scanner) {
if level < 0 || level > 10 {
panic("value given to nmap.WithVerbosity() should be between 0 and 10")
}
s.args = append(s.args, fmt.Sprintf("-v%d", level))
}
}
// WithDebugging sets and increases the debugging level of nmap.
func WithDebugging(level int) Option {
return func(s *Scanner) {
if level < 0 || level > 10 {
panic("value given to nmap.WithDebugging() should be between 0 and 10")
}
s.args = append(s.args, fmt.Sprintf("-d%d", level))
}
}
// WithReason makes nmap specify why a port is in a particular state.
func WithReason() Option {
return func(s *Scanner) {
s.args = append(s.args, "--reason")
}
}
// WithOpenOnly makes nmap only show open ports.
func WithOpenOnly() Option {
return func(s *Scanner) {
s.args = append(s.args, "--open")
}
}
// WithPacketTrace makes nmap show all packets sent and received.
func WithPacketTrace() Option {
return func(s *Scanner) {
s.args = append(s.args, "--packet-trace")
}
}
// WithAppendOutput makes nmap append to files instead of overwriting them.
// Currently does nothing, since this library doesn't write in files.
func WithAppendOutput() Option {
return func(s *Scanner) {
s.args = append(s.args, "--append-output")
}
}
// WithResumePreviousScan makes nmap continue a scan that was aborted,
// from an output file.
func WithResumePreviousScan(filePath string) Option {
return func(s *Scanner) {
s.args = append(s.args, "--resume")
s.args = append(s.args, filePath)
}
}
// WithStylesheet makes nmap apply an XSL stylesheet to transform its
// XML output to HTML.
func WithStylesheet(stylesheetPath string) Option {
return func(s *Scanner) {
s.args = append(s.args, "--stylesheet")
s.args = append(s.args, stylesheetPath)
}
}
// WithWebXML makes nmap apply the default nmap.org stylesheet to transform
// XML output to HTML. The stylesheet can be found at
// https://nmap.org/svn/docs/nmap.xsl
func WithWebXML() Option {
return func(s *Scanner) {
s.args = append(s.args, "--webxml")
}
}
// WithNoStylesheet prevents the use of XSL stylesheets with the XML output.
func WithNoStylesheet() Option {
return func(s *Scanner) {
s.args = append(s.args, "--no-stylesheet")
}
}
// WithNonInteractive disable runtime interactions via keyboard
func WithNonInteractive() Option {
return func(s *Scanner) {
s.args = append(s.Args(), "--noninteractive")
}
}