Skip to content

Repository files navigation

Banner

一个用 Go 编写的 Banner 指纹识别示例项目。项目提供 HTTP 服务端和命令行客户端,可以根据扫描到的服务 Banner 识别协议、产品、版本、操作系统线索和置信度。

功能

  • 支持批量识别扫描记录
  • 提供 HTTP API:POST /api/v1/identify
  • 提供健康检查接口:GET /healthz
  • 提供命令行客户端读取 JSON 输入并调用服务端
  • 支持 Docker 和 Docker Compose 运行
  • 当前内置识别:TLS、SSH、HTTP、MySQL、Redis、FTP,未识别时返回 Unknown

项目结构

.
├── cmd/
│   ├── client/          # CLI 客户端
│   └── server/          # HTTP 服务端
├── internal/
│   ├── api/             # HTTP 路由和接口处理
│   ├── fingerprint/     # 指纹识别逻辑
│   └── model/           # 请求和响应模型
├── examples/
│   └── input.json       # 示例输入
├── Dockerfile.client
├── Dockerfile.server
└── docker-compose.yml

快速开始

使用 Docker Compose

docker compose up --build

Compose 会启动服务端,并运行客户端读取 examples/input.json,然后输出识别结果。

本地运行服务端

go run ./cmd/server -addr :8080

健康检查:

curl http://localhost:8080/healthz

本地运行客户端

先启动服务端,然后执行:

go run ./cmd/client -input examples/input.json -server http://localhost:8080

API

POST /api/v1/identify

请求体是扫描记录数组:

[
  {
    "ip": "1.2.3.5",
    "port": 80,
    "banner": "HTTP/1.1 200 OK\r\nServer: nginx/1.24.0"
  }
]

响应体是识别结果数组:

[
  {
    "ip": "1.2.3.5",
    "port": 80,
    "protocol": "HTTP",
    "product": "nginx",
    "version": "1.24.0",
    "os_hint": "",
    "confidence": 0.9
  }
]

字段说明:

  • protocol:识别出的协议或服务类型
  • product:识别出的产品名称
  • version:识别出的版本号
  • os_hint:从 Banner 中推断出的操作系统线索
  • confidence:识别置信度,范围约为 01

测试

go test ./...

输入格式

客户端默认读取 /data/input.json,本地运行时可以通过 -input 指定路径:

go run ./cmd/client -input examples/input.json -server http://localhost:8080

输入文件应为 JSON 数组,每个元素包含:

  • ip:目标 IP
  • port:目标端口
  • banner:扫描到的原始 Banner 字符串

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages