diff --git a/pkg/port/port.go b/pkg/port/port.go index f05cc13b..fbb44578 100644 --- a/pkg/port/port.go +++ b/pkg/port/port.go @@ -33,21 +33,22 @@ func (p *Port) StringWithDetails() string { } type Service struct { - DeviceType string `json:"device_type,omitempty"` - ExtraInfo string `json:"extra_info,omitempty"` - HighVersion string `json:"high_version,omitempty"` - Hostname string `json:"hostname,omitempty"` - LowVersion string `json:"low_version,omitempty"` - Method string `json:"method,omitempty"` - Name string `json:"name,omitempty"` - OSType string `json:"os_type,omitempty"` - Product string `json:"product,omitempty"` - Proto string `json:"proto,omitempty"` - RPCNum string `json:"rpc_num,omitempty"` - ServiceFP string `json:"service_fp,omitempty"` - Tunnel string `json:"tunnel,omitempty"` - Version string `json:"version,omitempty"` - Confidence int `json:"confidence,omitempty"` + DeviceType string `json:"device_type,omitempty"` + ExtraInfo string `json:"extra_info,omitempty"` + HighVersion string `json:"high_version,omitempty"` + Hostname string `json:"hostname,omitempty"` + LowVersion string `json:"low_version,omitempty"` + Method string `json:"method,omitempty"` + Name string `json:"name,omitempty"` + OSType string `json:"os_type,omitempty"` + Product string `json:"product,omitempty"` + Proto string `json:"proto,omitempty"` + RPCNum string `json:"rpc_num,omitempty"` + ServiceFP string `json:"service_fp,omitempty"` + Tunnel string `json:"tunnel,omitempty"` + Version string `json:"version,omitempty"` + Confidence int `json:"confidence,omitempty"` + CPEs []string `json:"cpes,omitempty"` } func (s *Service) String() string { diff --git a/pkg/runner/nmap.go b/pkg/runner/nmap.go index 53d62645..990c2e98 100644 --- a/pkg/runner/nmap.go +++ b/pkg/runner/nmap.go @@ -267,6 +267,12 @@ func (r *Runner) convertNmapPortToNaabuPort(nmapPort nmap.Port) *port.Port { // Convert service information if available if nmapPort.Service.Name != "" { + // Convert CPEs from nmap.CPE to []string + cpes := make([]string, 0, len(nmapPort.Service.CPEs)) + for _, cpe := range nmapPort.Service.CPEs { + cpes = append(cpes, string(cpe)) + } + naabuPort.Service = &port.Service{ Name: nmapPort.Service.Name, Product: nmapPort.Service.Product, @@ -282,6 +288,7 @@ func (r *Runner) convertNmapPortToNaabuPort(nmapPort nmap.Port) *port.Port { Tunnel: nmapPort.Service.Tunnel, LowVersion: nmapPort.Service.LowVersion, HighVersion: nmapPort.Service.HighVersion, + CPEs: cpes, } }