This commit is contained in:
crusader 2018-09-05 05:57:18 +09:00
parent bf6b3901c2
commit 3135a11708
11 changed files with 36 additions and 12 deletions

View File

@ -135,6 +135,7 @@ func handlePacketARP(zone *omd.Zone, targetHosts []net.IP, hosts map[string]*omd
Address: ip.String(), Address: ip.String(),
Mac: net.HardwareAddr(packet.SourceHwAddress).String(), Mac: net.HardwareAddr(packet.SourceHwAddress).String(),
Zone: zone, Zone: zone,
DiscoveredBy: "ARP",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
} }

View File

@ -143,6 +143,7 @@ func handlePacketICMP4(zone *omd.Zone, targetHosts []net.IP, hosts map[string]*o
Address: ip.String(), Address: ip.String(),
Mac: net.HardwareAddr(ethLayer.SrcMAC).String(), Mac: net.HardwareAddr(ethLayer.SrcMAC).String(),
Zone: zone, Zone: zone,
DiscoveredBy: "ICMP",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
} }

View File

@ -142,6 +142,7 @@ func handlePacketICMP6(zone *omd.Zone, targetHosts []net.IP, hosts map[string]*o
Address: ip.String(), Address: ip.String(),
Mac: net.HardwareAddr(ethLayer.SrcMAC).String(), Mac: net.HardwareAddr(ethLayer.SrcMAC).String(),
Zone: zone, Zone: zone,
DiscoveredBy: "ICMP",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
} }

View File

@ -72,6 +72,7 @@ SERVICE_LOOP:
Address: ipv4.String(), Address: ipv4.String(),
Meta: meta, Meta: meta,
Zone: discoverySession.Zone(), Zone: discoverySession.Zone(),
DiscoveredBy: "mDNS",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
}) })
@ -84,6 +85,8 @@ SERVICE_LOOP:
PortNumber: json.Number(strconv.Itoa(port)), PortNumber: json.Number(strconv.Itoa(port)),
Meta: meta, Meta: meta,
Host: h, Host: h,
DiscoveredBy: "mDNS",
DiscoveredDate: omu.NowPtr(),
}) })
discoverySession.AddService(&omd.Service{ discoverySession.AddService(&omd.Service{
@ -91,6 +94,8 @@ SERVICE_LOOP:
Key: serviceName, Key: serviceName,
Name: name, Name: name,
Port: p, Port: p,
DiscoveredBy: "mDNS",
DiscoveredDate: omu.NowPtr(),
}) })
} }
@ -102,6 +107,7 @@ SERVICE_LOOP:
Address: ipv6.String(), Address: ipv6.String(),
Meta: meta, Meta: meta,
Zone: discoverySession.Zone(), Zone: discoverySession.Zone(),
DiscoveredBy: "mDNS",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
}) })
@ -114,6 +120,8 @@ SERVICE_LOOP:
PortNumber: json.Number(strconv.Itoa(port)), PortNumber: json.Number(strconv.Itoa(port)),
Meta: meta, Meta: meta,
Host: h, Host: h,
DiscoveredBy: "mDNS",
DiscoveredDate: omu.NowPtr(),
}) })
discoverySession.AddService(&omd.Service{ discoverySession.AddService(&omd.Service{
@ -121,6 +129,8 @@ SERVICE_LOOP:
Key: serviceName, Key: serviceName,
Name: name, Name: name,
Port: p, Port: p,
DiscoveredBy: "mDNS",
DiscoveredDate: omu.NowPtr(),
}) })
} }
} }

View File

@ -144,6 +144,7 @@ func scanV2(target net.IP, discoverySession session.DiscoverySession, credential
Address: target.String(), Address: target.String(),
Meta: meta, Meta: meta,
Zone: discoverySession.Zone(), Zone: discoverySession.Zone(),
DiscoveredBy: "SNMP V2c",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
}) })
@ -152,6 +153,8 @@ func scanV2(target net.IP, discoverySession session.DiscoverySession, credential
PortNumber: credential.Port, PortNumber: credential.Port,
Meta: meta, Meta: meta,
Host: h, Host: h,
DiscoveredBy: "SNMP V2c",
DiscoveredDate: omu.NowPtr(),
}) })
discoverySession.AddService(&omd.Service{ discoverySession.AddService(&omd.Service{
@ -159,6 +162,8 @@ func scanV2(target net.IP, discoverySession session.DiscoverySession, credential
Key: "SNMP", Key: "SNMP",
Name: "SNMP V2c", Name: "SNMP V2c",
Port: p, Port: p,
DiscoveredBy: "SNMP V2c",
DiscoveredDate: omu.NowPtr(),
}) })
// log.Printf("Host: %v, Port: %v, Service: %v", h, p, s) // log.Printf("Host: %v, Port: %v, Service: %v", h, p, s)

View File

@ -96,6 +96,7 @@ func tryConnect(discoverySession session.DiscoverySession, ports map[int]*omd.Po
p := &omd.Port{ p := &omd.Port{
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP), MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
PortNumber: json.Number(strconv.Itoa(port)), PortNumber: json.Number(strconv.Itoa(port)),
DiscoveredBy: "TCP Connection",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
} }
p.Host = targetHost p.Host = targetHost

View File

@ -132,6 +132,7 @@ func handlePacketTCP4(discoverySession session.DiscoverySession, host *omd.Host,
p := &omd.Port{ p := &omd.Port{
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP), MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
PortNumber: json.Number(strconv.Itoa(port)), PortNumber: json.Number(strconv.Itoa(port)),
DiscoveredBy: "TCP SYN",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
} }
p.Host = host p.Host = host

View File

@ -96,6 +96,7 @@ func tryConnect(discoverySession session.DiscoverySession, ports map[int]*omd.Po
p := &omd.Port{ p := &omd.Port{
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP), MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumTCP),
PortNumber: json.Number(strconv.Itoa(port)), PortNumber: json.Number(strconv.Itoa(port)),
DiscoveredBy: "UDP Connection",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
} }
p.Host = targetHost p.Host = targetHost

View File

@ -149,6 +149,7 @@ func handlePacketUDP4(discoverySession session.DiscoverySession, host *omd.Host,
MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumUDP), MetaPortType: omm.ToMetaPortType(omm.MetaPortTypeEnumUDP),
PortNumber: json.Number(strconv.Itoa(port)), PortNumber: json.Number(strconv.Itoa(port)),
UDPLayer: udpLayer, UDPLayer: udpLayer,
DiscoveredBy: "UDP Matcher",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
} }
p.Host = host p.Host = host

View File

@ -44,6 +44,7 @@ LOOP:
"UPC": rd.UPC, "UPC": rd.UPC,
}, },
Zone: discoverySession.Zone(), Zone: discoverySession.Zone(),
DiscoveredBy: "UPnP",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
}) })

View File

@ -83,6 +83,7 @@ LOOP:
Key: discoveredMatcher.Key(), Key: discoveredMatcher.Key(),
Name: discoveredMatcher.Name(matchCtx), Name: discoveredMatcher.Name(matchCtx),
Meta: matchCtx.GetAttributes(), Meta: matchCtx.GetAttributes(),
DiscoveredBy: "Service Matcher",
DiscoveredDate: omu.NowPtr(), DiscoveredDate: omu.NowPtr(),
Port: targetPort, Port: targetPort,
}) })