recog-intrigue 2.3.7 → 2.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/SECURITY.md +35 -0
  3. data/.gitignore +9 -0
  4. data/CONTRIBUTING.md +136 -37
  5. data/README.md +18 -16
  6. data/bin/recog_cleanup +16 -0
  7. data/bin/recog_standardize +30 -6
  8. data/cpe-remap.yaml +38 -1
  9. data/identifiers/README.md +9 -0
  10. data/identifiers/hw_device.txt +77 -0
  11. data/identifiers/hw_family.txt +96 -0
  12. data/identifiers/hw_product.txt +328 -0
  13. data/identifiers/os_architecture.txt +6 -6
  14. data/identifiers/os_device.txt +45 -3
  15. data/identifiers/os_family.txt +206 -41
  16. data/identifiers/os_product.txt +238 -17
  17. data/identifiers/service_family.txt +144 -57
  18. data/identifiers/service_product.txt +385 -83
  19. data/identifiers/vendor.txt +554 -68
  20. data/lib/recog/version.rb +1 -1
  21. data/requirements.txt +1 -1
  22. data/update_cpes.py +4 -1
  23. data/xml/apache_modules.xml +292 -5
  24. data/xml/apache_os.xml +41 -2
  25. data/xml/architecture.xml +11 -3
  26. data/xml/dns_versionbind.xml +200 -26
  27. data/xml/favicons.xml +1701 -0
  28. data/xml/ftp_banners.xml +256 -23
  29. data/xml/h323_callresp.xml +112 -12
  30. data/xml/hp_pjl_id.xml +47 -5
  31. data/xml/html_title.xml +1156 -70
  32. data/xml/http_cookies.xml +69 -11
  33. data/xml/http_servers.xml +1094 -107
  34. data/xml/http_wwwauth.xml +143 -27
  35. data/xml/imap_banners.xml +62 -13
  36. data/xml/ldap_searchresult.xml +81 -9
  37. data/xml/mdns_device-info_txt.xml +194 -17
  38. data/xml/mdns_workstation_txt.xml +4 -2
  39. data/xml/mysql_banners.xml +233 -40
  40. data/xml/mysql_error.xml +113 -6
  41. data/xml/nntp_banners.xml +10 -2
  42. data/xml/ntp_banners.xml +93 -9
  43. data/xml/operating_system.xml +90 -3
  44. data/xml/pop_banners.xml +87 -33
  45. data/xml/rsh_resp.xml +11 -2
  46. data/xml/rtsp_servers.xml +43 -23
  47. data/xml/sip_banners.xml +6 -11
  48. data/xml/sip_user_agents.xml +29 -2
  49. data/xml/smb_native_lm.xml +10 -2
  50. data/xml/smb_native_os.xml +80 -2
  51. data/xml/smtp_banners.xml +233 -13
  52. data/xml/smtp_debug.xml +6 -4
  53. data/xml/smtp_ehlo.xml +7 -5
  54. data/xml/smtp_expn.xml +13 -4
  55. data/xml/smtp_help.xml +23 -4
  56. data/xml/smtp_mailfrom.xml +5 -2
  57. data/xml/smtp_noop.xml +6 -5
  58. data/xml/smtp_quit.xml +5 -4
  59. data/xml/smtp_rcptto.xml +5 -2
  60. data/xml/smtp_rset.xml +4 -4
  61. data/xml/smtp_turn.xml +4 -4
  62. data/xml/smtp_vrfy.xml +14 -4
  63. data/xml/snmp_sysdescr.xml +741 -32
  64. data/xml/snmp_sysobjid.xml +47 -2
  65. data/xml/ssh_banners.xml +255 -81
  66. data/xml/telnet_banners.xml +503 -30
  67. data/xml/x11_banners.xml +26 -3
  68. data/xml/x509_issuers.xml +37 -13
  69. data/xml/x509_subjects.xml +214 -52
  70. metadata +12 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ce6e9357161c0d9ccd4a78a1b29c32ad316d5ebdbc36d1c14c83e7642a4ee87
4
- data.tar.gz: 55a033985a85110154d9eb1fda16a4a860ee6f4490cb162ed8e5ed5bdb8d8c8f
3
+ metadata.gz: 58547f0ee3dd0397d724499e035f9549e9d8bcc4dd0fc656db8ffb270d66189d
4
+ data.tar.gz: 93215d90b016f8828d2ec8eb900ec9a757ca3d64ed6175227755765186a4c5bb
5
5
  SHA512:
6
- metadata.gz: 625729df058c4a85767187b2244edc45a6b7f038f5cd620d7f986adb62744479cf9a4592b827dae962158b32dab3cd97463d237b25425016d87263e596dad304
7
- data.tar.gz: ccfdfed40b6691f9477f29d311a1e41273a85cbb481693f4377ab0547ba0fed8ddf765d00c5a6348b9bef673205bf4afbdbc8a27b32fd25b01e82b11ff5a412c
6
+ metadata.gz: 81bc16e8cdf1aa637847548f66fed86793c55f1a6aa3d05940f12e5e8bdc6dfa50f8934738c37f4601737a72b305949b37e3d615118c8717c1c73bc258261c74
7
+ data.tar.gz: ad7213eda987963e0dbbd96867c98868ebe46a27b04a01cc1627dd11b70472b6c040b9c81da01ee26fa13200eb864bd525f0409de63ba79280792711b9c8a600
@@ -0,0 +1,35 @@
1
+ # Reporting security issues
2
+
3
+ Thanks for your interest in making Recog more secure! If you feel
4
+ that you have found a security issue involving Metasploit, Meterpreter,
5
+ Recog, or any other Rapid7 open source project, you are welcome to let
6
+ us know in the way that's most comfortable for you.
7
+
8
+ ## Via ZenDesk
9
+
10
+ You can click on the big blue button at [Rapid7's Vulnerability
11
+ Disclosure][r7-vulns] page, which will get you to our general
12
+ vulnerability reporting system. While this does require a (free) ZenDesk
13
+ account to use, you'll get regular updates on your issue as our software
14
+ support teams work through it. As it happens [that page][r7-vulns] also
15
+ will tell you what to expect when it comes to reporting vulns, how fast
16
+ we'll fix and respond, and all the rest, so it's a pretty good read
17
+ regardless.
18
+
19
+ ## Via email
20
+
21
+ If you're more of a traditionalist, you can email your finding to
22
+ security@rapid7.com. If you like, you can use our [PGP key][pgp] to
23
+ encrypt your messages, but we certainly don't mind cleartext reports
24
+ over email.
25
+
26
+ ## NOT via GitHub Issues
27
+
28
+ Please don't! Disclosing security vulnerabilities to public bug trackers
29
+ is kind of mean, even when it's well-intentioned, since you end up
30
+ dropping 0-day on pretty much everyone right out of the gate. We'd prefer
31
+ you didn't!
32
+
33
+ [r7-vulns]:https://www.rapid7.com/security/disclosure/
34
+ [pgp]:https://keybase.io/rapid7/pgp_keys.asc?fingerprint=9a90aea0576cbcafa39c502ba5e16807959d3eda
35
+
data/.gitignore CHANGED
@@ -6,9 +6,18 @@ pkg/
6
6
 
7
7
  /Gemfile.lock
8
8
 
9
+ #Python specific
10
+ venv
11
+
9
12
  # IDE specific
10
13
  .vscode/
11
14
  .idea
12
15
 
13
16
  # Misc
14
17
  **/.DS_Store
18
+
19
+ # CPE XML
20
+ official-cpe-dictionary*.xml
21
+
22
+ # CPE Remap Errors
23
+ errors.txt
@@ -3,9 +3,24 @@
3
3
  The users and maintainers of Recog would greatly appreciate any contributions
4
4
  you can make to the project. These contributions typically come in the form of
5
5
  filed bugs/issues or pull requests (PRs). These contributions routinely result
6
- in new versions of the [recog gem](https://rubygems.org/gems/recog) to be
6
+ in new versions of the [recog gem](https://rubygems.org/gems/recog) being
7
7
  released. The process for everything is described below.
8
8
 
9
+ ## Table of Contents
10
+
11
+ 1. [Contributing Issues / Bug Reports](#contributing-issues-/-bug-reports)
12
+ 1. [Contributing Code](#contributing-code)
13
+ 1. [Fork and Clone](#fork-and-clone)
14
+ 1. [Branch and Improve](#branch-and-improve)
15
+ 1. [Testing](#testing)
16
+ 1. [Fingerprints](#fingerprints)
17
+ 1. [Best Practices](#best-practices)
18
+ 1. [Fingerprint Testing](#fingerprint-testing)
19
+ 1. [Updating CPEs](#updating-cpes)
20
+ 1. [Project Operations](#project-operations)
21
+ 1. [Landing PRs](#landing-prs)
22
+ 1. [Releasing New Versions](#releasing-new-versions)
23
+
9
24
  ## Contributing Issues / Bug Reports
10
25
 
11
26
  If you encounter any bugs or problems with Recog, please file them
@@ -14,6 +29,8 @@ possible. If the bug is straight-forward enough and you understand the fix for
14
29
  the bug well enough, you may take the simpler, less-paperwork route and simply
15
30
  fill a PR with the fix and the necessary details.
16
31
 
32
+ [^back to top](#contributing-to-recog)
33
+
17
34
  ## Contributing Code
18
35
 
19
36
  Recog uses a model nearly identical to that of
@@ -26,33 +43,39 @@ this document.
26
43
 
27
44
  On the other hand, if you haven't, read on!
28
45
 
46
+ [^back to top](#contributing-to-recog)
47
+
29
48
  ### Fork and Clone
30
49
 
31
50
  Generally, this should only need to be done once, or if you need to start over.
32
51
 
33
52
  1. Fork Recog: Visit https://github.com/rapid7/recog and click Fork,
34
53
  selecting your github account if prompted
35
- 2. Clone ```git@github.com:<your-github-username>/recog.git```, replacing
36
- ```<your-github-username>``` with, you guessed it, your Github username.
37
- 3. Add the master Recog repository as your upstream:
38
-
39
- ```
40
- git remote add upstream git://github.com/rapid7/recog.git
41
- ```
42
- 4. Update your `.git/config` to ensure that the `remote ["upstream"]` section is configured to pull both branches and PRs from upstream. It should look something like the following, in particular the second `fetch` option:
54
+ 1. Clone `git@github.com:<your-github-username>/recog.git`, replacing
55
+ `<your-github-username>` with, you guessed it, your Github username.
56
+ 1. Add the master Recog repository as your upstream:
43
57
 
58
+ ```bash
59
+ git remote add upstream git://github.com/rapid7/recog.git
44
60
  ```
61
+
62
+ 1. Update your `.git/config` to ensure that the `remote ["upstream"]` section is configured to pull both branches and PRs from upstream. It should look something like the following, in particular the second `fetch` option:
63
+
64
+ ```bash
45
65
  [remote "upstream"]
46
66
  url = git@github.com:rapid7/recog.git
47
67
  fetch = +refs/heads/*:refs/remotes/upstream/*
48
68
  fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*
49
69
  ```
50
- 5. Fetch the latest revisions, including PRs:
51
70
 
52
- ```
71
+ 1. Fetch the latest revisions, including PRs:
72
+
73
+ ```bash
53
74
  git fetch --all
54
75
  ```
55
76
 
77
+ [^back to top](#contributing-to-recog)
78
+
56
79
  ### Branch and Improve
57
80
 
58
81
  If you have a contribution to make, first create a branch to contain your
@@ -60,7 +83,7 @@ work. The name is yours to choose, however generally it should roughly
60
83
  describe what you are doing. In this example, and from here on out, the
61
84
  branch will be FOO, but you should obviously change this:
62
85
 
63
- ```
86
+ ```bash
64
87
  git fetch --all
65
88
  git checkout master
66
89
  git rebase upstream/master
@@ -73,17 +96,66 @@ Please note that changes to [lib/recog/version.rb](https://github.com/rapid7/rec
73
96
 
74
97
  Now push your changes to your fork:
75
98
 
76
- ```
99
+ ```bash
77
100
  git push origin FOO
78
101
  ```
79
102
 
80
103
  Finally, submit the PR. Navigate to ```https://github.com/<your-github-username>/recog/compare/FOO```, fill in the details and submit.
81
104
 
105
+ [^back to top](#contributing-to-recog)
106
+
82
107
  ### Testing
83
108
 
84
109
  When your PR is submitted, it will be automatically subjected to the full run of tests in [Travis](https://travis-ci.org/rapid7/recog/), however you are encourage to perform testing _before_ submitting the PR. To do this, simply run `rake tests`.
85
110
 
86
- ## Updating CPEs
111
+ [^back to top](#contributing-to-recog)
112
+
113
+ ## Fingerprints
114
+
115
+ ### Best Practices
116
+
117
+ * Create a single fingerprint for each product as long as the pattern remains clear and readable. If that is not possible, the pattern should be logically decomposed into additional fingerprints.
118
+
119
+ * Create regular expressions that allow for flexible version number matching. This ensures greater probability of matching a product. For example, all known public releases of a product report either `major.minor` or `major.minor.build` format version numbers. If the fingerprint strictly matches this version number format, it would fail to match a modified build of the product that reports only a `major` version number format.
120
+
121
+ [^back to top](#contributing-to-recog)
122
+
123
+ ### Fingerprint Testing
124
+
125
+ Once a fingerprint has been added, the `example` entries can be tested by executing `bin/recog_verify` against the fingerprint file:
126
+
127
+ ```shell
128
+ bin/recog_verify xml/ssh_banners.xml
129
+ ```
130
+
131
+ Matches can be tested on the command-line in a similar fashion:
132
+
133
+ ```shell
134
+ $ echo 'OpenSSH_6.6p1 Ubuntu-2ubuntu1' | bin/recog_match xml/ssh_banners.xml -
135
+ MATCH: {"matched"=>"OpenSSH running on Ubuntu 14.04", "service.version"=>"6.6p1", "openssh.comment"=>"Ubuntu-2ubuntu1", "service.vendor"=>"OpenBSD", "service.family"=>"OpenSSH", "service.product"=>"OpenSSH", "os.vendor"=>"Ubuntu", "os.device"=>"General", "os.family"=>"Linux", "os.product"=>"Linux", "os.version"=>"14.04", "service.protocol"=>"ssh", "fingerprint_db"=>"ssh.banner", "data"=>"OpenSSH_6.6p1 Ubuntu-2ubuntu1"}
136
+ ```
137
+
138
+ [^back to top](#contributing-to-recog)
139
+
140
+
141
+ ### Standardizing Vendors, Products, and Services
142
+
143
+ Given the number of fingerprints in Recog, it can be common for specific products, vendors, or services to be identified with different spellings and casing.
144
+ To limit the creep of slightly-different-names, the `bin/recog_standardize` script can be used to extract all identifiers and merge them into the known lists.
145
+
146
+ To get started, run the `recog_standardize` tool:
147
+ ```shell
148
+ ruby bin/recog_standardize
149
+ ```
150
+
151
+ Review any new additions to the text files under `identifiers/`. If any of these names are close to an existing name, update the offending fingerprint to use
152
+ the existing name instead. Once the fingerprints are fixed, removed the "extra" names from the identifiers files, and run the tool again.
153
+
154
+
155
+ [^back to top](#contributing-to-recog)
156
+
157
+
158
+ ### Updating CPEs
87
159
 
88
160
  There exists some automation to update the CPEs that might be asserted with
89
161
  some recog fingerprints. This should be run periodically to ensure that all
@@ -91,30 +163,47 @@ fingerprints that could have CPEs do, etc.
91
163
 
92
164
  First, setup a python3 venv:
93
165
 
94
- ```
166
+ ```bash
95
167
  python3 -m venv venv
96
- source venv/bin/activate
168
+ source venv/{bin,Scripts}/activate
97
169
  pip install -r requirements.txt
98
170
  ```
99
171
 
100
172
  Download the latest CPE 2.3 dictionary:
101
173
 
102
- ```
103
- wget https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz
104
- ````
174
+ ```bash
175
+ curl -o official-cpe-dictionary_v2.3.xml.gz https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz && \
176
+ gunzip official-cpe-dictionary_v2.3.xml.gz
177
+ ```
105
178
 
106
- Run the CPE automation against every XML file, using GNU `parallel` to speed things up:
179
+ Run the CPE automation against every XML file:
107
180
 
108
- ```
109
- ls xml/*.xml | parallel --gnu "./update_cpes.py {} official-cpe-dictionary_v2.3.xml cpe-remap.yaml && xmllint --format --noblanks {} > {}.bak && mv {}.bak {} || echo {}" 2> errors.txt
110
- ```
181
+ ```bash
182
+ # Update the CPEs (sequentially)
183
+ ls xml/*.xml | xargs -i python update_cpes.py {} official-cpe-dictionary_v2.3.xml cpe-remap.yaml 2>>errors.txt
184
+ ```
185
+
186
+ You may want to use GNU `parallel` to speed things up:
187
+ ```bash
188
+ # Update the CPEs (with GNU Parallel)
189
+ ls xml/*.xml | parallel --gnu "python update_cpes.py {} official-cpe-dictionary_v2.3.xml cpe-remap.yaml" 2>>errors.txt
190
+ ```
191
+
192
+ Clean up the whitespace across all fingerprints:
193
+ ```bash
194
+ ruby bin/recog_cleanup
195
+ ```
111
196
 
112
197
  Any mismatched fingerprints will be listed in `errors.txt` for eventual
113
198
  maintenance. The `cpe-remap.yaml` file can be used to map between
114
199
  vendor/product/etc differences between Recog and CPE, or to work around bugs in
115
200
  either.
116
201
 
117
- ## Landing PRs
202
+ [^back to top](#contributing-to-recog)
203
+
204
+ ## Project Operations
205
+
206
+ ### Landing PRs
118
207
 
119
208
  (Note: this portion is a work-in-progress. Please update it as things change)
120
209
 
@@ -126,46 +215,56 @@ In short:
126
215
  1. Follow the "Fork and Clone" steps from above
127
216
  2. Update your `.git/config` to ensure that the `remote ["upstream"]` section is configured to pull both branches and PRs from upstream. It should look something like the following, in particular the second `fetch` option:
128
217
 
129
- ```
218
+ ```bash
130
219
  [remote "upstream"]
131
220
  url = git@github.com:rapid7/recog.git
132
221
  fetch = +refs/heads/*:refs/remotes/upstream/*
133
222
  fetch = +refs/pull/*/head:refs/remotes/upstream/pr/*
134
223
  ```
224
+
135
225
  3. Fetch the latest revisions, including PRs:
136
226
 
137
- ```
227
+ ```bash
138
228
  git fetch --all
139
229
  ```
230
+
140
231
  4. Checkout and branch the PR for testing. Replace ```PR``` below with the actual PR # in question:
141
232
 
142
- ```
233
+ ```bash
143
234
  git checkout -b landing-PR upstream/pr/PR
144
235
  ```
236
+
145
237
  5. Test the PR (see the Testing section above)
146
238
  6. Merge with master, re-test, validate and push:
147
239
 
148
- ```
240
+ ```bash
149
241
  git checkout -b upstream-master --track upstream/master
150
242
  git merge -S --no-ff --edit landing-PR # merge the PR into upstream-master
243
+
151
244
  # re-test if/as necessary
152
245
  git push upstream upstream-master:master --dry-run # confirm you are pushing what you expect
246
+
153
247
  git push upstream upstream-master:master # push upstream-master to upstream:master
154
248
  ```
249
+
155
250
  7. If applicable, release a new version (see next section)
156
251
 
157
- ## Releasing New Versions
252
+ [^back to top](#contributing-to-recog)
253
+
254
+ ### Releasing New Versions
158
255
 
159
256
  When Recog's critical parts are modified, for example its fingerprints or underlying supporting code, a new version _must_ eventually be released. These new releases can then be optionally included in projects such as Metasploit or products such as Rapid7's Nexpose in a controlled manner. Releases for non-functional updates such as updates to documentation are not necessary.
160
257
 
161
258
  When a new version of Recog is to be released, you _must_ follow the instructions below.
162
259
 
163
260
  1. If are not already a Recog project contributor for the Recog gem (you'd be listed [here under OWNERS](https://rubygems.org/gems/recog)), become one:
164
- 1. Get an account on [Rubygems](https://rubygems.org)
165
- 2. Contact one of the Recog project contributors (listed [here under OWNERS](https://rubygems.org/gems/recog) and have them add you to the Recog gem. They'll need to run:
166
- ```
167
- gem owner recog -a EMAIL
168
- ```
169
- 2. Edit [lib/recog/version.rb](https://github.com/rapid7/recog/blob/master/lib/recog/version.rb) and increment ```VERSION```. Commit and push to rapid7/recog master.
170
- 3. Run `rake release`. Among other things, this creates the new gem, uploads it to Rubygems and tags the release with a tag like `v<VERSION>`, where `<VERSION>` is replaced with the version from `version.rb`. For example, if you release version 1.2.3 of the gem, the tag will be `v1.2.3`.
171
- 4. If your default remote repository is not `rapid7/recog`, you must ensure that the tags created in the previous step are also pushed to the right location(s). For example, if `origin` is your fork of recog and `upstream` is `rapid7/master`, you should run `git push --tags --dry-run upstream` to confirm what tags will be pushed and then `git push --tags upstream` to push the tags.
261
+ 1. Get an account on [Rubygems](https://rubygems.org)
262
+ 1. Contact one of the Recog project contributors (listed [here under OWNERS](https://rubygems.org/gems/recog) and have them add you to the Recog gem. They'll need to run: `gem owner recog -a EMAIL`
263
+
264
+ 1. Edit [lib/recog/version.rb](https://github.com/rapid7/recog/blob/master/lib/recog/version.rb) and increment `VERSION`. Commit and push to rapid7/recog master.
265
+
266
+ 1. Run `rake release`. Among other things, this creates the new gem, uploads it to Rubygems and tags the release with a tag like `v<VERSION>`, where `<VERSION>` is replaced with the version from `version.rb`. For example, if you release version 1.2.3 of the gem, the tag will be `v1.2.3`.
267
+
268
+ 1. If your default remote repository is not `rapid7/recog`, you must ensure that the tags created in the previous step are also pushed to the right location(s). For example, if `origin` is your fork of recog and `upstream` is `rapid7/master`, you should run `git push --tags --dry-run upstream` to confirm what tags will be pushed and then `git push --tags upstream` to push the tags.
269
+
270
+ [^back to top](#contributing-to-recog)
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Recog: A Recognition Framework
2
+
2
3
  [![Gem Version](https://badge.fury.io/rb/recog.svg)](http://badge.fury.io/rb/recog)
3
4
  [![Build Status](https://travis-ci.org/rapid7/recog.svg?branch=master)](https://travis-ci.org/rapid7/recog)
4
5
 
@@ -7,6 +8,13 @@ Recog is a framework for identifying products, services, operating systems, and
7
8
 
8
9
  Recog is open source, please see the [LICENSE](https://raw.githubusercontent.com/rapid7/recog/master/LICENSE) file for more information.
9
10
 
11
+ ## Table of Contents
12
+
13
+ 1. [Installation](#installation)
14
+ 1. [Maturity](#maturity)
15
+ 1. [Fingerprints](#fingerprints)
16
+ 1. [Contributing](#contributing)
17
+
10
18
  ## Installation
11
19
 
12
20
  Recog consists of both XML fingerprint files and an assortment of code, mostly in Ruby, that makes it easy to develop, test, and use the contained fingerprints. In 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.
@@ -17,10 +25,14 @@ $ cd recog
17
25
  $ bundle install
18
26
  ```
19
27
 
28
+ [^back to top](#recog-a-recognition-framework)
29
+
20
30
  ## Maturity
21
31
 
22
32
  Please note that while the XML fingerprints themselves are quite stable and well-tested, the Ruby codebase in Recog 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.
23
33
 
34
+ [^back to top](#recog-a-recognition-framework)
35
+
24
36
  ## Fingerprints
25
37
 
26
38
  The fingerprints within 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.
@@ -64,22 +76,12 @@ The `example` string can be base64 encoded to permit the use of unprintable char
64
76
  </example>
65
77
  ````
66
78
 
67
- ### Testing
68
-
69
- Once a fingerprint has been added, the `example` entries can be tested by executing `bin/recog_verify` against the fingerprint file:
79
+ [^back to top](#recog-a-recognition-framework)
70
80
 
71
- ```shell
72
- $ bin/recog_verify xml/ssh_banners.xml
73
- ```
74
-
75
- Matches can be tested on the command-line in a similar fashion:
76
-
77
- ```shell
78
- $ echo 'OpenSSH_6.6p1 Ubuntu-2ubuntu1' | bin/recog_match xml/ssh_banners.xml -
79
- MATCH: {"matched"=>"OpenSSH running on Ubuntu 14.04", "service.version"=>"6.6p1", "openssh.comment"=>"Ubuntu-2ubuntu1", "service.vendor"=>"OpenBSD", "service.family"=>"OpenSSH", "service.product"=>"OpenSSH", "os.vendor"=>"Ubuntu", "os.device"=>"General", "os.family"=>"Linux", "os.product"=>"Linux", "os.version"=>"14.04", "service.protocol"=>"ssh", "fingerprint_db"=>"ssh.banner", "data"=>"OpenSSH_6.6p1 Ubuntu-2ubuntu1"}
80
- ```
81
+ ## Contributing
81
82
 
82
- ### Best Practices
83
+ The users and maintainers of Recog would greatly appreciate any contributions
84
+ you can make to the project. For guidelines and instructions please see
85
+ [CONTRIBUTING.MD](CONTRIBUTING.md)
83
86
 
84
- * Create a single fingerprint for each product as long as the pattern remains clear and readable. If that is not possible, the pattern should be logically decomposed into additional fingerprints.
85
- * Create regular expressions that allow for flexible version number matching. This ensures greater probability of matching a product. For example, all known public releases of a product report either `major.minor` or `major.minor.build` format version numbers. If the fingerprint strictly matches this version number format, it would fail to match a modified build of the product that reports only a `major` version number format.
87
+ [^back to top](#recog-a-recognition-framework)
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
4
+ require 'optparse'
5
+ require 'ostruct'
6
+ require 'recog'
7
+
8
+ # Cleanup trailing whitespace around fingerprints
9
+ Dir[ File.expand_path(File.join(File.dirname(__FILE__), "..", "xml")) + "/*.xml" ].each do |f|
10
+ data = File.read(f).
11
+ gsub(/\s+$/, ''). # Trailing whitespace and empty lines
12
+ gsub("</fingerprint>", "</fingerprint>\n"). # Every fingerprint should have an empty line after it
13
+ gsub("-->", "-->\n") # Every comment should have an empty line after it
14
+
15
+ File.write(f, data)
16
+ end
@@ -18,7 +18,7 @@ def write_identifiers(vals, path)
18
18
  vals.each_pair do |k,v|
19
19
  res = res.push(k)
20
20
  end
21
- res = res.sort.uniq
21
+ res = res.map{|x| x.strip}.select{|x| x.length > 0}.sort.uniq
22
22
  File.write(path, res.join("\n") + "\n")
23
23
  end
24
24
 
@@ -54,9 +54,13 @@ os_arch = load_identifiers(File.join(bdir, "os_architecture.txt"))
54
54
  os_prod = load_identifiers(File.join(bdir, "os_product.txt"))
55
55
  os_family = load_identifiers(File.join(bdir, "os_family.txt"))
56
56
  os_device = load_identifiers(File.join(bdir, "os_device.txt"))
57
+ hw_prod = load_identifiers(File.join(bdir, "hw_product.txt"))
58
+ hw_family = load_identifiers(File.join(bdir, "hw_family.txt"))
59
+ hw_device = load_identifiers(File.join(bdir, "hw_device.txt"))
57
60
  svc_prod = load_identifiers(File.join(bdir, "service_product.txt"))
58
61
  svc_family = load_identifiers(File.join(bdir, "service_family.txt"))
59
62
 
63
+
60
64
  ARGV.each do |arg|
61
65
  Dir.glob(arg).each do |file|
62
66
  ndb = Recog::DB.new(file)
@@ -64,21 +68,23 @@ ARGV.each do |arg|
64
68
  f.params.each do |k,v|
65
69
  paramIndex, val = v
66
70
  next if paramIndex != 0
71
+ next if val.index("{") != -1
72
+ next if val.strip == ""
67
73
  case k
68
74
  when "os.vendor", "service.vendor", "service.component.vendor", "hw.vendor"
69
75
  if ! vendors[val]
70
76
  puts "VENDOR MISSING: #{val}"
71
77
  vendors[val] = true
72
78
  end
73
- when "os.product"
74
- if ! os_prod[val]
75
- puts "OS PRODUCT MISSING: #{val}"
76
- os_prod[val] = true
77
- end
78
79
  when "os.arch"
79
80
  if ! os_arch[val]
80
81
  puts "OS ARCH MISSING: #{val}"
81
82
  os_arch[val] = true
83
+ end
84
+ when "os.product"
85
+ if ! os_prod[val]
86
+ puts "OS PRODUCT MISSING: #{val}"
87
+ os_prod[val] = true
82
88
  end
83
89
  when "os.family"
84
90
  if ! os_family[val]
@@ -90,6 +96,21 @@ ARGV.each do |arg|
90
96
  puts "OS DEVICE MISSING: #{val}"
91
97
  os_device[val] = true
92
98
  end
99
+ when "hw.product"
100
+ if ! hw_prod[val]
101
+ puts "HW PRODUCT MISSING: #{val}"
102
+ hw_prod[val] = true
103
+ end
104
+ when "hw.family"
105
+ if ! hw_family[val]
106
+ puts "HW FAMILY MISSING: #{val}"
107
+ hw_family[val] = true
108
+ end
109
+ when "hw.device"
110
+ if ! hw_device[val]
111
+ puts "HW DEVICE MISSING: #{val}"
112
+ hw_device[val] = true
113
+ end
93
114
  when "service.product"
94
115
  if ! svc_prod[val]
95
116
  puts "SERVICE PRODUCT MISSING: #{val}"
@@ -114,5 +135,8 @@ write_identifiers(os_arch, File.join(bdir, "os_architecture.txt"))
114
135
  write_identifiers(os_prod, File.join(bdir, "os_product.txt"))
115
136
  write_identifiers(os_family, File.join(bdir, "os_family.txt"))
116
137
  write_identifiers(os_device, File.join(bdir, "os_device.txt"))
138
+ write_identifiers(hw_prod, File.join(bdir, "hw_product.txt"))
139
+ write_identifiers(hw_family, File.join(bdir, "hw_family.txt"))
140
+ write_identifiers(hw_device, File.join(bdir, "hw_device.txt"))
117
141
  write_identifiers(svc_prod, File.join(bdir, "service_product.txt"))
118
142
  write_identifiers(svc_family, File.join(bdir, "service_family.txt"))