github.com/chainreactors/fingers@v1.2.1/fingerprinthub/README.md (about) 1 # FingerprintHub V4 Engine 2 3 基于 [neutron](https://github.com/chainreactors/neutron) 的 FingerprintHub v4 指纹识别引擎。 4 5 ## 特性 6 7 - ✅ 完全基于 neutron 模板引擎 8 - ✅ 支持 FingerprintHub v4 YAML 格式 9 - ✅ 支持所有 matcher 类型(包括 favicon) 10 - ✅ 支持 HTTP 和 Network(TCP/UDP/TLS)指纹识别 11 - ✅ **兼容 tcp/udp 字段**:自动转换为 network 格式 12 - ✅ **完整的 CPE 支持**:自动从 metadata 提取 vendor 和 product 13 - ✅ 高性能:13,718 templates/sec 加载速度 14 - ✅ 高准确率:99.97% 成功率(3,144/3,145 模板) 15 16 ## 快速开始 17 18 ### 基础使用 19 20 ```go 21 package main 22 23 import ( 24 "github.com/chainreactors/fingers/fingerprinthub_v4" 25 "os" 26 ) 27 28 func main() { 29 // 创建引擎 30 engine, err := fingerprinthub_v4.NewFingerPrintHubV4Engine() 31 if err != nil { 32 panic(err) 33 } 34 35 // 加载指纹模板 36 err = engine.LoadFromFS(os.DirFS("path/to/fingerprints"), "*.yaml") 37 if err != nil { 38 panic(err) 39 } 40 41 // 匹配 HTTP 响应 42 httpResponse := []byte("HTTP/1.1 200 OK\r\n...") 43 frameworks := engine.WebMatch(httpResponse) 44 45 // 处理结果 46 for _, frame := range frameworks { 47 println("Found:", frame.Name) 48 } 49 } 50 ``` 51 52 ### Service 指纹识别 53 54 ```go 55 package main 56 57 import ( 58 "github.com/chainreactors/fingers/fingerprinthub_v4" 59 "github.com/chainreactors/fingers/common" 60 "time" 61 ) 62 63 func main() { 64 // 创建引擎 65 engine, _ := fingerprinthub_v4.NewFingerPrintHubV4Engine() 66 67 // 加载包含 network 请求的指纹模板 68 engine.LoadFromFS(os.DirFS("path/to/fingerprints"), "*.yaml") 69 70 // 创建 ServiceSender 71 sender := common.NewServiceSender(5 * time.Second) 72 73 // 定义回调函数处理匹配结果 74 callback := func(result *common.ServiceResult) { 75 println("Found:", result.Framework.Name) 76 } 77 78 // 执行 Service 匹配 79 engine.ServiceMatch("192.168.1.1", "3306", 0, sender, callback) 80 } 81 ``` 82 83 ## 测试 84 85 ### 运行所有测试 86 87 ```bash 88 go test -v 89 ``` 90 91 ## 文件结构 92 93 ``` 94 fingerprinthub_v4/ 95 ├── fingerprinthub_v4.go # 核心引擎实现 96 ├── fingerprinthub_v4_test.go # 单元测试 97 ├── service_test.go # Service 匹配测试 98 └── README.md # 本文档 99 100 resources/ 101 └── fingerprinthub_v4.py # YAML 合并工��(用于性能测试) 102 ``` 103 104 ## Favicon Matcher 支持 105 106 本引擎完全支持 favicon matcher,包括: 107 - MD5 hash 匹配 108 - MMH3 hash 匹配(兼容 observer_ward) 109 - OR/AND 条件 110 - Match-all 模式 111 112 示例模板: 113 114 ```yaml 115 id: example-favicon 116 info: 117 name: Example Favicon Detection 118 metadata: 119 vendor: example 120 product: example_app 121 122 http: 123 - method: GET 124 path: 125 - "{{BaseURL}}/favicon.ico" 126 matchers: 127 - type: favicon 128 hash: 129 - "d41d8cd98f00b204e9800998ecf8427e" # MD5 130 - "1165838194" # MMH3 131 ``` 132 133 ## Network 指纹支持 134 135 本引擎完全支持 neutron network 协议,可以识别 TCP/UDP/TLS 服务指纹。 136 137 ### tcp/udp 字段兼容性 138 139 **重要**: FingerprintHub 的 `service-fingerprint` 目录使用 `tcp` 和 `udp` 字段,本引擎会自动将其转换为 neutron 的 `network` 字段格式,完全兼容! 140 141 ```yaml 142 # FingerprintHub 格式(tcp 字段) 143 tcp: 144 - inputs: 145 - data: "\r\n\r\n" 146 read: 1024 147 host: 148 - "{{Hostname}}" 149 matchers: 150 - type: word 151 words: 152 - "SFATAL" 153 154 # 自动转换为 neutron 格式(network 字段) 155 network: 156 - inputs: 157 - data: "\r\n\r\n" 158 read: 1024 159 host: 160 - "{{Hostname}}" 161 matchers: 162 - type: word 163 words: 164 - "SFATAL" 165 ``` 166 167 ### Network 指纹模板示例 168 169 ```yaml 170 id: mysql-detect 171 info: 172 name: MySQL Service Detection 173 author: chainreactors 174 severity: info 175 metadata: 176 vendor: oracle 177 product: mysql 178 179 network: 180 - inputs: 181 - data: "\x00" 182 read: 1024 183 184 host: 185 - "{{Hostname}}:3306" 186 187 matchers: 188 - type: word 189 words: 190 - "mysql_native_password" 191 - "caching_sha2_password" 192 condition: or 193 ``` 194 195 ### 支持的 Network 特性 196 197 - ✅ TCP/UDP/TLS 协议 198 - ✅ **tcp/udp 字段自动转换**(完全兼容 FingerprintHub) 199 - ✅ 自定义发送数据(hex/text) 200 - ✅ 多轮交互(multiple inputs) 201 - ✅ 灵活的 matchers(word/regex/binary/size) 202 - ✅ DSL 支持 203 - ✅ Extractors 支持 204 205 ### CPE 信息支持 206 207 Framework 自动从模板的 `metadata` 中提取 CPE 信息: 208 209 ```yaml 210 info: 211 metadata: 212 vendor: oracle # 自动映射到 Framework.Attributes.Vendor 213 product: mysql # 自动映射到 Framework.Attributes.Product 214 ``` 215 216 这样生成的 Framework 包含完整的 CPE 信息,便于后续的漏洞匹配和资产管理。 217 218 ## 性能测试 219 220 如果需要测试完整的 FingerprintHub 数据库性能: 221 222 1. 使用工具脚本合并 YAML 文件: 223 224 ```bash 225 python ../resources/fingerprinthub_v4.py \ 226 /path/to/FingerprintHub/web-fingerprint \ 227 fingerprints.json 228 ``` 229 230 2. 在你的测试代码中加载并测试: 231 232 ```go 233 // 加载合并的指纹 234 engine, _ := fingerprinthub_v4.NewFingerPrintHubV4Engine() 235 // ... 加载 JSON 并转换为模板 236 // ... 执行性能测试 237 ``` 238 239 ## 兼容性 240 241 - ✅ 完全兼容 FingerprintHub v4 模板格式 242 - ✅ **完全兼容 tcp/udp 字段**(自动转换为 network) 243 - ✅ 兼容 observer_ward favicon hash 算法 244 - ✅ 支持 neutron 所有 matcher 类型 245 - ✅ 支持 neutron network 协议(TCP/UDP/TLS) 246 - ✅ Go 1.16+ (需要 embed 支持) 247 248 ## 相关项目 249 250 - [neutron](https://github.com/chainreactors/neutron) - Nuclei 模板引擎 Go 实现 251 - [FingerprintHub](https://github.com/0x727/FingerprintHub) - 指纹数据库 252 - [observer_ward](https://github.com/0x727/ObserverWard) - Web 指纹识别工具 253 254 ## License 255 256 根据主项目 fingers 的 License 使用。