Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
recog — 针对主机、服务和内容的模式识别 | Kitploit
工具/GitHubGitHub/rapid7/recog
OSINT (开源情报)侦察网络映射漏洞分析信息收集Web安全实用工具与框架
GitHubrapid7/recog

recog

针对主机、服务和内容的模式识别

查看仓库
7882134815天前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
# Recog:一个识别框架

[![CI Workflow](https://github.com/rapid7/recog/actions/workflows/ci.yml/badge.svg)](https://github.com/rapid7/recog/actions/workflows/ci.yml)
[![Verify Workflow](https://github.com/rapid7/recog/actions/workflows/verify.yml/badge.svg)](https://github.com/rapid7/recog/actions/workflows/verify.yml)

Recog 是一个通过将指纹与各种网络探测返回的数据进行匹配来识别产品、服务、操作系统和硬件的框架。Recog 让从 Web 服务器横幅、snmp 系统描述字段以及更多数据中提取有用信息变得简单。

Recog 是开源的,更多信息请参阅 [LICENSE](https://github.com/rapid7/recog/blob/main/LICENSE) 文件。

## 目录

1. [仓库拆分](#repository-split)
    1. [默认分支重命名](#default-branch-rename)
1. [Recog 库语言实现](#recog-library-language-implementations)
    1. [功能对等](#feature-parity)
1. [安装](#installation)
1. [成熟度](#maturity)
1. [指纹](#fingerprints)
1. [测试匹配](#testing-matches)
    1. [ftp_banners](#ftp_banners)
    1. [http_cookies](#http_cookies)
    1. [http_servers](#http_servers)
    1. [favicons](#favicons)
    1. [http_wwwauth](#http_wwwauth)
    1. [tls_jarm](#tls_jarm)
1. [贡献](#contributing)

## 仓库拆分

2022 年 3 月 31 日,Recog 内容——XML 指纹文件和实用工具——已从 Recog 框架库实现中拆分出来。原 [Recog](https://github.com/rapid7/recog) 仓库现在包含 Recog 内容,[Recog-Ruby](https://github.com/rapid7/recog-ruby) 仓库包含 Ruby 语言实现。Recog 内容作为 git 子模块包含在 Recog-Ruby 中,并嵌套在 `recog` 目录下。拆分后的所有版本号大于或等于 3.0.0 的 Recog gem 将:1. 在 `recog` 目录下包含 XML 指纹目录,并且 2. 只包含 `recog_match` 工具,因为其他工具专注于指纹管理。

[^返回顶部](#recog-a-recognition-framework)

### 默认分支重命名

与仓库拆分同步,默认分支已从 `master` 重命名为 `main`。在这些更改之前创建的任何克隆都必须在你的本地环境中手动更新。如果你有 fork,请导航到你的 fork 的设置,并按照[重命名分支](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch)中的说明将默认分支更改为 `main`。

```
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
```

(可选)运行以下命令以删除对旧分支名的跟踪引用。
```
# dry-run to confirm stale references that will be deleted before proceeding
git remote prune origin --dry-run
git remote prune origin
```

如果你之前使用的是上游跟踪分支 `upstream-master`,请运行以下命令以删除旧分支并创建新的上游跟踪分支。
```
git branch -d upstream-master
git checkout -b upstream-main --track upstream/main
```

(可选)运行以下命令以删除对旧上游分支名的跟踪引用。
```
# dry-run to confirm stale references that will be deleted before proceeding
git remote prune upstream --dry-run
git remote prune upstream
```

[^返回顶部](#recog-a-recognition-framework)

## Recog 库语言实现

* Ruby: [rapid7/recog-ruby](https://github.com/rapid7/recog-ruby)
* Java: [rapid7/recog-java](https://github.com/rapid7/recog-java)
* Go: [runZeroInc/recog-go](https://github.com/runZeroInc/recog-go)

[^返回顶部](#recog-a-recognition-framework)

### 功能对等

| 功能 :sparkles:                             | rapid7/recog-ruby  | rapid7/recog-java  | runZeroInc/recog-go |
|---------------------------------------------|:------------------:|:------------------:|:-------------------:|
| 指纹验证 CLI 工具                           | :white_check_mark: | :white_check_mark: | :white_check_mark:  |
| 指纹匹配 CLI 工具                           | :white_check_mark: |                    | :white_check_mark:  |
| 支持 base64 编码的示例                      | :white_check_mark: | :white_check_mark: | :white_check_mark:  |
| 支持基于文件系统的外部示例                  | :white_check_mark: | :white_check_mark: | :white_check_mark:  |
| 指纹匹配 CPE 参数插值                       | :white_check_mark: | :white_check_mark: | :white_check_mark:  |

[^返回顶部](#recog-a-recognition-framework)

## 安装

Recog 由 XML 指纹文件和一组代码(主要使用 Ruby 编写)组成,这些代码使开发、测试和使用所包含的指纹变得容易。为了使用附带的 Ruby 代码,需要较新版本的 Ruby(2.31+),以及 Rubygems 和 `bundler` gem。一旦这些依赖就绪,请使用以下命令获取最新源代码并安装任何其他依赖。

```shell
$ git clone [email protected]:rapid7/recog.git
$ cd recog
$ bundle install
```

[^返回顶部](#recog-a-recognition-framework)

## 成熟度

请注意,虽然 XML 指纹本身相当稳定且经过充分测试,但 Ruby 代码库仍然比较新,并且可能快速变化。在任何生产项目中使用 Recog 代码之前,请先联系我们(research[at]rapid7.com)。

[^返回顶部](#recog-a-recognition-framework)

## 指纹

Recog 中的指纹存储在 XML 文件中,每个文件都旨在匹配特定的协议响应字符串或字段。例如,文件 [ssh_banners.xml](https://github.com/rapid7/recog/blob/main/xml/ssh_banners.xml) 可以通过匹配初始 SSH 守护进程横幅字符串来确定操作系统、供应商,有时还有硬件产品。

一个指纹文件由如下所示的 XML 文档组成:

```xml
<fingerprints matches="ssh.banner">
  <fingerprint pattern="^RomSShell_([\d\.]+)$">
    <description>Allegro RomSShell SSH</description>
    <example service.version="4.62">RomSShell_4.62</example>
    <param pos="0" name="service.vendor" value="Allegro"/>
    <param pos="0" name="service.product" value="RomSShell"/>
    <param pos="1" name="service.version"/>
  </fingerprint>
</fingerprints>
```

第一行应始终是 XML 版本声明。第一个元素应始终是一个 `fingerprints` 块,并带有 `matches` 属性,指示此指纹文件应该匹配的数据。`matches` 属性通常采用 `protocol.field` 的形式。

在 `fingerprints` 元素内部,应有一个或多个 `fingerprint` 元素。每个 `fingerprint` 都必须包含一个 `pattern` 属性,该属性包含用于匹配数据的正则表达式。可以指定可选的 `flags` 属性,以控制正则表达式的解释方式。更多信息请参阅 [Recog 的 `FLAG_MAP` 文档](http://www.rubydoc.info/gems/recog/Recog/Fingerprint/RegexpFactory#FLAG_MAP-constant)。

在指纹内部,`description` 元素应包含一个人类可读的字符串,用于描述该指纹。

至少应存在一个 `example` 元素,但最好使用多个 `example` 元素。这些元素用作 `rspec` 中测试覆盖的一部分,用于验证提供的数据与指定的正则表达式匹配。此外,如果指纹使用 `param` 元素从数据中提取字段值(将在下面描述),则可以将这些预期提取结果添加为 `example` 元素的属性。在上面的示例中,这个:

```xml
<example service.version="4.62">RomSShell_4.62</example>
```

用于测试 `RomSShell_4.62` 是否与提供的正则表达式匹配,以及 `service.version` 的值是否为 4.62。

`example` 字符串可以进行 base64 编码,以允许使用不可打印字符。为了向 Recog 发出此信号,需要向 `example` 元素添加一个值为 `base64` 的 `_encoding` 属性。超过 80 个字符的 Base64 编码文本可以像下面这样用换行符换行,以提高可读性。

```xml
<example _encoding="base64">
  dGllczGEAAAAlQQWMS4yLjg0MC4xMTM1NTYuMS40LjgwMAQuZGF0YS5yZW1vdmVkLjCEAAAAK
  AQdZG9tYWluQ29udHJvbGxlckZ1bmN0aW9uYWxpdHkxhAAAAAMEATc=
</example>
```

此外,示例可以放置在与 XML 文件位于同一目录下的、与 XML 文件同名的目录中:

```
xml/services.xml
xml/services/file1
xml/services/file2
...
```

然后可以使用 `_filename` 属性加载它们:

```xml
<example _filename="file1"/>
```

这对于长示例很有用。

`param` 元素包含一个 `pos` 属性,该属性指示应从 `pattern` 中提取哪个捕获字段;对于静态字符串,则为 `0`。`name` 属性是成功匹配时报告的键;`value` 在 `pos` 值为 `0` 时是静态字符串,否则被省略并从捕获的字段中获取。

`value` 属性支持来自其他字段的数据插值。这在通过正则表达式捕获 `hw.product` 的值并在 `os.product` 中重用它时通常很有用。

以下是来自 `http_servers.xml` 的示例,其中 `hw.product` 被捕获并重用。

```xml
  <fingerprint pattern="^Eltex (TAU-\d+[A-Z]*(?:\.IP)?)$">
    <description>Eltex TAU model VoIP gateway</description>
    <example hw.product="TAU-72">Eltex TAU-72</example>
    <example hw.product="TAU-1.IP">Eltex TAU-1.IP</example>
    <param pos="0" name="os.vendor" value="Eltex"/>
    <param pos="0" name="os.product" value="{hw.product} Firmware"/>
    <param pos="0" name="os.device" value="VoIP Gateway"/>
    <param pos="0" name="hw.vendor" value="Eltex"/>
    <param pos="1" name="hw.product"/>
    <param pos="0" name="hw.device" value="VoIP Gateway"/>
  </fingerprint>
```

对于名称以 `_tmp.` 开头的临时属性,有特殊的处理。这些属性可用于插值,但不会在输出中发出。当某个产品名称在各种横幅、供应商营销中不一致,或者在尝试生成 CPE 时与 NIST 值不一致,此功能很有用。在这些情况下,可以提取横幅中有用的部分,并构造一个新值,而不会使匹配所发出的数据变得混乱。

```xml
<fingerprint pattern="^foo baz switchThing-(\d{4})$">
  <description>NetCorp NX series switches</description>
  <example hw.product="NX8200">foo baz switchThing-8200</example>
  <param pos="0" name="hw.vendor" value="NetCorp"/>
  <param pos="0" name="hw.product" value="NX{_tmp.001}"/>
  <param pos="2" name="_tmp.001"/>
</fingerprint>
```

这些临时属性不会在 `identifiers/fields.txt` 中被跟踪。

[^返回顶部](#recog-a-recognition-framework)

### 测试匹配

以下示例使用 `bin/recog_match`,这是一个简单的 Ruby 命令行工具,使用 Recog 的指纹数据。在运行 Recog 之前通常需要进行预处理,例如提取 HTTP 标头值等。所有指纹数据都可以在 `xml/*.xml` 中找到。

#### ftp_banners

根据连接后服务器的横幅响应来对 FTP 服务器进行指纹识别:

```
# Example plaintext input
echo -n '220 Microsoft FTP Service' | bin/recog_match xml/ftp_banners.xml -

# Example command using nmap
nmap -sV -script=banner -p 21 192.168.123.13 | grep --color=never '_banner' | cut -d: -f2- | bin/recog_match xml/ftp_banners.xml -

# Example output
MATCH: {"matched"=>"Microsoft FTP Server on Windows XP, 2003 or later without version", "service.vendor"=>"Microsoft", "service.product"=>"IIS", "service.family"=>"IIS", "service.cpe23"=>"cpe:/a:microsoft:iis:-", "os.vendor"=>"Microsoft", "os.family"=>"Windows", "os.product"=>"Windows", "os.cpe23"=>"cpe:/o:microsoft:windows:-", "host.name"=>"220", "service.protocol"=>"ftp", "fingerprint_db"=>"ftp.banner", "data"=>"220 Microsoft FTP Service"}
```

#### http_cookies

使用 HTTP `Set-Cookie` 标头值对 HTTP 服务器进行指纹识别:

```
# Example plaintext input
echo 'laravel_session=eyJ...etc..etc...%3D; expires=Mon, 13-Mar-2023 16:48:58 GMT; Max-Age=7200; path=/; httponly; samesite=lax' | bin/recog_match xml/http_cookies.xml -

# Example cURL command
curl --silent -I http://localhost:9001 | grep --color=never -i '^Set-Cookie:' | cut -d: -f2- | bin/recog_match xml/http_cookies.xml -

# Example output
MATCH: {"matched"=>"Laravel PHP web application framework", "service.vendor"=>"Laravel", "service.product"=>"Laravel", "service.cpe23"=>"cpe:/a:laravel:laravel:-", "service.protocol"=>"http", "fingerprint_db"=>"http_header.cookie", "data"=>"laravel_session=eyJ...etc..etc...%3D; expires=Mon, 13-Mar-2023 16:48:58 GMT; Max-Age=7200; path=/; httponly; samesite=lax"}
```

#### http_servers

使用 HTTP `Server` 标头值对 HTTP 服务器进行指纹识别:

```
# Example plaintext input
echo -n 'Apache/2.4.38 (Debian)' | bin/recog_match xml/http_servers.xml -

# Example cURL command
curl --silent -I http://localhost:9001 | grep --color=never -i '^Server:' | cut -d: -f2- | bin/recog_match xml/http_servers.xml -

# Example output
MATCH: {"matched"=>"Apache", "service.vendor"=>"Apache", "service.product"=>"HTTPD", "service.family"=>"Apache", "service.version"=>"2.4.38", "service.cpe23"=>"cpe:/a:apache:http_server:2.4.38", "apache.info"=>"(Debian)", "service.protocol"=>"http", "fingerprint_db"=>"http_header.server", "data"=>"Apache/2.4.38 (Debian)"}
```

#### favicons

使用 favicon 的 md5sum 来识别正在运行的服务:

```
# Example plaintext input
echo -n fe22dd2bb09daccf58256611ac491469 | bin/recog_match xml/favicons.xml -

# Example cURL command
curl --silent http://localhost:8000/favicon.ico | md5sum | awk '{ print $1 }' | bin/recog_match xml/favicons.xml -

# Example output
MATCH: {"matched"=>"Drupal CMS", "service.vendor"=>"Drupal", "service.product"=>"CMS", "service.certainty"=>"0.5", "service.cpe23"=>"cpe:/a:drupal:drupal:-", "service.protocol"=>"", "fingerprint_db"=>"favicon.md5", "data"=>"fe22dd2bb09daccf58256611ac491469"}
```

#### http_wwwauth

使用 HTTP `WWW-Authenticate` 标头值对 HTTP 服务器进行指纹识别:

```
# Example plaintext input
echo -n 'Basic realm="monit"' | bin/recog_match xml/http_wwwauth.xml -

# Example cURL command
curl --silent -I http://localhost:9001 | grep --color=never -i '^WWW-Authenticate:' | cut -d: -f2- | bin/recog_match xml/http_wwwauth.xml -

# Example output
MATCH: {"matched"=>"Minot", "service.vendor"=>"Tildeslash", "service.product"=>"Monit", "service.cpe23"=>"cpe:/a:tildeslash:monit:-", "service.protocol"=>"http", "fingerprint_db"=>"http_header.wwwauth", "data"=>"Basic realm=\"monit\""}
```

#### tls_jarm

根据服务器对 10 个 TLS Client Hello 数据包的响应来对 TLS 服务器进行指纹识别。指纹识别基于 https://github.com/salesforce/jarm

```
# Example plaintext input
echo -n 07d14d16d21d21d07c42d43d000000f50d155305214cf247147c43c0f1a823 | bin/recog_match xml/jarm.xml -

# Example command using Salesforce's JARM against a running Metasploit listener
python3 $code/jarm/jarm.py -p 8443 192.168.123.1 | grep --color=never 'JARM: ' | awk -F: '{ print $2 }' | bin/recog_match xml/tls_jarm.xml -

# Example output
MATCH: {"matched"=>"Metasploit listener", "service.vendor"=>"Rapid7", "service.product"=>"Metasploit", "service.cpe23"=>"cpe:/a:rapid7:metasploit:-", "service.protocol"=>"tls", "fingerprint_db"=>"tls.jarm", "data"=>"07d14d16d21d21d07c42d43d000000f50d155305214cf247147c43c0f1a823"}
```

## 贡献

Recog 的用户和维护者非常感谢您能对项目做出的任何贡献。有关指南和说明,请参阅 [CONTRIBUTING.MD](https://github.com/rapid7/recog/blob/main/CONTRIBUTING.md)

[^返回顶部](#recog-a-recognition-framework)
下载工具