mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-25 04:31:52 +08:00
fix: 修复新服务扫描插件的健壮性问题
- ipmi: 删除未使用的 encoding/binary 导入 - rmi: TCP读取改用 io.ReadFull 避免分片导致的解析错误 - jdwp: handshake响应读取改用 io.ReadFull 避免分片误判 - nfs: v4协议回退时使用新连接避免残留数据污染 - snmp: 修正timeout计算与其他插件保持一致
This commit is contained in:
+14
-8
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user