Update PortScan.go

This commit is contained in:
I0veD 2025-04-20 17:55:54 +08:00 committed by GitHub
parent fc1962055d
commit 51e54698a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -120,7 +120,7 @@ func PortConnect(addr Addr, results chan<- ScanResult, timeout int64, wg *sync.W
// 记录开放端口
address := fmt.Sprintf("%s:%d", addr.ip, addr.port)
Common.LogInfo(fmt.Sprintf("端口开放 %s", address))
Common.LogSuccess(fmt.Sprintf("端口开放 %s", address))
// 保存端口扫描结果
portResult := &Common.ScanResult{
@ -145,6 +145,7 @@ func PortConnect(addr Addr, results chan<- ScanResult, timeout int64, wg *sync.W
scanner := NewPortInfoScanner(addr.ip, addr.port, conn, time.Duration(timeout)*time.Second)
if serviceInfo, err := scanner.Identify(); err == nil {
result.Service = serviceInfo
// 构造服务识别日志
var logMsg strings.Builder
logMsg.WriteString(fmt.Sprintf("服务识别 %s => ", address))
@ -201,11 +202,8 @@ func PortConnect(addr Addr, results chan<- ScanResult, timeout int64, wg *sync.W
Details: details,
}
Common.SaveResult(serviceResult)
if serviceInfo.Name != "unknown" {
Common.LogSuccess(logMsg.String())
} else {
Common.LogDebug(logMsg.String())
}
}
}