nparse

package module
v0.0.0-...-7c9dd51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 2 Imported by: 0

README

Nparse

nparse converts Nmap's XML output to JSON.

It can also be used as a Go library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Addr     string `xml:"addr,attr" json:"addr"`
	AddrType string `xml:"addrtype,attr" json:"addrType"`
	Vendor   string `xml:"vendor,attr" json:"vendor"`
}

Address holds the address subnodes of the host nodes in the XML.

type ExtraPort

type ExtraPort struct {
	State string `xml:"state,attr" json:"state"`
	Count string `xml:"count,attr" json:"count"`
}

type Host

type Host struct {
	Status     State      `xml:"status" json:"status"`
	Addrs      []Address  `xml:"address" json:"addrs"`
	Hostnames  []Hostname `xml:"hostnames>hostname" json:"hostnames"`
	Ports      []Port     `xml:"ports>port" json:"ports"`
	ExtraPorts ExtraPort  `xml:"ports>extraports" json:"extraports"`
	ScannedAt  string     `xml:"endtime,attr" json:"scannedAt"`
}

Host holds the host node from the XML.

func (Host) AddrInfo

func (h Host) AddrInfo(addrType string) Address

AddrInfo returns all the information held by Address struct associated with the given address type ("ipv4" or "mac").

type Hostname

type Hostname struct {
	Hostname string `xml:"name,attr" json:"hostname"`
	Type     string `xml:"type,attr" json:"type"`
}

type NmapScan

type NmapScan struct {
	Args  string `xml:"args,attr" json:"args"`
	Hosts []Host `xml:"host" json:"hosts"`
}

NmapScan is the unmarshaled version of the Nmap's XML output.

func NewNmapScan

func NewNmapScan(data []byte) (*NmapScan, error)

NewNmapScan reads the content of the Nmap's XML file, in bytes, and returns a NmapScan struct, or an error.

func (*NmapScan) Host

func (n *NmapScan) Host(addr string) Host

Host simply returns the information about the provided host. Host only accepts the host's IPv4 as parameter.

func (*NmapScan) Json

func (n *NmapScan) Json() []byte

Json simply marshals an NmapScan to JSON.

type Port

type Port struct {
	Protocol string  `xml:"protocol,attr" json:"protocol"`
	PortId   int     `xml:"portid,attr" json:"portId"`
	State    State   `xml:"state" json:"state"`
	Service  Service `xml:"service" json:"service"`
}

Port is a marshaled version of the hosts nodes in the XML.

type Service

type Service struct {
	Name      string `xml:"name,attr" json:"name"`
	Product   string `xml:"product,attr" json:"product"`
	Version   string `xml:"version,attr" json:"version"`
	Extrainfo string `xml:"extrainfo,attr" json:"extrainfo"`
}

Service is a marshaled version of the hosts nodes in the XML.

type State

type State struct {
	State  string `xml:"state,attr" json:"state"`
	Reason string `xml:"reason,attr" json:"reason"`
}

State is a marshaled version of the hosts nodes in the XML.

type Status

type Status struct {
	State  string `xml:"state,attr" json:"state"`
	Reason string `xml:"reason,attr" json:"reason"`
}

Directories

Path Synopsis
cmd
nparse command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL