mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
根因分析(通过 goroutine dump 定位): 1. UDP conn.Write 在 WSL2 上可能永久阻塞(SetDeadline 对 Write 不生效) 2. SNMP community 爆破混入通用密码字典(57个),串行 × 10s超时 = 10分钟 修复: - 提取 udpProbe() 公共函数,用 context timeout + conn.Close 双保险 超时后强制关闭连接,中断阻塞的 Write/Read - BACnet/DNS/IPMI/TFTP 统一使用 udpProbe() - SNMP probe 使用 goroutine + context select 保护 - SNMP community 列表不再混入通用密码字典(8个专用 community 足够) - SNMP 后续 community 爆破用 3s 短超时 + 连续失败 3 次快速退出 效果: 同样的扫描从无限卡死 → 9秒完成
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
//go:build plugin_dns || !plugin_selective
|
|
|
|
package services
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/shadow1ng/fscan/common"
|
|
"github.com/shadow1ng/fscan/plugins"
|
|
)
|
|
|
|
type DNSPlugin struct {
|
|
plugins.BasePlugin
|
|
}
|
|
|
|
func NewDNSPlugin() *DNSPlugin {
|
|
return &DNSPlugin{BasePlugin: plugins.NewBasePlugin("dns")}
|
|
}
|
|
|
|
func (p *DNSPlugin) Scan(ctx context.Context, info *common.HostInfo, session *common.ScanSession) *ScanResult {
|
|
timeout := session.Config.Timeout
|
|
if timeout <= 0 {
|
|
timeout = 3 * time.Second
|
|
}
|
|
|
|
target := info.Target()
|
|
queryID := randomUint16()
|
|
query := buildDNSRootNSQuery(queryID)
|
|
|
|
data, n := udpProbe(ctx, session, target, timeout, query, 1500)
|
|
if data == nil || n < 12 {
|
|
return &ScanResult{Success: false, Service: "dns"}
|
|
}
|
|
|
|
banner, ok := parseDNSResponse(data[:n], queryID)
|
|
if !ok {
|
|
return &ScanResult{Success: false, Service: "dns"}
|
|
}
|
|
|
|
return &ScanResult{
|
|
Success: true,
|
|
Type: plugins.ResultTypeService,
|
|
Service: "dns",
|
|
Banner: banner,
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
RegisterUDPPluginWithPorts("dns", func() Plugin {
|
|
return NewDNSPlugin()
|
|
}, []int{53})
|
|
}
|