Documentation ¶
Index ¶
- Constants
- Variables
- func TemplateContent(f Formatter, c *Config) (string, error)
- type CSVFormatter
- type CSVOutputOptions
- type CellData
- type Config
- type D2LangFormatter
- type D2LangOutputOptions
- type Debugging
- type Distance
- type DotFormatter
- type DotTemplateData
- type ExcelFormatter
- type ExcelOutputOptions
- type ExtraPorts
- type Finished
- type Formatter
- type HTMLFormatter
- type HTMLOutputOptions
- type Hop
- type Host
- type HostAddress
- type HostName
- type HostNames
- type HostRepository
- 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 OSRepository
- type OutputFile
- type OutputFormat
- type OutputOptions
- type Port
- type PortRepository
- type PortService
- type PortState
- type RTT
- type RunStats
- type ScanInfo
- type ScanRepository
- type Script
- type SqliteDB
- type SqliteFormatter
- type SqliteOutputOptions
- type StatHosts
- type TCPSequence
- type TCPTSSequence
- type TemplateData
- type Trace
- type Uptime
- type Verbose
- type Workflow
Constants ¶
const ( // DotOpenPortColor defines default color of the opened port DotOpenPortColor = "#228B22" // DotFilteredPortColor defines default color of the filtered port DotFilteredPortColor = "#FFAE00" // DotClosedPortColor defies default color of the closed port DotClosedPortColor = "#DC143C" // DotDefaultColor defines default color of various elements (lines, boxes) DotDefaultColor = "gray" // DotFontStyle default font style DotFontStyle = "monospace" // DotLayout is a type of layout used in Graphviz (dot by default is the most fitting) DotLayout = "dot" )
Variables ¶
var DotDefaultOptions = map[string]string{ "default_font": DotFontStyle, "layout": DotLayout, "color_default": DotDefaultColor, }
DotDefaultOptions is a config map that is used in Graphviz template
var DotTemplate string
DotTemplate variable is used to store contents of graphviz template
var ExcelColWidth float64 = 50
ExcelColWidth is the default width of the columns in the Excel file
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
var SqliteDDL string
SqliteDDL contains database schema definition
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 ¶
type CSVOutputOptions struct { }
CSVOutputOptions store option related only to CSV conversion/formatting
type CellData ¶
type CellData struct {
// contains filtered or unexported fields
}
CellData is a struct to hold the data for a cell to avoid code duplication
type Config ¶
type Config struct { Writer io.WriteCloser OutputFormat OutputFormat InputFileConfig InputFileConfig OutputFile OutputFile OutputOptions OutputOptions ShowVersion bool TemplatePath string CustomOptions []string CurrentVersion string SkipDownHosts bool FilterExpressions []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 ¶
CustomOptionsMap returns custom options provided in the CLI
type D2LangFormatter ¶
type D2LangFormatter struct {
// contains filtered or unexported fields
}
D2LangFormatter is struct defined for D2 Language Output use-case
func (*D2LangFormatter) Format ¶
func (f *D2LangFormatter) Format(td *TemplateData, templateContent string) (err error)
Format the data to D2 Language and output it to a D2 Language file
type D2LangOutputOptions ¶
type D2LangOutputOptions struct { }
D2LangOutputOptions store options related to D2 language file formatting
type Debugging ¶
type Debugging struct {
Level int `xml:"level,attr"`
}
Debugging defines level of debug during NMAP execution
type Distance ¶
type Distance struct {
Value int `xml:"value,attr"`
}
Distance describes amount of hops to the target
type DotFormatter ¶
type DotFormatter struct {
// contains filtered or unexported fields
}
DotFormatter is used to create Graphviz (dot) format
func (*DotFormatter) Format ¶
func (f *DotFormatter) Format(td *TemplateData, templateContent string) (err error)
Format the data and output it to appropriate io.Writer
type DotTemplateData ¶
DotTemplateData is a custom TemplateData struct that is used by DotFormatter
type ExcelFormatter ¶
type ExcelFormatter struct {
// contains filtered or unexported fields
}
ExcelFormatter is struct defined for Excel Output use-case
func (*ExcelFormatter) Format ¶
func (f *ExcelFormatter) Format(td *TemplateData, templateContent string) (err error)
Format the data to Excel and output it to an Excel file
type ExcelOutputOptions ¶
type ExcelOutputOptions struct { }
ExcelOutputOptions store options related to Excel file formatting
type ExtraPorts ¶
ExtraPorts contains information about certain amount of ports that were (for example) filtered
type Finished ¶
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 ¶
type HTMLOutputOptions struct { // SkipHeader skips the header of the HTML output SkipHeader bool // SkipTOC skips the table of contents in the HTML output SkipTOC 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 ¶
type Hop struct { TTL int `xml:"ttl,attr"` IPAddr string `xml:"ipaddr,attr"` RTT RTT `xml:"rtt,attr"` Host string `xml:"host,attr"` }
Hop struct contains information about HOP record with time to live, host name, IP
type Host ¶
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)
func (*Host) JoinedAddresses ¶
JoinedAddresses joins all possible host addresses with a delimiter string
func (*Host) JoinedHostNames ¶
JoinedHostNames returns a joined string of host names with a provided delimiter
type HostAddress ¶
type HostAddress struct { Address string `xml:"addr,attr"` AddressType string `xml:"addrtype,attr"` Vendor string `xml:"vendor,attr"` }
HostAddress struct contains the host address (IP) and type of it.
type HostNames ¶
type HostNames struct {
HostName []HostName `xml:"hostname"`
}
HostNames struct contains list of hostnames (domains) that this host has
type HostRepository ¶
type HostRepository struct {
// contains filtered or unexported fields
}
HostRepository main responsibility is to populated database with host related data
type HostStatus ¶
HostStatus describes the state (up or down) of the host and the reason
func (*HostStatus) IsUp ¶
func (hs *HostStatus) IsUp() bool
IsUp returns true if the host is up and accessible
type IPIDSequence ¶
IPIDSequence describes all information related to `<ipidsequence>` node
type InputFileConfig ¶
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 ¶
func (i *InputFileConfig) ExistsOpen() error
ExistsOpen tries to open a file for reading, returning an error if it fails
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 ¶
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 ¶
type MainWorkflow struct {
Config *Config
}
MainWorkflow is main workflow implementation struct
func (*MainWorkflow) Execute ¶
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 ¶
func (w *MainWorkflow) SetConfig(c *Config)
SetConfig is a simple setter-function that sets the configuration
func (*MainWorkflow) SetInputFile ¶
func (w *MainWorkflow) SetInputFile()
SetInputFile sets an input file (file descriptor) in the config
func (*MainWorkflow) SetOutputFile ¶
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 ¶
type MarkdownOutputOptions struct { // SkipHeader skips the header SkipHeader bool // SkipTOC skips the table of contents SkipTOC 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 OSRepository ¶
type OSRepository struct {
// contains filtered or unexported fields
}
OSRepository is responsible for populating database with OS related data on the scanned host
type OutputFormat ¶
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" // DotOutput constant defined OutputFormat for Dot (Graphviz), which can be used to generate various graphs DotOutput OutputFormat = "dot" // SqliteOutput constant defines OutputFormat for sqlite file, which can be used to generate sqlite embedded databases SqliteOutput OutputFormat = "sqlite" // ExcelOutput constant defines OutputFormat for Excel file, which can be used to generate Excel files ExcelOutput OutputFormat = "excel" // D2LangOutput constant defines OutputFormat for D2 language, which can be used to generate D2 language files D2LangOutput OutputFormat = "d2" )
func (OutputFormat) IsValid ¶
func (of OutputFormat) IsValid() bool
IsValid checks whether requested output format is valid
type OutputOptions ¶
type OutputOptions struct { HTMLOptions HTMLOutputOptions MarkdownOptions MarkdownOutputOptions JSONOptions JSONOutputOptions CSVOptions CSVOutputOptions SqliteOutputOptions SqliteOutputOptions ExcelOptions ExcelOutputOptions D2LangOptions D2LangOutputOptions }
OutputOptions describes various output options for nmap formatter
type Port ¶
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 PortRepository ¶
type PortRepository struct {
// contains filtered or unexported fields
}
PortRepository is responsible for populating database with a data related to ports
type PortService ¶
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 ¶
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 ¶
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 ScanRepository ¶
type ScanRepository struct {
// contains filtered or unexported fields
}
ScanRepository main function is to make a first step populating sqlite database with values
type SqliteDB ¶
type SqliteDB struct {
// contains filtered or unexported fields
}
SqliteDB holds sqlite connection and transaction and performs main database function - preparation, population and finishing data migration
func NewSqliteDB ¶
NewSqliteDB attempts to create new instance of SqliteDB struct and attempts to make a connection to the database, once it's successful it assigns variables to a ScanRepository struct and returns a pointer
type SqliteFormatter ¶
type SqliteFormatter struct {
// contains filtered or unexported fields
}
SqliteFormatter is a main struct to handle output for Sqlite
func (*SqliteFormatter) Format ¶
func (f *SqliteFormatter) Format(td *TemplateData, templateContent string) error
Format the data to sqlite format and insert it into appropriate output (Sqlite DSN)
type SqliteOutputOptions ¶
type SqliteOutputOptions struct { // DSN is a Data Source Name to sqlite embedded database, by default it's empty which results in stdout output, // however, if both DSN and OutputFile provided, OutputFile option takes preference over SqliteOutputOptions.DSN DSN string // ScanIdentifier is a unique string passed by the user to identify unique scans. If it's empty, it's generated automatically ScanIdentifier string }
SqliteOutputOptions store options related to SQLite database formatting
type StatHosts ¶
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 ¶
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 ¶
TCPTSSequence describes all information related to `<tcptssequence>` node
type TemplateData ¶
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 ¶
type Trace struct { Port int `xml:"port,attr"` Protocol string `xml:"proto,attr"` Hops []Hop `xml:"hop"` }
Trace struct contains trace information with hops
Source Files ¶
- config.go
- expr.go
- file.go
- format.go
- formatter.go
- formatter_csv.go
- formatter_d2.go
- formatter_dot.go
- formatter_excel.go
- formatter_html.go
- formatter_json.go
- formatter_md.go
- formatter_sqlite.go
- nmap_host.go
- nmap_port.go
- nmap_run.go
- output_options.go
- sqlite_db.go
- sqlite_host_repository.go
- sqlite_os_repository.go
- sqlite_port_repository.go
- sqlite_scan_repository.go
- template_data.go
- workflow.go