metasploit_data_models 0.24.4 → 0.24.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +3 -3
- data/.travis.yml +3 -6
- data/CONTRIBUTING.md +52 -10
- data/Gemfile +8 -1
- data/Rakefile +0 -23
- data/app/models/mdm/api_key.rb +1 -41
- data/app/models/mdm/client.rb +1 -41
- data/app/models/mdm/cred.rb +19 -107
- data/app/models/mdm/event.rb +1 -48
- data/app/models/mdm/exploit_attempt.rb +16 -65
- data/app/models/mdm/exploited_host.rb +1 -28
- data/app/models/mdm/host_detail.rb +1 -45
- data/app/models/mdm/host_tag.rb +8 -6
- data/app/models/mdm/listener.rb +1 -53
- data/app/models/mdm/macro.rb +0 -42
- data/app/models/mdm/mod_ref.rb +0 -21
- data/app/models/mdm/module/action.rb +0 -15
- data/app/models/mdm/module/arch.rb +0 -10
- data/app/models/mdm/module/author.rb +0 -16
- data/app/models/mdm/module/mixin.rb +0 -13
- data/app/models/mdm/module/platform.rb +0 -11
- data/app/models/mdm/module/target.rb +0 -18
- data/app/models/mdm/nexpose_console.rb +4 -82
- data/app/models/mdm/profile.rb +0 -36
- data/app/models/mdm/route.rb +5 -17
- data/app/models/mdm/session_event.rb +1 -33
- data/app/models/mdm/tag.rb +10 -49
- data/app/models/mdm/task.rb +45 -94
- data/app/models/mdm/task_cred.rb +0 -29
- data/app/models/mdm/task_host.rb +0 -25
- data/app/models/mdm/task_service.rb +0 -25
- data/app/models/mdm/task_session.rb +0 -25
- data/app/models/mdm/user.rb +6 -188
- data/app/models/mdm/vuln_attempt.rb +12 -37
- data/app/models/mdm/vuln_detail.rb +5 -139
- data/app/models/mdm/vuln_ref.rb +1 -4
- data/app/models/mdm/web_form.rb +1 -35
- data/app/models/mdm/web_page.rb +1 -70
- data/app/models/mdm/web_site.rb +1 -51
- data/app/models/mdm/wmap_request.rb +0 -85
- data/app/models/mdm/wmap_target.rb +0 -40
- data/app/models/mdm/workspace.rb +14 -152
- data/app/models/metasploit_data_models/automatic_exploitation.rb +16 -0
- data/app/models/metasploit_data_models/automatic_exploitation/match.rb +24 -19
- data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +5 -33
- data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +4 -22
- data/app/models/metasploit_data_models/automatic_exploitation/run.rb +3 -13
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
- data/app/models/metasploit_data_models/module_run.rb +1 -1
- data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
- data/app/validators/ip_format_validator.rb +0 -4
- data/app/validators/parameters_validator.rb +0 -12
- data/app/validators/password_is_strong_validator.rb +1 -10
- data/lib/mdm/host/operating_system_normalization.rb +10 -7
- data/lib/metasploit_data_models.rb +0 -4
- data/lib/metasploit_data_models/engine.rb +0 -2
- data/lib/metasploit_data_models/serialized_prefs.rb +0 -6
- data/lib/metasploit_data_models/version.rb +10 -24
- data/lib/tasks/yard.rake +33 -0
- data/metasploit_data_models.gemspec +2 -9
- data/spec/app/models/mdm/api_key_spec.rb +3 -1
- data/spec/app/models/mdm/client_spec.rb +11 -9
- data/spec/app/models/mdm/cred_spec.rb +54 -42
- data/spec/app/models/mdm/event_spec.rb +23 -21
- data/spec/app/models/mdm/exploit_attempt_spec.rb +21 -19
- data/spec/app/models/mdm/exploited_host_spec.rb +13 -11
- data/spec/app/models/mdm/host_detail_spec.rb +17 -15
- data/spec/app/models/mdm/host_spec.rb +260 -261
- data/spec/app/models/mdm/host_tag_spec.rb +8 -6
- data/spec/app/models/mdm/listener_spec.rb +32 -30
- data/spec/app/models/mdm/loot_spec.rb +23 -21
- data/spec/app/models/mdm/macro_spec.rb +3 -1
- data/spec/app/models/mdm/mod_ref_spec.rb +3 -1
- data/spec/app/models/mdm/module/action_spec.rb +12 -10
- data/spec/app/models/mdm/module/arch_spec.rb +12 -10
- data/spec/app/models/mdm/module/author_spec.rb +17 -22
- data/spec/app/models/mdm/module/detail_spec.rb +75 -184
- data/spec/app/models/mdm/module/mixin_spec.rb +12 -10
- data/spec/app/models/mdm/module/platform_spec.rb +12 -10
- data/spec/app/models/mdm/module/ref_spec.rb +12 -10
- data/spec/app/models/mdm/module/target_spec.rb +15 -13
- data/spec/app/models/mdm/nexpose_console_spec.rb +37 -35
- data/spec/app/models/mdm/note_spec.rb +25 -23
- data/spec/app/models/mdm/profile_spec.rb +3 -1
- data/spec/app/models/mdm/ref_spec.rb +12 -10
- data/spec/app/models/mdm/route_spec.rb +8 -6
- data/spec/app/models/mdm/service_spec.rb +40 -38
- data/spec/app/models/mdm/session_event_spec.rb +12 -10
- data/spec/app/models/mdm/session_spec.rb +15 -13
- data/spec/app/models/mdm/tag_spec.rb +29 -29
- data/spec/app/models/mdm/task_cred_spec.rb +11 -9
- data/spec/app/models/mdm/task_host_spec.rb +11 -9
- data/spec/app/models/mdm/task_service_spec.rb +11 -9
- data/spec/app/models/mdm/task_session_spec.rb +9 -7
- data/spec/app/models/mdm/task_spec.rb +29 -27
- data/spec/app/models/mdm/user_spec.rb +19 -17
- data/spec/app/models/mdm/vuln_attempt_spec.rb +16 -14
- data/spec/app/models/mdm/vuln_detail_spec.rb +28 -26
- data/spec/app/models/mdm/vuln_ref_spec.rb +10 -8
- data/spec/app/models/mdm/vuln_spec.rb +26 -24
- data/spec/app/models/mdm/web_form_spec.rb +13 -11
- data/spec/app/models/mdm/web_page_spec.rb +21 -19
- data/spec/app/models/mdm/web_site_spec.rb +23 -21
- data/spec/app/models/mdm/web_vuln_spec.rb +65 -63
- data/spec/app/models/mdm/wmap_request_spec.rb +3 -1
- data/spec/app/models/mdm/wmap_target_spec.rb +3 -1
- data/spec/app/models/mdm/workspace_spec.rb +100 -97
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +5 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +15 -13
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +12 -10
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +23 -21
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +11 -9
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +23 -21
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +15 -22
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +6 -4
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +3 -1
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +20 -18
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +8 -6
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +4 -2
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +10 -8
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +8 -6
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +11 -9
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +7 -5
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +19 -17
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +7 -5
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +23 -61
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +10 -8
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +46 -54
- data/spec/dummy/db/structure.sql +3403 -0
- data/spec/factories/mdm/module/details.rb +1 -1
- data/spec/lib/base64_serializer_spec.rb +19 -19
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +12 -18
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +6 -4
- data/spec/lib/metasploit_data_models/match/child_spec.rb +4 -2
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +6 -4
- data/spec/lib/metasploit_data_models/version_spec.rb +141 -3
- data/spec/spec_helper.rb +12 -86
- data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
- data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
- data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +6 -7
- metadata +9 -67
- data/CHANGELOG.md +0 -6
- data/RELEASING.md +0 -88
- data/UPGRADING.md +0 -1
- data/lib/metasploit_data_models/automatic_exploitation.rb +0 -25
- data/spec/lib/metasploit_data_models_spec.rb +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1295b513f0e595f45f1315528cec3ad0f4cf2de
|
|
4
|
+
data.tar.gz: 9e7bb0f98fc9b16e90fd65c502e715fc31f5a34a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29da581587c411a58073e15611381797eaa99d526e9f18bb4c41c7abf0d21cdce16050bdab6300431e0e65baca48b845dac7bbc9e30b6b5b7d226c1bd6cbffe9
|
|
7
|
+
data.tar.gz: 7645723fa0cb86dd2b484f8a4e51fdaee78be760a41bb25f6ca60df9c6f174d702cc584e26e4e810819e04af8bd3473b7b88510753961529a3eed04cd361968e
|
data/.rspec
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
--
|
|
2
|
-
--
|
|
3
|
-
--
|
|
1
|
+
--format nested
|
|
2
|
+
--colour
|
|
3
|
+
--drb
|
data/.travis.yml
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
addons:
|
|
2
|
-
postgresql: '9.3'
|
|
3
|
-
before_install:
|
|
4
|
-
# graphviz for yard-metasploit-erd
|
|
5
|
-
- sudo apt-get install graphviz
|
|
6
1
|
before_script:
|
|
7
2
|
- cp spec/dummy/config/database.yml.travis spec/dummy/config/database.yml
|
|
8
3
|
- bundle exec rake db:setup
|
|
@@ -10,4 +5,6 @@ cache: bundler
|
|
|
10
5
|
language: ruby
|
|
11
6
|
rvm:
|
|
12
7
|
- 2.1
|
|
13
|
-
|
|
8
|
+
sudo: false
|
|
9
|
+
addons:
|
|
10
|
+
postgresql: '9.3'
|
data/CONTRIBUTING.md
CHANGED
|
@@ -25,18 +25,19 @@ issue tracking software.
|
|
|
25
25
|
|
|
26
26
|
### `PRERELEASE`
|
|
27
27
|
|
|
28
|
-
1. Update `PRERELEASE` to match the `SUMMARY` in the branch name. If you branched from `master`, and [version.rb](lib/metasploit_data_models/version.rb) does not have `PRERELEASE` defined, then adding the following lines after `PATCH`:
|
|
28
|
+
1. Update `PRERELEASE` to match the `SUMMARY` in the branch name. If you branched from `master`, and [version.rb](lib/metasploit_data_models/version.rb) does not have `PRERELEASE` defined, then adding the following lines after `PATCH`:
|
|
29
29
|
```
|
|
30
|
-
# The prerelease version, scoped to the {
|
|
30
|
+
# The prerelease version, scoped to the {PATCH} version number.
|
|
31
31
|
PRERELEASE = '<SUMMARY>'
|
|
32
32
|
```
|
|
33
33
|
2. `rake spec`
|
|
34
34
|
3. Verify the specs pass, which indicates that `PRERELEASE` was updated correctly.
|
|
35
35
|
4. Commit the change `git commit -a`
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
### Your changes
|
|
38
39
|
|
|
39
|
-
Make your changes or however many commits you like,
|
|
40
|
+
Make your changes or however many commits you like, commiting each with `git commit`.
|
|
40
41
|
|
|
41
42
|
### Pre-Pull Request Testing
|
|
42
43
|
|
|
@@ -45,12 +46,12 @@ Make your changes or however many commits you like, committing each with `git co
|
|
|
45
46
|
|
|
46
47
|
### Push
|
|
47
48
|
|
|
48
|
-
Push your branch to your fork on
|
|
49
|
+
Push your branch to your fork on gitub: `git push push TYPE/ISSUE/SUMMARY`
|
|
49
50
|
|
|
50
51
|
### Pull Request
|
|
51
52
|
|
|
52
53
|
* [Create new Pull Request](https://github.com/rapid7/metasploit_data_models/compare/)
|
|
53
|
-
* Add a Verification Steps
|
|
54
|
+
* Add a Verification Steps comment
|
|
54
55
|
|
|
55
56
|
```
|
|
56
57
|
# Verification Steps
|
|
@@ -61,12 +62,11 @@ Push your branch to your fork on github: `git push TYPE/ISSUE/SUMMARY`
|
|
|
61
62
|
- [ ] `rake spec`
|
|
62
63
|
- [ ] VERIFY no failures
|
|
63
64
|
```
|
|
64
|
-
|
|
65
65
|
You should also include at least one scenario to manually check the changes outside of specs.
|
|
66
66
|
|
|
67
67
|
* Add a Post-merge Steps comment
|
|
68
68
|
|
|
69
|
-
The 'Post-merge Steps' are a reminder to the reviewer of the Pull Request of how to update the [`PRERELEASE`](lib/metasploit_data_models/version.rb) so that [version_spec.rb](spec/lib/metasploit_data_models/
|
|
69
|
+
The 'Post-merge Steps' are a reminder to the reviewer of the Pull Request of how to update the [`PRERELEASE`](lib/metasploit_data_models/version.rb) so that [version_spec.rb](spec/lib/metasploit_data_models/version_spec.rb) passes on the target branch after the merge.
|
|
70
70
|
|
|
71
71
|
DESTINATION is the name of the destination branch into which the merge is being made. SOURCE_SUMMARY is the SUMMARY from TYPE/ISSUE/SUMMARY branch name for the SOURCE branch that is being made.
|
|
72
72
|
|
|
@@ -106,7 +106,7 @@ Perform these steps prior to pushing to DESTINATION or the build will be broke o
|
|
|
106
106
|
- [ ] Change `PRERELEASE` from `SOURCE_SUMMARY` to `DESTINATION_SUMMARY` to match the branch (DESTINATION) summary (DESTINATION_SUMMARY)
|
|
107
107
|
|
|
108
108
|
## Gem build
|
|
109
|
-
- [ ] gem build
|
|
109
|
+
- [ ] gem build *.gemspec
|
|
110
110
|
- [ ] VERIFY the prerelease suffix has change on the gem.
|
|
111
111
|
|
|
112
112
|
## RSpec
|
|
@@ -118,5 +118,47 @@ Perform these steps prior to pushing to DESTINATION or the build will be broke o
|
|
|
118
118
|
- [ ] `git push origin DESTINATION`
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
* Add a 'Release Steps' comment
|
|
122
|
+
|
|
123
|
+
The 'Release Steps' are a reminder to the reviewer of the Pull Request of how to release the gem.
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
# Release
|
|
127
|
+
|
|
128
|
+
Complete these steps on DESTINATION
|
|
129
|
+
|
|
130
|
+
## Version
|
|
131
|
+
|
|
132
|
+
### Compatible changes
|
|
133
|
+
|
|
134
|
+
If the change are compatible with the previous branch's API, then increment [`PATCH`](lib/metasploit_data_models/version.rb).
|
|
135
|
+
|
|
136
|
+
### Incompatible changes
|
|
137
|
+
|
|
138
|
+
If your changes are incompatible with the previous branch's API, then increment
|
|
139
|
+
[`MINOR`](lib/metasploit_data_models/version.rb) and reset [`PATCH`](lib/metasploit_data_models/version.rb) to `0`.
|
|
140
|
+
|
|
141
|
+
- [ ] Following the rules for [semantic versioning 2.0](http://semver.org/spec/v2.0.0.html), update
|
|
142
|
+
[`MINOR`](lib/metasploit_data_models/version.rb) and [`PATCH`](lib/metasploit_data_models/version.rb) and commit the changes.
|
|
143
|
+
|
|
144
|
+
## JRuby
|
|
145
|
+
- [ ] `rvm use jruby@metasploit_data_models`
|
|
146
|
+
- [ ] `rm Gemfile.lock`
|
|
147
|
+
- [ ] `bundle install`
|
|
148
|
+
- [ ] `rake release`
|
|
149
|
+
|
|
150
|
+
## MRI Ruby
|
|
151
|
+
- [ ] `rvm use ruby-2.1@metasploit_data_models`
|
|
152
|
+
- [ ] `rm Gemfile.lock`
|
|
153
|
+
- [ ] `bundle install`
|
|
154
|
+
- [ ] `rake release`
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Downstream dependencies
|
|
158
|
+
|
|
159
|
+
When releasing new versions, the following projects may need to be updated:
|
|
160
|
+
|
|
161
|
+
* [metasploit-credential](https://github.com/rapid7/metasploit-credential)
|
|
162
|
+
* [metasploit-framework](https://github.com/rapid7/metasploit-framework)
|
|
163
|
+
* [metasploit-pro-ui](https://github.com/rapid7/pro/tree/master/ui)
|
|
164
|
+
* [metasploit-pro-engine](https://github.com/rapid7/pro/tree/master/engine)
|
data/Gemfile
CHANGED
|
@@ -3,6 +3,11 @@ source "https://rubygems.org"
|
|
|
3
3
|
# Specify your gem's dependencies in metasploit_data_models.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
+
group :development do
|
|
7
|
+
# embed ERDs on index, namespace Module and Class<ActiveRecord::Base> pages
|
|
8
|
+
gem 'yard-metasploit-erd', '~> 0.0.2'
|
|
9
|
+
end
|
|
10
|
+
|
|
6
11
|
# used by dummy application
|
|
7
12
|
group :development, :test do
|
|
8
13
|
# Upload coverage reports to coveralls.io
|
|
@@ -27,9 +32,11 @@ group :test do
|
|
|
27
32
|
gem 'shoulda-matchers'
|
|
28
33
|
# code coverage of tests
|
|
29
34
|
gem 'simplecov', :require => false
|
|
35
|
+
# @todo Update specs for rspec 3.0.0 compatibility and remove this gem in favor of just rspec-rails
|
|
36
|
+
gem 'rspec-core', '< 3.0.0'
|
|
30
37
|
# need rspec-rails >= 2.12.0 as 2.12.0 adds support for redefining named subject in nested context that uses the
|
|
31
38
|
# named subject from the outer context without causing a stack overflow.
|
|
32
|
-
gem 'rspec-rails', '
|
|
39
|
+
gem 'rspec-rails', '>= 2.12.0'
|
|
33
40
|
# used for building markup for webpage factories
|
|
34
41
|
gem 'builder'
|
|
35
42
|
end
|
data/Rakefile
CHANGED
|
@@ -42,29 +42,6 @@ else
|
|
|
42
42
|
task :default => :spec
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
|
46
|
-
gem_specification = Gem::Specification.find_all_by_name('metasploit-yard').first
|
|
47
|
-
|
|
48
|
-
if gem_specification
|
|
49
|
-
Dir[File.join(gem_specification.gem_dir, 'lib', 'tasks', '**', '*.rake')].each do |rake|
|
|
50
|
-
load rake
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
#
|
|
54
|
-
# Eager load before yard docs so that ActiveRecord::Base subclasses are loaded for yard-metasploit-erd
|
|
55
|
-
#
|
|
56
|
-
|
|
57
|
-
task 'yard:doc' => :eager_load
|
|
58
|
-
|
|
59
|
-
task eager_load: :environment do
|
|
60
|
-
Rails.application.eager_load!
|
|
61
|
-
end
|
|
62
|
-
else
|
|
63
|
-
puts "metasploit-yard not in bundle, so can't setup yard tasks. " \
|
|
64
|
-
"To run yard ensure to install the development group."
|
|
65
|
-
print_without = true
|
|
66
|
-
end
|
|
67
|
-
|
|
68
45
|
if print_without
|
|
69
46
|
puts "Bundle currently installed '--without #{Bundler.settings.without.join(' ')}'."
|
|
70
47
|
puts "To clear the without option do `bundle install --without ''` (the --without flag with an empty string) or " \
|
data/app/models/mdm/api_key.rb
CHANGED
|
@@ -1,53 +1,13 @@
|
|
|
1
|
-
# API key to access the RPC.
|
|
2
1
|
class Mdm::ApiKey < ActiveRecord::Base
|
|
3
2
|
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
# @!attribute [rw] created_at
|
|
8
|
-
# When this API Key was created.
|
|
9
|
-
#
|
|
10
|
-
# @return [DateTime]
|
|
11
|
-
|
|
12
|
-
# @!attribute [rw] token
|
|
13
|
-
# The API Key to authenicate to the RPC.
|
|
14
|
-
#
|
|
15
|
-
# @return [String]
|
|
16
|
-
|
|
17
|
-
# @!attribute [rw] updated_at
|
|
18
|
-
# The last time this API Key was updated.
|
|
19
|
-
#
|
|
20
|
-
# @return [DateTime]
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
# Validations
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
|
|
28
|
-
#
|
|
29
|
-
# Method Validations
|
|
3
|
+
# Validators
|
|
30
4
|
#
|
|
31
5
|
|
|
32
6
|
validate :supports_api
|
|
33
|
-
|
|
34
|
-
#
|
|
35
|
-
# Attribute Validations
|
|
36
|
-
#
|
|
37
|
-
|
|
38
7
|
validates :token, :presence => true, :length => { :minimum => 8 }
|
|
39
8
|
|
|
40
|
-
#
|
|
41
|
-
# Instance Methods
|
|
42
|
-
#
|
|
43
|
-
|
|
44
9
|
protected
|
|
45
10
|
|
|
46
|
-
|
|
47
|
-
# Validates whether License supports API.
|
|
48
|
-
#
|
|
49
|
-
# @return [void]
|
|
50
|
-
# @todo MSP-2724
|
|
51
11
|
def supports_api
|
|
52
12
|
license = License.get
|
|
53
13
|
|
data/app/models/mdm/client.rb
CHANGED
|
@@ -1,50 +1,10 @@
|
|
|
1
|
-
# Client used for `report_client` in metasploit-framework Metasploit Modules.
|
|
2
1
|
class Mdm::Client < ActiveRecord::Base
|
|
3
2
|
#
|
|
4
|
-
#
|
|
3
|
+
# Relations
|
|
5
4
|
#
|
|
6
|
-
|
|
7
|
-
# {Mdm::Host} from which this client connected.
|
|
8
5
|
belongs_to :host,
|
|
9
6
|
class_name: 'Mdm::Host',
|
|
10
7
|
inverse_of: :clients
|
|
11
8
|
|
|
12
|
-
#
|
|
13
|
-
# Attributes
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
# @!attribute created_at
|
|
17
|
-
# When this client was created.
|
|
18
|
-
#
|
|
19
|
-
# @return [DateTime]
|
|
20
|
-
|
|
21
|
-
# @!attribute updated_at
|
|
22
|
-
# When this client was last updated.
|
|
23
|
-
#
|
|
24
|
-
# @return [DateTime]
|
|
25
|
-
|
|
26
|
-
#
|
|
27
|
-
# @!group User Agent
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
# @!attribute ua_name
|
|
31
|
-
# Parsed name from {#ua_string user agent string}
|
|
32
|
-
#
|
|
33
|
-
# @return [String]
|
|
34
|
-
|
|
35
|
-
# @!attribute ua_string
|
|
36
|
-
# Raw user agent string from client browser
|
|
37
|
-
#
|
|
38
|
-
# @return [String]
|
|
39
|
-
|
|
40
|
-
# @!attribute ua_ver
|
|
41
|
-
# Version of user agent.
|
|
42
|
-
#
|
|
43
|
-
# @return [String]
|
|
44
|
-
|
|
45
|
-
#
|
|
46
|
-
# @!endgroup
|
|
47
|
-
#
|
|
48
|
-
|
|
49
9
|
Metasploit::Concern.run(self)
|
|
50
10
|
end
|
data/app/models/mdm/cred.rb
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
# @deprecated Use metasploit-credential's `Metasploit::Credential::Core`.
|
|
2
|
-
#
|
|
3
|
-
# A credential captured from a {#service}.
|
|
4
1
|
class Mdm::Cred < ActiveRecord::Base
|
|
5
2
|
#
|
|
6
3
|
# CONSTANTS
|
|
7
4
|
#
|
|
8
|
-
|
|
9
|
-
# Checks if {#proof} is an SSH Key in {#ssh_key_id}.
|
|
10
5
|
KEY_ID_REGEX = /([0-9a-fA-F:]{47})/
|
|
11
|
-
|
|
12
|
-
# Maps {#ptype_human} to {#ptype}.
|
|
13
6
|
PTYPES = {
|
|
14
7
|
'read/write password' => 'password_rw',
|
|
15
8
|
'read-only password' => 'password_ro',
|
|
@@ -19,93 +12,35 @@ class Mdm::Cred < ActiveRecord::Base
|
|
|
19
12
|
}
|
|
20
13
|
|
|
21
14
|
#
|
|
22
|
-
#
|
|
23
|
-
# Associations
|
|
24
|
-
#
|
|
15
|
+
# Relations
|
|
25
16
|
#
|
|
26
17
|
|
|
27
|
-
#
|
|
18
|
+
# @!attribute [rw] servce
|
|
19
|
+
# The service this cred is for
|
|
20
|
+
#
|
|
21
|
+
# @return [Mdm::Service]
|
|
28
22
|
belongs_to :service,
|
|
29
23
|
class_name: 'Mdm::Service',
|
|
30
24
|
inverse_of: :creds
|
|
31
25
|
|
|
32
|
-
#
|
|
26
|
+
# @!attribute [rw] task_creds
|
|
27
|
+
# Details about what Tasks touched this cred
|
|
28
|
+
#
|
|
29
|
+
# @return [Array<Mdm::TaskCred>]
|
|
33
30
|
has_many :task_creds,
|
|
34
31
|
class_name: 'Mdm::TaskCred',
|
|
35
32
|
dependent: :destroy,
|
|
36
33
|
inverse_of: :cred
|
|
37
34
|
|
|
35
|
+
# @!attribute [rw] tasks
|
|
36
|
+
# Tasks that touched this service
|
|
38
37
|
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
# Tasks that touched this service
|
|
38
|
+
# @return [Array<Mdm::Task>]
|
|
43
39
|
has_many :tasks, :through => :task_creds
|
|
44
40
|
|
|
45
|
-
#
|
|
46
|
-
# Attributes
|
|
47
|
-
#
|
|
48
|
-
|
|
49
|
-
# @!attribute active
|
|
50
|
-
# Whether the credential is active.
|
|
51
|
-
#
|
|
52
|
-
# @return [false] if a captured credential cannot be used to log into {#service}.
|
|
53
|
-
# @return [true] otherwise
|
|
54
|
-
|
|
55
|
-
# @!attribute created_at
|
|
56
|
-
# When this credential was created.
|
|
57
|
-
#
|
|
58
|
-
# @return [DateTime]
|
|
59
|
-
|
|
60
|
-
# @!attribute pass
|
|
61
|
-
# Pass of credential.
|
|
62
|
-
#
|
|
63
|
-
# @return [String, nil]
|
|
64
|
-
|
|
65
|
-
# @!attribute proof
|
|
66
|
-
# Proof of credential capture.
|
|
67
|
-
#
|
|
68
|
-
# @return [String]
|
|
69
|
-
|
|
70
|
-
# @!attribute ptype
|
|
71
|
-
# Type of {#pass}.
|
|
72
|
-
#
|
|
73
|
-
# @return [String]
|
|
74
|
-
|
|
75
|
-
# @!attribute source_id
|
|
76
|
-
# Id of source of this credential.
|
|
77
|
-
#
|
|
78
|
-
# @return [Integer, nil]
|
|
79
|
-
|
|
80
|
-
# @!attribute source_type
|
|
81
|
-
# Type of source with {#source_id}.
|
|
82
|
-
#
|
|
83
|
-
# @return [String, nil]
|
|
84
|
-
|
|
85
|
-
# @!attribute updated_at
|
|
86
|
-
# The last time this credential was updated.
|
|
87
|
-
#
|
|
88
|
-
# @return [DateTime]
|
|
89
|
-
|
|
90
|
-
# @!attribute user
|
|
91
|
-
# User name of credential.
|
|
92
|
-
#
|
|
93
|
-
# @return [String, nil]
|
|
94
|
-
|
|
95
|
-
#
|
|
96
|
-
# Callbacks
|
|
97
|
-
#
|
|
98
|
-
|
|
99
41
|
after_create :increment_host_counter_cache
|
|
100
42
|
after_destroy :decrement_host_counter_cache
|
|
101
43
|
|
|
102
|
-
#
|
|
103
|
-
# Instance methods
|
|
104
|
-
#
|
|
105
|
-
|
|
106
|
-
# Humanized {#ptype}.
|
|
107
|
-
#
|
|
108
|
-
# @return [String, nil]
|
|
109
44
|
def ptype_human
|
|
110
45
|
humanized = PTYPES.select do |k, v|
|
|
111
46
|
v == ptype
|
|
@@ -114,24 +49,13 @@ class Mdm::Cred < ActiveRecord::Base
|
|
|
114
49
|
humanized ? humanized : ptype
|
|
115
50
|
end
|
|
116
51
|
|
|
117
|
-
# Returns
|
|
118
|
-
#
|
|
119
|
-
# @return [String] SSH Key Id if ssh-type key and {#proof} matches {KEY_ID_REGEX}.
|
|
120
|
-
# @return [nil] otherwise
|
|
52
|
+
# Returns its key id. If this is not an ssh-type key, returns nil.
|
|
121
53
|
def ssh_key_id
|
|
122
54
|
return nil unless self.ptype =~ /^ssh_/
|
|
123
55
|
return nil unless self.proof =~ KEY_ID_REGEX
|
|
124
56
|
$1.downcase # Can't run into NilClass problems.
|
|
125
57
|
end
|
|
126
58
|
|
|
127
|
-
# Returns whether `other`'s SSH private key or public key matches.
|
|
128
|
-
#
|
|
129
|
-
# @return [false] if `other` is not same class as `self`.
|
|
130
|
-
# @return [false] if {#ptype} does not match.
|
|
131
|
-
# @return [false] if {#ptype} is neither `"ssh_key"` nor `"ssh_pubkey"`.
|
|
132
|
-
# @return [false] if {#ssh_key_id} is `nil`.
|
|
133
|
-
# @return [false] if {#ssh_key_id} does not match.
|
|
134
|
-
# @return [true] if {#ssh_key_id} matches.
|
|
135
59
|
def ssh_key_matches?(other_cred)
|
|
136
60
|
return false unless other_cred.kind_of? self.class
|
|
137
61
|
return false unless self.ptype == other_cred.ptype
|
|
@@ -146,16 +70,14 @@ class Mdm::Cred < ActiveRecord::Base
|
|
|
146
70
|
matches.include?(self) and matches.include?(other_cred)
|
|
147
71
|
end
|
|
148
72
|
|
|
149
|
-
# Returns all keys with matching key ids, including itself
|
|
150
|
-
#
|
|
151
|
-
# @return [ActiveRecord::Relation<Mdm::Cred>] ssh_key and ssh_pubkey creds with matching {#ssh_key_id}.
|
|
73
|
+
# Returns all keys with matching key ids, including itself
|
|
74
|
+
# If this is not an ssh-type key, always returns an empty array.
|
|
152
75
|
def ssh_keys
|
|
153
76
|
(self.ssh_private_keys | self.ssh_public_keys)
|
|
154
77
|
end
|
|
155
78
|
|
|
156
|
-
# Returns all private keys with matching
|
|
157
|
-
#
|
|
158
|
-
# @return [ActiveRecord::Relation<Mdm::Cred>] ssh_key creds with matching {#ssh_key_id}.
|
|
79
|
+
# Returns all private keys with matching key ids, including itself
|
|
80
|
+
# If this is not an ssh-type key, always returns an empty array.
|
|
159
81
|
def ssh_private_keys
|
|
160
82
|
return [] unless self.ssh_key_id
|
|
161
83
|
matches = self.class.all(
|
|
@@ -164,9 +86,8 @@ class Mdm::Cred < ActiveRecord::Base
|
|
|
164
86
|
matches.select {|c| c.workspace == self.workspace}
|
|
165
87
|
end
|
|
166
88
|
|
|
167
|
-
# Returns all public keys with matching
|
|
168
|
-
#
|
|
169
|
-
# @return [ActiveRecord::Relation<Mdm::Cred>] ssh_pubkey creds with matching {#ssh_key_id}.
|
|
89
|
+
# Returns all public keys with matching key ids, including itself
|
|
90
|
+
# If this is not an ssh-type key, always returns an empty array.
|
|
170
91
|
def ssh_public_keys
|
|
171
92
|
return [] unless self.ssh_key_id
|
|
172
93
|
matches = self.class.all(
|
|
@@ -176,29 +97,20 @@ class Mdm::Cred < ActiveRecord::Base
|
|
|
176
97
|
end
|
|
177
98
|
|
|
178
99
|
# Returns its workspace
|
|
179
|
-
#
|
|
180
|
-
# @return [Mdm::Workspace]
|
|
181
100
|
def workspace
|
|
182
101
|
self.service.host.workspace
|
|
183
102
|
end
|
|
184
103
|
|
|
185
104
|
private
|
|
186
105
|
|
|
187
|
-
# Decrements {Mdm::Host#cred_count}.
|
|
188
|
-
#
|
|
189
|
-
# @return [void]
|
|
190
106
|
def decrement_host_counter_cache
|
|
191
107
|
Mdm::Host.decrement_counter("cred_count", self.service.host_id)
|
|
192
108
|
end
|
|
193
109
|
|
|
194
|
-
# Increments {Mdm::Host#cred_count}.
|
|
195
|
-
#
|
|
196
|
-
# @return [void]
|
|
197
110
|
def increment_host_counter_cache
|
|
198
111
|
Mdm::Host.increment_counter("cred_count", self.service.host_id)
|
|
199
112
|
end
|
|
200
113
|
|
|
201
|
-
# Switch back to public for load hooks.
|
|
202
114
|
public
|
|
203
115
|
|
|
204
116
|
Metasploit::Concern.run(self)
|