This commit is contained in:
crusader 2017-11-22 19:45:25 +09:00
parent 3081c408fd
commit 2f67baeb46
2 changed files with 17 additions and 15 deletions

View File

@ -131,7 +131,7 @@ func (d *discovery) discoverService(port *model.Port, ds *model.DiscoveryService
}, },
func(result interface{}) { func(result interface{}) {
s := result.(*model.Service) s := result.(*model.Service)
logging.Logger().Info(fmt.Sprintf("service: %v", s)) logging.Logger().Info(fmt.Sprintf("service: %s(%s)[%s:%d]", s.ServiceName, s.CryptoType, port.Host.IP, port.PortNumber))
}, },
) )
} }

View File

@ -35,6 +35,8 @@ func scanServiceTCP(port *model.Port, ds *model.DiscoveryService, resultChan cha
errChan <- fmt.Errorf("Discovery: Service scan[%s] on %s:%d error has occurred %v ", sc.Type(), hostIP, portNumber, err) errChan <- fmt.Errorf("Discovery: Service scan[%s] on %s:%d error has occurred %v ", sc.Type(), hostIP, portNumber, err)
break break
} }
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan connected[%s:%d] %s", hostIP, portNumber, sc.Type()))
buf := make([]byte, 1024) buf := make([]byte, 1024)
rn, err := conn.Read(buf) rn, err := conn.Read(buf)
if err != nil { if err != nil {
@ -67,7 +69,7 @@ func hadlePrePacket(info matcher.MatchInfo, sc serviceConnector, conn net.Conn,
}() }()
// logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan pre packet length[%d], buf[%v]", packet.Len, packet.Buffer)) // logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan pre packet length[%d], buf[%v]", packet.Len, packet.Buffer))
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan pre packet length[%d]", packet.Len)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d pre packet length[%d]", sc.Type(), info.IP(), info.Port(), packet.Len))
ms := service.GetTCPMatchers(true) ms := service.GetTCPMatchers(true)
buf := make([]byte, 1024) buf := make([]byte, 1024)
@ -93,30 +95,30 @@ Loop:
for j := 0; j < packetCount; j++ { for j := 0; j < packetCount; j++ {
tPacket := m.Packet(j) tPacket := m.Packet(j)
// logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d], buf[%v]", tPacket.Len, tPacket.Buffer)) // logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d], buf[%v]", tPacket.Len, tPacket.Buffer))
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d]", tPacket.Len)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d send packet length[%d]", sc.Type(), info.IP(), info.Port(), tPacket.Len))
wn, err := conn.Write(tPacket.Buffer) wn, err := conn.Write(tPacket.Buffer)
if nil != err { if nil != err {
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet error %v", err)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d send packet error %v", sc.Type(), info.IP(), info.Port(), err))
break break
} }
if wn != tPacket.Len { if wn != tPacket.Len {
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d] not same with %d", wn, tPacket.Len)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d send packet length[%d] not same with %d", sc.Type(), info.IP(), info.Port(), wn, tPacket.Len))
break break
} }
rn, err := conn.Read(buf) rn, err := conn.Read(buf)
if nil != err { if nil != err {
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive packet error %v", err)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d receive packet error %v", sc.Type(), info.IP(), info.Port(), err))
break break
} }
if m.Match(info, j+1, matcher.NewPacket(buf, rn)) { if m.Match(info, j+1, matcher.NewPacket(buf, rn)) {
// logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive match length[%d], buf[%v]", rn, buf)) // logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive match length[%d], buf[%v]", rn, buf))
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive match length[%d]", rn)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d receive match length[%d]", sc.Type(), info.IP(), info.Port(), rn))
found = true found = true
} else { } else {
// logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive not match length[%d], buf[%v]", rn, buf)) // logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive not match length[%d], buf[%v]", rn, buf))
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive not match length[%d]", rn)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d receive not match length[%d]", sc.Type(), info.IP(), info.Port(), rn))
found = false found = false
break break
} }
@ -146,7 +148,7 @@ Loop:
conn, err := sc.Dial(info.IP(), info.Port()) conn, err := sc.Dial(info.IP(), info.Port())
if err != nil { if err != nil {
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan socket[%s:%d] dial error %v", info.IP(), info.Port(), err)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d socket dial error %v", sc.Type(), info.IP(), info.Port(), err))
break Loop break Loop
} }
@ -154,14 +156,14 @@ Loop:
for j := 0; j < packetCount; j++ { for j := 0; j < packetCount; j++ {
tPacket := m.Packet(j) tPacket := m.Packet(j)
// logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d], buf[%v]", tPacket.Len, tPacket.Buffer)) // logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d], buf[%v]", tPacket.Len, tPacket.Buffer))
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d]", tPacket.Len)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d send packet length[%d]", sc.Type(), info.IP(), info.Port(), tPacket.Len))
wn, err := conn.Write(tPacket.Buffer) wn, err := conn.Write(tPacket.Buffer)
if nil != err { if nil != err {
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet error %v", err)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d send packet error %v", sc.Type(), info.IP(), info.Port(), err))
break break
} }
if wn != tPacket.Len { if wn != tPacket.Len {
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan send packet length[%d] not same with %d", wn, tPacket.Len)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d send packet length[%d] not same with %d", sc.Type(), info.IP(), info.Port(), wn, tPacket.Len))
break break
} }
@ -175,7 +177,7 @@ Loop:
break break
} }
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive packet error %v", err)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d receive packet error %v", sc.Type(), info.IP(), info.Port(), err))
break break
} }
@ -189,11 +191,11 @@ Loop:
} }
// logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive match length[%d], buf[%v]", rn, buf)) // logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive match length[%d], buf[%v]", rn, buf))
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive match length[%d]", rn)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d receive match length[%d]", sc.Type(), info.IP(), info.Port(), rn))
continue continue
} else { } else {
// logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive not match length[%d], buf[%v]", rn, buf)) // logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive not match length[%d], buf[%v]", rn, buf))
logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan receive not match length[%d]", rn)) logging.Logger().Debug(fmt.Sprintf("Discovery: Service scan[%s] on %s:%d receive not match length[%d]", sc.Type(), info.IP(), info.Port(), rn))
break break
} }
} }