Documentation ¶
Index ¶
- Variables
- func TemplateContent(f Formatter, c *Config) (string, error)
- type CSVFormatter
- type CSVOutputOptions
- type Config
- type Debugging
- type Distance
- type ExtraPorts
- type Finished
- type Formatter
- type HTMLFormatter
- type HTMLOutputOptions
- type Hop
- type Host
- type HostAddress
- type HostName
- type HostNames
- type HostStatus
- type IPIDSequence
- type InputFile
- type InputFileConfig
- type JSONFormatter
- type JSONOutputOptions
- type MainWorkflow
- type MarkdownFormatter
- type MarkdownOutputOptions
- type NMAPRun
- type OS
- type OSClass
- type OSMatch
- type OSPortUsed
- type OutputFile
- type OutputFormat
- type OutputOptions
- type Port
- type PortService
- type PortState
- type RunStats
- type ScanInfo
- type Script
- type StatHosts
- type TCPSequence
- type TCPTSSequence
- type TemplateData
- type Trace
- type Uptime
- type Verbose
- type Workflow
Constants ¶
This section is empty.
Variables ¶
var HTMLSimpleTemplate string
HTMLSimpleTemplate variable is used to store embedded HTML template content
var MarkdownTemplate string
MarkdownTemplate variable is used to store markdown.tmpl embed file contents
Functions ¶
Types ¶
type CSVFormatter ¶
type CSVFormatter struct {
// contains filtered or unexported fields
}
CSVFormatter is struct defined for CSV Output use-case
func (*CSVFormatter) Format ¶
func (f *CSVFormatter) Format(td *TemplateData, templateContent string) (err error)
Format the data to CSV and output it to appropriate io.Writer
type CSVOutputOptions ¶ added in v1.0.0
type CSVOutputOptions struct { // The hosts that are down won't be displayed SkipDownHosts bool }
CSVOutputOptions store option related only to CSV conversion/formatting
type Config ¶
type Config struct { Writer io.WriteCloser OutputFormat OutputFormat InputFileConfig InputFileConfig OutputFile OutputFile OutputOptions OutputOptions ShowVersion bool TemplatePath string CustomOptions []string }
Config defines main application configs (requirements from user), like: where output will be delivered, desired output format, input file path, output file path and different output options
func (*Config) CustomOptionsMap ¶ added in v1.0.0
CustomOptionsMap returns custom options provided in the CLI
type Debugging ¶ added in v0.2.1
type Debugging struct {
Level int `xml:"level,attr"`
}
Debugging defines level of debug during NMAP execution
type Distance ¶ added in v0.2.1
type Distance struct {
Value int `xml:"value,attr"`
}
Distance describes amount of hops to the target
type ExtraPorts ¶ added in v0.2.1
ExtraPorts contains information about certain amount of ports that were (for example) filtered
type Finished ¶ added in v0.2.1
type Finished struct { Time int `xml:"time,attr"` TimeStr string `xml:"timestr,attr"` Elapsed float64 `xml:"elapsed,attr"` Summary string `xml:"summary,attr"` Exit string `xml:"exit,attr"` }
Finished is part of `RunStats` struct, it has all information related to the time (started, how much time it took) and summary incl. exit status code
type Formatter ¶
type Formatter interface { // Format the data and output it to appropriate io.Writer Format(td *TemplateData, templateContent string) error // contains filtered or unexported methods }
Formatter interface describes only one function `Format()` that is responsible for data "formatting"
type HTMLFormatter ¶
type HTMLFormatter struct {
// contains filtered or unexported fields
}
HTMLFormatter is struct defined for HTML Output use-case
func (*HTMLFormatter) Format ¶
func (f *HTMLFormatter) Format(td *TemplateData, templateContent string) error
Format the data and output it to appropriate io.Writer
type HTMLOutputOptions ¶ added in v1.0.0
type HTMLOutputOptions struct { // SkipDownHosts skips hosts that are down (including TOC) SkipDownHosts bool // SkipSummary skips general summary for HTML SkipSummary bool // SkipTraceroute skips traceroute information for HTML SkipTraceroute bool // SkipMetrics skips metrics related data for HTML SkipMetrics bool // SkipPortScripts skips port scripts information for HTML SkipPortScripts bool // DarkMode sets a style to be mostly in dark colours, if false, light colours would be used DarkMode bool // FloatingContentsTable is an option to make contents table float on the side of the page FloatingContentsTable bool }
HTMLOutputOptions stores options related only to HTML conversion/formatting
type Hop ¶ added in v0.2.1
type Hop struct { TTL int `xml:"ttl,attr"` IPAddr string `xml:"ipaddr,attr"` RTT float64 `xml:"rtt,attr"` Host string `xml:"host,attr"` }
Hop struct contains information about HOP record with time to live, host name, IP
type Host ¶ added in v0.2.1
type Host struct { StartTime int `xml:"starttime,attr"` EndTime int `xml:"endtime,attr"` Port []Port `xml:"ports>port"` HostAddress HostAddress `xml:"address"` HostNames HostNames `xml:"hostnames"` Status HostStatus `xml:"status"` OS OS `xml:"os"` Trace Trace `xml:"trace"` Uptime Uptime `xml:"uptime"` Distance Distance `xml:"distance"` TCPSequence TCPSequence `xml:"tcpsequence"` IPIDSequence IPIDSequence `xml:"ipidsequence"` TCPTSSequence TCPTSSequence `xml:"tcptssequence"` }
Host describes host related entry (`host` node)
type HostAddress ¶ added in v0.2.1
type HostAddress struct { Address string `xml:"addr,attr"` AddressType string `xml:"addrtype,attr"` }
HostAddress struct contains the host address (IP) and type of it.
type HostName ¶ added in v0.2.1
HostName defines the name of the host and type of DNS record (like PTR for example)
type HostNames ¶ added in v0.2.1
type HostNames struct {
HostName []HostName `xml:"hostname"`
}
HostNames struct contains list of hostnames (domains) that this host has
type HostStatus ¶ added in v0.2.1
HostStatus describes the state (up or down) of the host and the reason
type IPIDSequence ¶ added in v0.2.1
IPIDSequence describes all information related to `<ipidsequence>` node
type InputFile ¶ added in v0.2.1
type InputFile string
InputFile describes input file (nmap XML full path)
type InputFileConfig ¶ added in v1.0.0
type InputFileConfig struct { Path string IsStdin bool Source io.ReadCloser }
InputFileConfig stores all options related to nmap XML (path, is content is taken from stdin and io reader)
func (*InputFileConfig) ExistsOpen ¶ added in v1.0.0
func (i *InputFileConfig) ExistsOpen() error
ExistsOpen tries to open a file for reading, returning an error if it fails
func (*InputFileConfig) ReadContents ¶ added in v1.0.0
func (i *InputFileConfig) ReadContents() ([]byte, error)
ReadContents reads content from stdin or provided file-path
type JSONFormatter ¶
type JSONFormatter struct {
// contains filtered or unexported fields
}
JSONFormatter is struct defined for JSON Output use-case
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(td *TemplateData, templateContent string) (err error)
Format the data and output it to appropriate io.Writer
type JSONOutputOptions ¶ added in v1.0.0
type JSONOutputOptions struct { // PrettyPrint defines if JSON output would be pretty-printed (human-readable) or not (machine readable) PrettyPrint bool }
JSONOutputOptions store option related only to JSON conversion/formatting
type MainWorkflow ¶ added in v0.2.1
type MainWorkflow struct {
Config *Config
}
MainWorkflow is main workflow implementation struct
func (*MainWorkflow) Execute ¶ added in v0.2.1
func (w *MainWorkflow) Execute() (err error)
Execute is the core of the application which executes required steps one-by-one to achieve formatting from input -> output.
func (*MainWorkflow) SetConfig ¶ added in v0.2.1
func (w *MainWorkflow) SetConfig(c *Config)
SetConfig is a simple setter-function that sets the configuration
func (*MainWorkflow) SetInputFile ¶ added in v1.0.0
func (w *MainWorkflow) SetInputFile()
SetInputFile sets an input file (file descriptor) in the config
func (*MainWorkflow) SetOutputFile ¶ added in v1.0.0
func (w *MainWorkflow) SetOutputFile()
SetOutputFile sets output file (file descriptor) depending on config and returns error if there is output file reading issue
type MarkdownFormatter ¶
type MarkdownFormatter struct {
// contains filtered or unexported fields
}
MarkdownFormatter is a formatter struct used to deliver markdown file format
func (*MarkdownFormatter) Format ¶
func (f *MarkdownFormatter) Format(td *TemplateData, templateContent string) (err error)
Format the data and output it to appropriate io.Writer
type MarkdownOutputOptions ¶ added in v1.0.0
type MarkdownOutputOptions struct { // SkipDownHosts skips hosts that are down (including TOC) SkipDownHosts bool // SkipSummary skips general summary for Markdown SkipSummary bool // SkipPortScripts skips port scripts information for Markdown SkipPortScripts bool // SkipTraceroute skips traceroute information for Markdown SkipTraceroute bool // SkipMetrics skips metrics related data for Markdown SkipMetrics bool }
MarkdownOutputOptions stores options related only to Markdown conversion/formatting
type NMAPRun ¶ added in v0.2.1
type NMAPRun struct { Scanner string `xml:"scanner,attr"` Args string `xml:"args,attr"` Start int `xml:"start,attr"` StartStr string `xml:"startstr,attr"` Version string `xml:"version,attr"` ScanInfo ScanInfo `xml:"scaninfo"` Host []Host `xml:"host"` Verbose Verbose `xml:"verbose"` Debugging Debugging `xml:"debugging"` RunStats RunStats `xml:"runstats"` }
NMAPRun represents main `<nmaprun>“ node which contains meta-information about the scan For example: scanner, what arguments used during scan, nmap version, verbosity level, et cetera Main information about scanned hosts is in the `host` node
type OS ¶ added in v0.2.1
type OS struct { OSPortUsed []OSPortUsed `xml:"portused"` OSClass OSClass `xml:"osclass"` OSMatch []OSMatch `xml:"osmatch"` }
OS describes all information about underlying operating system that this host operates
type OSClass ¶ added in v0.2.1
type OSClass struct { Type string `xml:"type,attr"` Vendor string `xml:"vendor,attr"` OSFamily string `xml:"osfamily,attr"` OSGen string `xml:"osgen,attr"` Accuracy string `xml:"accuracy,attr"` CPE []string `xml:"cpe"` }
OSClass contains all information about operating system family
type OSMatch ¶ added in v0.2.1
type OSMatch struct { Name string `xml:"name,attr"` Accuracy string `xml:"accuracy,attr"` Line string `xml:"line,attr"` }
OSMatch is a record of OS that matched with certain accuracy
type OSPortUsed ¶ added in v0.2.1
type OSPortUsed struct { State string `xml:"state,attr"` Protocol string `xml:"proto,attr"` PortID int `xml:"portid,attr"` }
OSPortUsed defines which ports were used for OS detection
type OutputFile ¶ added in v0.2.1
type OutputFile string
OutputFile describes output file name (full path)
type OutputFormat ¶ added in v0.2.1
type OutputFormat string
OutputFormat is a resulting type of file that is converted/formatted from XML to HTML (for example)
const ( // HTMLOutput constant defines OutputFormat is HyperText Markup Language which can be viewed using browsers HTMLOutput OutputFormat = "html" // CSVOutput constant defines OutputFormat for Comma-Separated Values CSV file which is viewed most of the time in Excel CSVOutput OutputFormat = "csv" // MarkdownOutput constant defines OutputFormat for Markdown, which is handy and easy format to read-write MarkdownOutput OutputFormat = "md" // JSONOutput constant defines OutputFormat for JavaScript Object Notation, which is more useful for machine-related operations (parsing) JSONOutput OutputFormat = "json" )
func (OutputFormat) FileOutputFormat ¶ added in v0.2.1
func (of OutputFormat) FileOutputFormat() OutputFormat
FileOutputFormat returns appropriate file format, users can provide short
func (OutputFormat) IsValid ¶ added in v0.2.1
func (of OutputFormat) IsValid() bool
IsValid checks whether requested output format is valid
type OutputOptions ¶ added in v0.2.1
type OutputOptions struct { HTMLOptions HTMLOutputOptions MarkdownOptions MarkdownOutputOptions JSONOptions JSONOutputOptions CSVOptions CSVOutputOptions }
OutputOptions describes various output options for nmap formatter
type Port ¶ added in v0.2.1
type Port struct { Protocol string `xml:"protocol,attr"` PortID int `xml:"portid,attr"` State PortState `xml:"state"` Service PortService `xml:"service"` Script []Script `xml:"script"` }
Port record contains main information about port that was scanned
type PortService ¶ added in v0.2.1
type PortService struct { Name string `xml:"name,attr"` Product string `xml:"product,attr"` Version string `xml:"version,attr"` ExtraInfo string `xml:"extrainfo,attr"` Method string `xml:"method,attr"` Conf string `xml:"conf,attr"` CPE []string `xml:"cpe"` }
PortService struct contains information about the service that is located on certain port
type PortState ¶ added in v0.2.1
type PortState struct { State string `xml:"state,attr"` Reason string `xml:"reason,attr"` ReasonTTL string `xml:"reason_ttl,attr"` }
PortState describes information about the port state and why it's state was defined that way
type ScanInfo ¶ added in v0.2.1
type ScanInfo struct { Type string `xml:"type,attr"` Protocol string `xml:"protocol,attr"` NumServices int `xml:"numservices,attr"` Services string `xml:"services,attr"` }
ScanInfo shows what type of scan it was and number of services covered
type StatHosts ¶ added in v0.2.1
type StatHosts struct { Up int `xml:"up,attr"` Down int `xml:"down,attr"` Total int `xml:"total,attr"` }
StatHosts contains statistics about hosts that are up or down
type TCPSequence ¶ added in v0.2.1
type TCPSequence struct { Index string `xml:"index,attr"` Difficulty string `xml:"difficulty,attr"` Values string `xml:"values,attr"` }
TCPSequence describes all information related to `<tcpsequence>`
type TCPTSSequence ¶ added in v0.2.1
TCPTSSequence describes all information related to `<tcptssequence>` node
type TemplateData ¶ added in v0.2.1
type TemplateData struct { NMAPRun NMAPRun OutputOptions OutputOptions CustomOptions map[string]string }
TemplateData is a struct that is used in the template, where NMAPRun is containing all parsed data from XML & OutputOptions contain all the information about certain output preferences.
type Trace ¶ added in v0.2.1
type Trace struct { Port int `xml:"port,attr"` Protocol string `xml:"proto,attr"` Hops []Hop `xml:"hop"` }
Trace struct contains trace information with hops