{"id":20445874,"url":"https://github.com/rapid7/recog-ruby","last_synced_at":"2025-10-13T05:34:48.362Z","repository":{"id":40791589,"uuid":"436680870","full_name":"rapid7/recog-ruby","owner":"rapid7","description":"Recog-Ruby: Pattern Recognition using Rapid7 Recog","archived":false,"fork":false,"pushed_at":"2024-09-23T14:08:28.000Z","size":5759,"stargazers_count":5,"open_issues_count":1,"forks_count":9,"subscribers_count":39,"default_branch":"main","last_synced_at":"2024-12-18T06:23:48.154Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapid7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-09T16:13:28.000Z","updated_at":"2024-09-23T14:08:32.000Z","dependencies_parsed_at":"2023-01-22T00:46:45.450Z","dependency_job_id":"f4679957-66bf-4b3a-98fb-5b92be80adaa","html_url":"https://github.com/rapid7/recog-ruby","commit_stats":{"total_commits":1496,"total_committers":62,"mean_commits":"24.129032258064516","dds":0.5574866310160428,"last_synced_commit":"bba476d8bdec7e728219fec98891c30f2380aadb"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Frecog-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Frecog-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Frecog-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Frecog-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapid7","download_url":"https://codeload.github.com/rapid7/recog-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244637098,"owners_count":20485446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:15:10.436Z","updated_at":"2025-10-13T05:34:43.328Z","avatar_url":"https://github.com/rapid7.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Recog-Ruby: A Recognition Framework\n\n[![Gem Version](https://badge.fury.io/rb/recog.svg)](http://badge.fury.io/rb/recog)\n[![CI Workflow](https://github.com/rapid7/recog-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/rapid7/recog-ruby/actions/workflows/ci.yml)\n\n\nRecog is a framework for identifying products, services, operating systems, and hardware by matching fingerprints against data returned from various network probes. Recog makes it simple to extract useful information from web server banners, SNMP system description fields, and a whole lot more.\n\nThe Recog-Ruby repository contains the Ruby language implementation of the Recog recognition framework library and the [Recog](https://github.com/rapid7/recog) content, XML fingerprint files, as a git submodule. That makes it easy to develop, test, and use the contained fingerprints.\n\nRecog-Ruby is open source, please see the [LICENSE](LICENSE) file for more information.\n\n## Table of Contents\n\n1. [Repository split](#repository-split)\n1. [Installation](#installation)\n1. [Maturity](#maturity)\n1. [Fingerprints](#fingerprints)\n1. [Contributing](#contributing)\n\n## Repository split\n\nOn March 31, 2022, the Recog content - XML fingerprint files and utilities - were split from the Recog framework library implementation. The original [Recog](https://github.com/rapid7/recog) repository now contains the Recog content and the [Recog-Ruby](https://github.com/rapid7/recog-ruby) repository contains the Ruby language implementation. The Recog content is included in Recog-Ruby as a git submodule and is nested under the `recog` directory. All post-split Recog gem versions equal or greater than 3.0.0 will: 1. contain the XML fingerprint directory under the `recog` directory, and 2. only include the `recog_match` tool since the other tools are focused on fingerprint management.\n\n[^back to top](#recog-ruby-a-recognition-framework)\n\n## Installation\n\nIn order to use the included Ruby code, a recent version of Ruby (2.31+) is required, along with Rubygems and the `bundler` gem. Once these dependencies are in place, use the following commands to grab the latest source code and install any additional dependencies.\n\n```shell\n$ git clone --recurse-submodules git@github.com:rapid7/recog-ruby.git\n$ cd recog-ruby\n$ bundle install\n```\n\n[^back to top](#recog-ruby-a-recognition-framework)\n\n## Maturity\n\nPlease note that while the XML fingerprints themselves are quite stable and well-tested, the Ruby codebase is still fairly new and subject to change quickly. Please contact us (research[at]rapid7.com) before leveraging the Recog code within any production projects.\n\n[^back to top](#recog-ruby-a-recognition-framework)\n\n## Fingerprints\n\nThe fingerprints within [Recog](https://github.com/rapid7/recog) are stored in XML files, each of which is designed to match a specific protocol response string or field. For example, the file [ssh_banners.xml](https://github.com/rapid7/recog/blob/master/xml/ssh_banners.xml) can determine the os, vendor, and sometimes hardware product by matching the initial SSH daemon banner string.\n\nA fingerprint file consists of an XML document like the following:\n\n```xml\n\u003cfingerprints matches=\"ssh.banner\"\u003e\n  \u003cfingerprint pattern=\"^RomSShell_([\\d\\.]+)$\"\u003e\n    \u003cdescription\u003eAllegro RomSShell SSH\u003c/description\u003e\n    \u003cexample service.version=\"4.62\"\u003eRomSShell_4.62\u003c/example\u003e\n    \u003cparam pos=\"0\" name=\"service.vendor\" value=\"Allegro\"/\u003e\n    \u003cparam pos=\"0\" name=\"service.product\" value=\"RomSShell\"/\u003e\n    \u003cparam pos=\"1\" name=\"service.version\"/\u003e\n  \u003c/fingerprint\u003e\n\u003c/fingerprints\u003e\n```\n\nThe first line should always consist of the XML version declaration. The first element should always be a `fingerprints` block with a `matches` attribute indicating what data this fingerprint file is supposed to match. The `matches` attribute is normally in the form of `protocol.field`.\n\nInside of the `fingerprints` element there should be one or more `fingerprint` elements. Every `fingerprint` must contain a `pattern` attribute, which contains the regular expression to be used to match against the data.  An optional `flags` attribute can be specified to control how the regular expression is to be interpreted.  See [the Recog documentation for `FLAG_MAP`](http://www.rubydoc.info/gems/recog/Recog/Fingerprint/RegexpFactory#FLAG_MAP-constant) for more information.\n\nInside of the fingerprint, a `description` element should contain a human-readable string describing this fingerprint.\n\nAt least one `example` element should be present, however multiple `example` elements are preferred.  These elements are used as part of the test coverage present in `rspec` which validates that the provided data matches the specified regular expression.  Additionally, if the fingerprint is using the `param` elements to extract field values from the data (described next), you can add these expected extractions as attributes for the `example` elements.  In the example above, this:\n\n```xml\n\u003cexample service.version=\"4.62\"\u003eRomSShell_4.62\u003c/example\u003e\n```\n\ntests that `RomSShell_4.62` matches the provided regular expression and that the value of `service.version` is 4.62.\n\nThe `example` string can be base64 encoded to permit the use of unprintable characters.  To signal this to Recog an `_encoding` attribute with the value of `base64` is added to the `example` element.  Based64 encoded text that is longer than 80 characters may be wrapped with newlines as shown below to aid in readability.\n\n```xml\n\u003cexample _encoding=\"base64\"\u003e\n  dGllczGEAAAAlQQWMS4yLjg0MC4xMTM1NTYuMS40LjgwMAQuZGF0YS5yZW1vdmVkLjCEAAAAK\n  AQdZG9tYWluQ29udHJvbGxlckZ1bmN0aW9uYWxpdHkxhAAAAAMEATc=\n\u003c/example\u003e\n```\n\nAdditionally, examples can be placed in a directory with the same base name as the XML file, in the same directory as the XML file:\n\n```\nxml/services.xml\nxml/services/file1\nxml/services/file2\n...\n```\n\nThey can then be loaded using the `_filename` attribute:\n\n```xml\n\u003cexample _filename=\"file1\"/\u003e\n```\n\nThis is useful for long examples.\n\nThe `param` elements contain a `pos` attribute, which indicates what capture field\nfrom the `pattern` should be extracted, or `0` for a static string. The `name` attribute\nis the key that will be reported in the case of a successful match and the `value`\nwill either be a static string for `pos` values of `0` or missing and taken from the\ncaptured field.\n\nThe `value` attribute supports interpolation of data from other fields. This is\noften useful when capturing the value for `hw.product` via regex and re-using this\nvalue in `os.product`.\n\nHere is an example from`http_servers.xml` where `hw.product` is captured and reused.\n\n```xml\n  \u003cfingerprint pattern=\"^Eltex (TAU-\\d+[A-Z]*(?:\\.IP)?)$\"\u003e\n    \u003cdescription\u003eEltex TAU model VoIP gateway\u003c/description\u003e\n    \u003cexample hw.product=\"TAU-72\"\u003eEltex TAU-72\u003c/example\u003e\n    \u003cexample hw.product=\"TAU-1.IP\"\u003eEltex TAU-1.IP\u003c/example\u003e\n    \u003cparam pos=\"0\" name=\"os.vendor\" value=\"Eltex\"/\u003e\n    \u003cparam pos=\"0\" name=\"os.product\" value=\"{hw.product} Firmware\"/\u003e\n    \u003cparam pos=\"0\" name=\"os.device\" value=\"VoIP Gateway\"/\u003e\n    \u003cparam pos=\"0\" name=\"hw.vendor\" value=\"Eltex\"/\u003e\n    \u003cparam pos=\"1\" name=\"hw.product\"/\u003e\n    \u003cparam pos=\"0\" name=\"hw.device\" value=\"VoIP Gateway\"/\u003e\n  \u003c/fingerprint\u003e\n```\n\nThere is special handling for temporary attributes that have a name starting with\n`_tmp.`. These attributes can be used for interpolation but are not emitted in the\noutput. This is useful when a particular product name is inconsistent in various\nbanners, vendor marketing, or with NIST values when trying to generate CPEs. In\nthese cases the useful parts of the banner can be extracted and a new value\ncrafted without cluttering the data emitted by a match.\n\n```xml\n\u003cfingerprint pattern=\"^foo baz switchThing-(\\d{4})$\"\u003e\n  \u003cdescription\u003eNetCorp NX series switches\u003c/description\u003e\n  \u003cexample hw.product=\"NX8200\"\u003efoo baz switchThing-8200\u003c/example\u003e\n  \u003cparam pos=\"0\" name=\"hw.vendor\" value=\"NetCorp\"/\u003e\n  \u003cparam pos=\"0\" name=\"hw.product\" value=\"NX{_tmp.001}\"/\u003e\n  \u003cparam pos=\"2\" name=\"_tmp.001\"/\u003e\n\u003c/fingerprint\u003e\n```\n\nThese temporary attributes are not tracked in the `identifiers/fields.txt`.\n\n[^back to top](#recog-ruby-a-recognition-framework)\n\n## Contributing\n\nThe users and maintainers of Recog-Ruby would greatly appreciate any contributions\nyou can make to the project. For guidelines and instructions please see\n[CONTRIBUTING.MD](CONTRIBUTING.md)\n\n[^back to top](#recog-ruby-a-recognition-framework)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Frecog-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapid7%2Frecog-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Frecog-ruby/lists"}