43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
|
package ipv4
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
csm "git.loafle.net/commons/service_matcher-go"
|
||
|
cuej "git.loafle.net/commons/util-go/encoding/json"
|
||
|
omd "git.loafle.net/overflow/model/discovery"
|
||
|
omm "git.loafle.net/overflow/model/meta"
|
||
|
omu "git.loafle.net/overflow/model/util"
|
||
|
"git.loafle.net/overflow_scanner/probe/matcher"
|
||
|
)
|
||
|
|
||
|
func scanServiceUDP(port *omd.Port, ds *omd.DiscoverService, resultChan chan interface{}, errChan chan error, stopChan chan struct{}) bool {
|
||
|
portNumber, err := cuej.NumberToInt(port.PortNumber)
|
||
|
if err != nil {
|
||
|
errChan <- fmt.Errorf("Discovery: Service scan port[%s] error %v ", port.PortNumber, err)
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
ms := matcher.GetUDPMatchers()
|
||
|
mi := csm.NewMatchInfo(port.Host.Address, portNumber)
|
||
|
|
||
|
for i := 0; i < len(ms); i++ {
|
||
|
m := ms[i]
|
||
|
p := csm.NewPacket(port.UDPLayer.LayerPayload(), len(port.UDPLayer.LayerPayload()))
|
||
|
|
||
|
if err := m.Match(mi, 0, p); err == nil {
|
||
|
s := &omd.Service{
|
||
|
Key: m.Key(),
|
||
|
Port: port,
|
||
|
MetaCryptoType: omm.ToMetaCryptoType(omm.MetaCryptoTypeEnumNONE),
|
||
|
DiscoveredDate: omu.NowPtr(),
|
||
|
}
|
||
|
|
||
|
resultChan <- s
|
||
|
return true
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return false
|
||
|
}
|