Documentation
¶
Index ¶
- Constants
- Variables
- func Completions() []display.Options
- func Detail(port *host.Port, hostLabel string) display.Detail
- func DisplayDetails() []display.Options
- func DisplayHeaders() []display.Options
- func InfoPanes(port *host.Port) []display.Pane
- func Insights(port *host.Port) (lines []string)
- type Address
- type Service
Constants ¶
const ( // Address.Type (nmap `addrtype` attribute). AddrTypeIPv4 = "ipv4" AddrTypeIPv6 = "ipv6" AddrTypeMAC = "mac" // Port.Protocol / Service.Protocol (nmap `proto` attribute). ProtoTCP = "tcp" ProtoUDP = "udp" ProtoSCTP = "sctp" )
Address types and transport protocols.
These are NOT an enum: the values are the exact strings nmap writes into its XML `addrtype`/`proto` attributes (Address.Type, Port.Protocol/Service.Protocol), unmarshalled straight into the `string` fields via their `xml:"…"` tags. They are therefore an external contract whose spelling must not drift — these consts give the codebase one authoritative spelling to switch/compare against instead of literals duplicated across the network, scan/ingest and cmd packages.
Variables ¶
var DisplayFields = map[string]func(port *host.Port) string{ "ID": func(port *host.Port) string { id := display.FormatSmallID(port.Id) if port.State == nil { return id } switch port.State.State { case hostdomain.PortOpen: return color.HiGreenString(id) case hostdomain.PortFiltered: return color.HiYellowString(id) case hostdomain.PortClosed: return color.HiRedString(id) } return id }, "Num": func(port *host.Port) string { return strconv.Itoa(int(port.Number)) }, "Proto": func(port *host.Port) string { proto := color.HiBlackString(port.Protocol) if port.Service == nil { return proto } else { proto = "" } if port.Service.Protocol != "" { proto += port.Service.Protocol } else if port.Service.Name != "" { proto += port.Service.Name } return proto }, "Product": func(port *host.Port) string { if port.Service == nil { return "" } product := port.Service.Product if port.Service.Version == "" { return product } product += color.HiBlackString(fmt.Sprintf(" (v%s)", port.Service.Version)) return product }, "Version": func(port *host.Port) string { serv := port.Service version := port.Service.Version if serv.HighVersion != "" && serv.LowVersion != "" { version += color.HiBlackString(" (%s / %s)", serv.LowVersion, serv.HighVersion) } return version }, "Info": func(port *host.Port) string { if len(port.Scripts) == 0 { return port.Service.ExtraInfo } var scripts string for _, script := range port.Scripts { name := script.Name if script.Output == "" && script.Name == "" { continue } scripts += fmt.Sprintf("(%s) %s\n", name, script.Output) } return strings.TrimSuffix(scripts, "\n") }, "Extra Info": func(port *host.Port) string { if port.Service == nil { return "" } return port.Service.ExtraInfo }, "Fingerprint": func(port *host.Port) string { if port.Service == nil { return "" } return port.Service.ServiceFP }, "Method": func(port *host.Port) string { if port.Service == nil { return "" } return color.HiBlackString(port.Service.Method) }, "State": func(port *host.Port) string { if port.State == nil { return "unknown" } switch port.State.State { case hostdomain.PortOpen: return color.HiGreenString(hostdomain.PortOpen) case hostdomain.PortFiltered: return color.HiYellowString(hostdomain.PortFiltered) case hostdomain.PortClosed: return color.HiRedString(hostdomain.PortClosed) } return port.State.State }, "Reason": func(port *host.Port) string { if port.State == nil { return "undefined" } return port.State.Reason }, "Scripts": func(port *host.Port) string { scripts := "" for _, script := range port.Scripts { scripts += printScript(script, 0) } return scripts }, }
DisplayFields maps field names to their value generators.
Functions ¶
func Completions ¶
Completions returns some columns to be combined into completion candidates and/or their descriptions.
func Detail ¶
Detail assembles the full `info` view for a single service: the identity banner, the side-by-side info panes, the derived insights, and the NSE scripts as a trailing section. It hands these to the shared display.Detail renderer, so a service's detail view is laid out identically to every other domain's. hostLabel is the owning host's display name (passed in, since a Port doesn't reference its host).
func DisplayDetails ¶
DisplayDetails returns the headers for a detailed service view.
func DisplayHeaders ¶
DisplayHeaders returns all weighted table headers for a table of services/ports.
Types ¶
type Address ¶
Address - An address somewhere on a network, or on a host. Can be an IPv4/v6 address, a MAC address, or else. This type has fields that are compliant with Nmap scan schemas.