69 Commits
Author SHA1 Message Date
NOPTrace 6bb8ccd490 fix: set conn deadline in smtp testAnonymousAccess/testOpenRelay to avoid hang on silent servers
testAnonymousAccess and testOpenRelay dial the target and immediately
hand the connection to smtp.NewClient without setting any deadline.
smtp.NewClient reads the 220 greeting as its first operation, so a
server that accepts TCP but never sends data (honeypot/tarpit) blocks
the goroutine forever. The outer select waits on resultChan or
ctx.Done(); with the default -gt 0 the context has no deadline, so
Scan never returns and RunScan's wg.Wait() freezes the whole process.

Set the same ModuleTimeout deadline used by the other functions in
this file (doSMTPAuth, testVRFYCommand, testEXPNCommand, getServerInfo).

Verified against a live accept-but-silent SMTP endpoint:
- unpatched: process hangs (31 goroutines, stack at smtp.go:276)
- patched: full plugin chain completes in ~92s, no regression on
  normally-responding servers (detection output identical)
2026-09-17 09:24:05 +08:00
ZacharyZcR a1ff55ef55 fix: resolve recent service scan regressions 2026-08-26 04:19:58 +08:00
ZacharyZcR a3ccc2827b fix: Telnet 弱口令误报,Cisco MOTD 横幅触发 shell prompt 误判 (Closes #590)
isShellPrompt 使用 Contains 匹配 # $ > 单字符,Cisco IOS MOTD 横幅中
的装饰线(###)和文本内容会误触发,导致未发送凭据就判定认证成功。

重写 isShellPrompt 改为行尾匹配,排除全同字符装饰线;
performTelnetAuth 等待 login prompt 阶段移除 isShellPrompt 检查,
未授权检测由 testUnauthAccess 专门负责。
2026-06-27 16:35:18 +08:00
ZacharyZcR 4922122530 fix: 修复 #591 POC 对 HTTPS 端口误用 HTTP + #592 空指针 panic
1. buildTargetURL 对 443/8443 等已知 TLS 端口默认使用 https scheme,
   webtitle 触发 POC 扫描前将检测到的协议写回 info.URL,
   避免对 HTTPS 服务发送 HTTP 请求导致 EOF
2. GetInfo 添加 probe nil 检查,防止探针初始化失败时空指针 panic
3. 删除 test-nuclei-example.yaml 测试模板,避免 robots.txt 误报
2026-06-27 16:23:52 +08:00
ZacharyZcR 65e64e8967 fix: Oracle TNS Resend 重试 + ANO 格式修正,扩展集成测试至 22 协议
Oracle raw TNS 修复:
- connect 阶段支持 Resend 包重试(Oracle 18c+ 需要)
- ANO 请求补齐加密/完整性算法列表和 auth UB2 字段
- ANO length 字段修正为包含 magic 的完整长度
- Oracle 18c ANO 仍不兼容(字节级匹配 go-ora 但被拒绝),爆破标记 SKIP

新增集成测试协议:
ActiveMQ, Zookeeper, Rsync, VNC, SNMP, Oracle(服务检测), Cassandra, Neo4j, Kafka, SMTP, LDAP

VNC 修复:换用支持 RFB 3.8 的 debian-xfce-vnc 镜像
2026-06-17 12:51:43 +08:00
ZacharyZcR 1c6f3b80d0 fix: Cassandra CQL 协议头缺少 flags 字节 + version 方向位错误
cqlSend 写 8 字节头(缺 flags),实际 CQL v4 需要 9 字节。
version byte 0x84 是 response 方向,request 应为 0x04。

同时扩展集成测试至 17 个协议:新增 Memcached、Elasticsearch、
MSSQL、RabbitMQ、MQTT、LDAP、Cassandra、Neo4j、Kafka、SMTP。
2026-06-17 12:51:42 +08:00
ZacharyZcR 9b8e4f3f3b fix: MongoDB SCRAM 认证因 BSON 键序随机而失败
Go map 遍历顺序不确定,导致 buildBSON 输出的命令文档中
saslStart/saslContinue 不一定是第一个键,MongoDB 拒绝执行。

引入有序 []mongoKV 类型,SASL 命令改用 orderedDoc() 构造。
同时新增 6 协议集成测试框架(Docker Compose + go test -tags integration)。
2026-06-17 12:51:42 +08:00
ZacharyZcR 0612255893 test: 补充单元测试覆盖率 29.9% → 36.6%
新建 18 个测试文件,追加 30 个已有测试文件,覆盖协议解析、
错误分类、CEL 表达式求值、YAML 反序列化、字节编码等纯函数。
2026-06-17 12:51:41 +08:00
ZacharyZcR 6eff1d5ccf fix: 外部审查 8 项修复 + 国密 TLS 按需回退
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
- UserAgent 默认值回退 + 注册 -ua flag (#2)
- README 编译命令 main.go → . (#3)
- README 版本号同步 rc.1 (#4)
- Client.go gmtls stdout 劫持删除 (#5)
- ms17010 smb1GetResponse size<32 越界 panic (#6)
- SSH 拨号超时统一 ModuleTimeout (#8)
- AddPorts 死字段删除 (#9)
- 国密 TLS 按需回退:标准 TLS 握手失败时仅在错误为
  cipher/protocol 不兼容时尝试国密,跳过超时/拒绝等连接级错误
2026-06-15 04:46:25 +08:00
ZacharyZcR 2f7d2d49c6 fix: redis exploit 超时改用配置值 & 清理死代码
- redis exploit 硬编码 30s deadline 改为 config.ModuleTimeout(),与同文件其他超时一致
- 删除 BaseScanStrategy.LogPluginInfo 残留死代码(全是空操作)
- .gitignore 补充 fscan_cli/fscan_web/embed-agent 构建产物
2026-06-14 23:58:56 +08:00
ZacharyZcR 42092d8664 fix: 修复实机测试发现的可靠性问题 (v2.2.0-rc.1)
- UDP 插件在 -p 指定端口时被跳过
- Redis exploit 无超时保护 / readReply 吞没非超时错误
- service_probe 连接丢失后静默成功
- SNMP 探测成功但终端无输出
- SSH 爆破不稳定 (并发过高 + 自适应超时过短 + 限流误判)
- 进度条 isActive 竞态

新增 Config.ModuleTimeout() 协议级超时下限 (≥3s)
新增 ErrorTypeThrottle 限流错误分类
2026-06-14 22:14:02 +08:00
ZacharyZcR e6c5e5a9a8 fix: -nopoc 禁用POC时不再输出错误日志
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
2026-06-13 23:09:47 +08:00
ZacharyZcR 8fb66e8e2f fix: 修复3个实测发现的问题
1. -pwd 支持逗号分隔多个密码
   之前 -pwd "123,456,root" 被当作单个密码,SSH root:123 无法匹配
   现在逗号分隔为独立密码,空格保留(可能是密码的一部分)

2. -nobr 禁用爆破时仍检测 Redis 未授权访问
   未授权访问是服务探测不是爆破,不应被 -nobr 跳过
   将未授权检测移到 DisableBrute 判断之前

3. 指定端口时跳过 UDP 插件调度
   -p 80 只扫 HTTP 时不需要 SNMP/BACnet/DNS 等 UDP 探测
   仅在默认端口扫描时才分发 UDP 插件
   效果: -p 80 从 9 秒降到 3 秒
2026-06-13 22:35:48 +08:00
ZacharyZcR 28686f845d fix: 彻底解决UDP插件阻塞导致扫描无法结束的问题
根因分析(通过 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秒完成
2026-06-13 22:07:03 +08:00
ZacharyZcR 06ba595e32 fix: UDP插件改用 conn.SetDeadline 替代类型断言 2026-06-13 21:52:26 +08:00
ZacharyZcR 1a7770530d fix: 所有UDP插件添加ReadDeadline防止无限阻塞
SNMP/BACnet/DNS/IPMI/TFTP 的 conn.Read() 在目标不响应时
无限阻塞(goroutine 泄漏),导致整个扫描无法结束。

在 Write 前设置 ReadDeadline 确保超时后返回。
2026-06-13 21:42:49 +08:00
ZacharyZcR 2a9a3c36e2 fix: 修复6个运行时问题
1. 抑制 gmtls 库的 handshake error stdout 噪声
   gmtls/conn.go:1304 硬编码了 fmt.Println,在调用时临时重定向 os.Stdout

2. MySQL 3306 服务名误识别为 genetec-5400
   nmap 指纹库将 MySQL 握手包的随机 salt 误匹配,通过 banner 特征校正

3. 管道输出时自动禁用 ANSI 控制码
   检测 stdout 是否为终端,非终端时自动启用 NoColor

4. 进度条完成消息措辞精确化
   去掉冗余冒号,保持信息简洁一致

5. URL 模式跳过不必要的 TLS 探测
   用户已通过 -u 显式指定 http:// 协议时直接使用,不再做 TLS 握手

6. 无网络探测数据时降低默认重试次数
   -np 跳过存活探测后,将默认重试从 3 降到 2,加速不可达主机的超时
2026-06-13 19:53:28 +08:00
ZacharyZcR 6a1636112f fix+perf: 修复10个bug & 10项性能优化
Bug修复:
- clustersend CEL结果判断从字符串比较改为类型断言
- Nuclei DSL matcher安全降级为false避免误报
- clusterpoc发现漏洞后返回true修正语义
- reverseCheck加10s超时防止ceye API阻塞
- doSearch/bmatches正则编译结果缓存到sync.Map
- evalset CEL求值失败时存空字符串而非原始表达式
- CEL wait()函数加nil Reverse指针检查防panic
- MongoDB readMongoMsg应用timeout参数设置读超时
- TXTWriter.Close确保Sync失败后仍调用file.Close

性能优化:
- 指纹regex缓存从RWMutex+map改为sync.Map消除锁竞争
- CaseInsensitive指纹词加载时预小写化避免匹配时分配
- 版本提取FindAllStringSubmatch限制返回数量
- i18n.Tr用strconv.Itoa替代Sprintf减少分配
- POC加载用atomic.Bool+DCLP消除热路径锁
- 结果缓冲map预分配容量减少rehash
- HTTP连接池参数随并发数动态调整
- getRuleHash去除反射+Headers排序保证确定性dedup
- POC并发加载用channel替代Mutex收集结果
2026-06-13 18:46:14 +08:00
ZacharyZcR 15a7670ba2 Harden scan robustness and tests 2026-06-13 07:55:37 +08:00
ZacharyZcR 1595c92aed feat: 统一服务缓存 + 指纹驱动插件匹配
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
将 webServiceCache 扩展为通用 serviceCache,所有指纹识别结果
统一缓存,插件匹配时端口不命中则回退到服务名称匹配。

删除多余的 service_cache.go,复用已有的 ServiceInfo 体系。
补充 nil 防御、Explicit 标记、大量单元/集成/回归测试。
2026-06-12 19:49:07 +08:00
ZacharyZcR 5b7e72e56e Fix credential cleanup and explicit tuning flags 2026-06-12 15:30:44 +08:00
ZacharyZcR 52f872b8d1 fix: webtitle HTTP 请求失败时重试,修复批量扫描 POC 缺失 #587
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
批量扫描(-hf)时并发压力导致 HTTP 请求瞬时失败,getWebTitle
直接返回 error,跳过指纹识别和 POC 触发。

加入指数退避重试(200ms→400ms),最多 3 次,复用 config.MaxRetries。
2026-06-12 12:23:54 +08:00
ZacharyZcR b94e8bc4ca fix: 修复 SSH 扫描 goroutine 泄漏
ssh.NewClientConn 不接受 context,context 取消后底层 TCP 连接未关闭,
导致 readLoop goroutine 永久阻塞在 conn.Read 上。大规模扫描时泄漏数万
goroutine。

- doSSHAuth 新增 goroutine 监听 context 取消并关闭底层连接
- TestSingleCredential 移除 5 秒超时放弃逻辑,改为持续等待清理
2026-06-12 03:59:02 +08:00
ZacharyZcR a02eed0518 refactor: mylib 重命名为 libs
更清晰的目录命名,libs/ 存放内嵌的独立协议实现库。
2026-06-01 08:22:13 +08:00
ZacharyZcR d6d323854a refactor: 完成全局状态到 session 的完整迁移
将 plugins/services、plugins/local、plugins/web、webscan 层的日志输出、
漏洞结果保存和 TCP 计数器从全局 common.Log*/GetGlobalState() 迁移到
session 实例方法,确保 SDK 并发扫描时各实例完全隔离。

- 50 个文件,所有插件日志走 session.Log*
- DoRequest 加入 session 参数,计数器走 session.State
- POC 执行器通过 POCContext.Session 传递
- 仅保留 init() 和 CEL runtime 等无 session 场景的全局回退
2026-06-01 08:13:23 +08:00
ZacharyZcR 569d21a8bc fix: harden address parsing edge cases 2026-06-01 04:03:46 +08:00
ZacharyZcR 8ec96bfe6d fix: harden scan edge cases 2026-06-01 03:32:13 +08:00
ZacharyZcR 3e4e2db722 feat: stream large host scans 2026-06-01 02:55:28 +08:00
ZacharyZcR 8d30ee334c Add native protocol service plugins
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
2026-05-23 15:51:50 +08:00
ZacharyZcR 73cbe803c4 Expand i18n coverage 2026-05-23 15:18:40 +08:00
ZacharyZcR 9ed6cc95b6 replace string builder sprintf with fprintf
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
2026-05-23 07:53:28 +08:00
ZacharyZcR a0f0379c6c silence ci warnings and staticcheck suggestions 2026-05-23 07:50:49 +08:00
ZacharyZcR 3c7823355d tighten scan session and HTTP paths 2026-05-23 07:46:53 +08:00
ZacharyZcR 1a714f6a0c reduce scanner client fingerprints 2026-05-23 07:20:24 +08:00
ZacharyZcR 0046817c2e fix mssql login client metadata 2026-05-23 07:17:55 +08:00
ZacharyZcR e0080555b4 fix: 跳过snmp社区字符串暴力破解中的冗余public探测
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
2026-05-19 21:00:47 +08:00
ZacharyZcR bc2a8f653a fix: 修复新服务扫描插件的健壮性问题
- ipmi: 删除未使用的 encoding/binary 导入
- rmi: TCP读取改用 io.ReadFull 避免分片导致的解析错误
- jdwp: handshake响应读取改用 io.ReadFull 避免分片误判
- nfs: v4协议回退时使用新连接避免残留数据污染
- snmp: 修正timeout计算与其他插件保持一致
2026-05-19 20:46:22 +08:00
ZacharyZcR a92df59dfe fix: NFS plugin RPC probe + UDP dispatch in auto mode
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
NFS: use RPC NULL call to detect NFS service before MOUNT EXPORT
UDP dispatch: query plugin registry directly in auto mode instead of
GetPlugins which excludes UDP from FilterService
2026-05-19 00:37:35 +08:00
ZacharyZcR 0a28db7371 feat: add NFS, RMI and IPMI plugins
NFS (2049/TCP): Sun RPC EXPORT call, lists shared directories
RMI (1099/TCP): Java RMI handshake, detects exposed JMX/RMI endpoints
IPMI (623/UDP): RMCP ping + channel auth capabilities probe

All pure stdlib, zero new dependencies.
2026-05-19 00:01:58 +08:00
ZacharyZcR 778ba019d5 feat: add IMAP and POP3 plugins for mail server detection
IMAP (143/993): banner grab + LOGIN brute force
POP3 (110/995): banner grab + USER/PASS brute force
Both registered as safe default plugins with auth-check capability.
2026-05-18 23:29:52 +08:00
ZacharyZcR f43e3e3d0a feat: add JDWP plugin for Java debug port detection
Detects exposed JDWP (Java Debug Wire Protocol) services on ports
5005/8000/8787/5050. Performs protocol handshake and reports as VULN
since an exposed debug port allows remote code execution.
2026-05-18 23:22:15 +08:00
ZacharyZcR a1588a321f feat: SDK agent integration + UDP plugin framework + SNMP plugin
SDK enhancements for endpoint agent embedding:
- ScanWithController for pause/resume and live stats
- OnProgress callback for periodic progress reporting
- TaskID injection into every scan result
- ScanController with goroutine-safe pause/resume/stats
- Multi-target stats aggregation (race-free)

UDP plugin infrastructure:
- PluginTypeUDP registry with dedicated dispatch path
- DialUDP on ScanSession with rate limiting and packet counting
- UDP plugins bypass TCP port scan, probe targets directly
- FilterService excludes UDP plugins from TCP port matching

SNMP plugin (first UDP plugin):
- SNMPv2c GetRequest probe for sysDescr detection
- Community string brute force (public/private/community/etc)
- Pure stdlib implementation (encoding/asn1)
- Registered as safe default plugin on port 161/UDP

Tests: 95.7% SDK coverage, race-free, 50+ new test cases
2026-05-18 23:11:39 +08:00
ZacharyZcR 5a884ca6ad fix lint issues before merge 2026-05-18 17:59:00 +08:00
ZacharyZcR c0a9cfd8f5 use config proxy state for credential prechecks 2026-05-18 17:13:19 +08:00
ZacharyZcR adb3ac5b74 add session-aware scan logging 2026-05-18 16:19:34 +08:00
ZacharyZcR 3dde0c6a8e move plugin safety metadata to registry 2026-05-18 15:57:18 +08:00
ZacharyZcR bce0a718ea slim mssql credential check 2026-05-18 14:00:45 +08:00
ZacharyZcR 40c3f1423e slim oracle credential check 2026-05-18 13:13:40 +08:00
ZacharyZcR bfd64f78ed 瘦身: Kafka/MongoDB/Cassandra用raw TCP替代重型依赖
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled
- kafka: 移除IBM/sarama(45MB), 自实现SASL PLAIN+ApiVersions协议(~150行)
- mongodb: 移除mongo-driver(25MB), 自实现OP_MSG+saslStart认证(~180行)
- cassandra: 移除gocql(1.2MB), 自实现CQLv4 STARTUP+SASL PLAIN(~130行)
- 同时移除间接依赖: pierrec/lz4, klauspost/compress, eapache/snappy等

二进制: 47MB → 40MB (-15%), 移除~55MB压缩依赖
全部13个测试包通过
2026-05-18 06:37:05 +08:00
ZacharyZcR 639298b7c8 修复全部SA1006: fmt.Errorf(i18n)统一使用"%s"前缀 2026-05-18 05:17:40 +08:00