fix: 修复新服务扫描插件的健壮性问题

- ipmi: 删除未使用的 encoding/binary 导入
- rmi: TCP读取改用 io.ReadFull 避免分片导致的解析错误
- jdwp: handshake响应读取改用 io.ReadFull 避免分片误判
- nfs: v4协议回退时使用新连接避免残留数据污染
- snmp: 修正timeout计算与其他插件保持一致
This commit is contained in:
ZacharyZcR
2026-05-19 20:46:22 +08:00
parent a92df59dfe
commit bc2a8f653a
5 changed files with 26 additions and 16 deletions
+14 -8
View File
@@ -5,6 +5,7 @@ package services
import (
"context"
"fmt"
"io"
"time"
"github.com/shadow1ng/fscan/common"
@@ -40,18 +41,23 @@ func (p *RMIPlugin) Scan(ctx context.Context, info *common.HostInfo, session *co
return &ScanResult{Success: false, Service: "rmi"}
}
buf := make([]byte, 256)
// RMI server responds with ProtocolAck (0x4e) followed by endpoint info.
// Read at least 1 byte for the ack; io.ReadFull guarantees it.
ack := make([]byte, 1)
if _, err := io.ReadFull(conn, ack); err != nil {
return &ScanResult{Success: false, Service: "rmi"}
}
if ack[0] != 0x4e {
return &ScanResult{Success: false, Service: "rmi"}
}
buf := make([]byte, 255)
n, err := conn.Read(buf)
if err != nil || n < 5 {
if err != nil && n == 0 {
return &ScanResult{Success: false, Service: "rmi"}
}
// RMI server responds with 0x4e (ProtocolAck) followed by endpoint info
if buf[0] != 0x4e {
return &ScanResult{Success: false, Service: "rmi"}
}
endpoint := parseRMIEndpoint(buf[1:n])
endpoint := parseRMIEndpoint(buf[:n])
return &ScanResult{
Success: true,