metasploit-credential 0.14.7 → 0.14.8
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/CONTRIBUTING.md +41 -9
- data/lib/metasploit/credential/exporter/core.rb +2 -2
- data/lib/metasploit/credential/exporter/pwdump.rb +2 -2
- data/lib/metasploit/credential/migrator.rb +1 -1
- data/lib/metasploit/credential/version.rb +12 -21
- data/spec/dummy/db/structure.sql +0 -1
- data/spec/lib/metasploit/credential/creation_spec.rb +8 -6
- data/spec/lib/metasploit/credential/exporter/core_spec.rb +85 -100
- data/spec/lib/metasploit/credential/exporter/pwdump_spec.rb +16 -14
- data/spec/lib/metasploit/credential/importer/core_spec.rb +12 -10
- data/spec/lib/metasploit/credential/importer/multi_spec.rb +6 -4
- data/spec/lib/metasploit/credential/importer/pwdump_spec.rb +13 -11
- data/spec/lib/metasploit/credential/importer/zip_spec.rb +7 -5
- data/spec/lib/metasploit/credential/migrator_spec.rb +13 -13
- data/spec/lib/metasploit/credential/version_spec.rb +141 -3
- data/spec/lib/metasploit/credential_spec.rb +15 -4
- data/spec/models/mdm/service_spec.rb +5 -3
- data/spec/models/mdm/session_spec.rb +4 -2
- data/spec/models/mdm/task_spec.rb +6 -4
- data/spec/models/mdm/user_spec.rb +4 -2
- data/spec/models/mdm/workspace_spec.rb +4 -2
- data/spec/models/metasploit/credential/blank_username_spec.rb +7 -5
- data/spec/models/metasploit/credential/core_spec.rb +45 -43
- data/spec/models/metasploit/credential/login/status_spec.rb +21 -19
- data/spec/models/metasploit/credential/login_spec.rb +38 -36
- data/spec/models/metasploit/credential/nonreplayable_hash_spec.rb +5 -3
- data/spec/models/metasploit/credential/ntlm_hash_spec.rb +15 -13
- data/spec/models/metasploit/credential/origin/cracked_password_spec.rb +7 -5
- data/spec/models/metasploit/credential/origin/import_spec.rb +10 -8
- data/spec/models/metasploit/credential/origin/manual_spec.rb +9 -7
- data/spec/models/metasploit/credential/origin/service_spec.rb +12 -10
- data/spec/models/metasploit/credential/origin/session_spec.rb +13 -11
- data/spec/models/metasploit/credential/password_hash_spec.rb +6 -4
- data/spec/models/metasploit/credential/password_spec.rb +5 -3
- data/spec/models/metasploit/credential/postgres_md5_spec.rb +6 -4
- data/spec/models/metasploit/credential/private_spec.rb +10 -8
- data/spec/models/metasploit/credential/public_spec.rb +7 -5
- data/spec/models/metasploit/credential/realm_spec.rb +16 -14
- data/spec/models/metasploit/credential/replayable_hash_spec.rb +5 -3
- data/spec/models/metasploit/credential/ssh_key_spec.rb +17 -15
- data/spec/models/metasploit/credential/username_spec.rb +8 -6
- data/spec/models/metasploit_data_models/search/visitor/relation_spec.rb +3 -1
- data/spec/spec_helper.rb +25 -95
- data/spec/support/shared/contexts/mdm/workspace.rb +1 -1
- data/spec/support/shared/examples/core_validations.rb +42 -117
- data/spec/support/shared/examples/single_table_inheritance_database_columns.rb +2 -2
- data/spec/support/shared/examples/timestamp_database_column.rb +2 -2
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 895352ea1fdface54872f23f7ef803a5733cd3c2
|
4
|
+
data.tar.gz: ff8bb3e6f773ec263c99459fe8618db96fa66855
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f13f43bae66ba9283939559732ffef33303215e06146ee78ccb0ba14fb1c8d7b1cc3f9be1fe424ba519ef499cab9d666ac877cb30ff17b19d1183b13d54962a7
|
7
|
+
data.tar.gz: fa0396f86e9f469da28eb4875c57f70719d1b0aa177cde5bc06b69848b53438b80414ed10b4522ead6c732a1b2ea53778f11769259b8a703e158851b7e162bf5
|
data/CONTRIBUTING.md
CHANGED
@@ -25,9 +25,9 @@ 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/credential/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/credential/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`
|
@@ -36,7 +36,7 @@ PRERELEASE = '<SUMMARY>'
|
|
36
36
|
|
37
37
|
### Your changes
|
38
38
|
|
39
|
-
Make your changes or however many commits you like,
|
39
|
+
Make your changes or however many commits you like, commiting each with `git commit`.
|
40
40
|
|
41
41
|
### Pre-Pull Request Testing
|
42
42
|
|
@@ -45,12 +45,12 @@ Make your changes or however many commits you like, committing each with `git co
|
|
45
45
|
|
46
46
|
### Push
|
47
47
|
|
48
|
-
Push your branch to your fork on
|
48
|
+
Push your branch to your fork on gitub: `git push push TYPE/ISSUE/SUMMARY`
|
49
49
|
|
50
50
|
### Pull Request
|
51
51
|
|
52
52
|
* [Create new Pull Request](https://github.com/rapid7/metasploit-credential/compare/)
|
53
|
-
* Add a Verification Steps
|
53
|
+
* Add a Verification Steps comment
|
54
54
|
|
55
55
|
```
|
56
56
|
# Verification Steps
|
@@ -61,7 +61,6 @@ Push your branch to your fork on github: `git push TYPE/ISSUE/SUMMARY`
|
|
61
61
|
- [ ] `rake spec`
|
62
62
|
- [ ] VERIFY no failures
|
63
63
|
```
|
64
|
-
|
65
64
|
You should also include at least one scenario to manually check the changes outside of specs.
|
66
65
|
|
67
66
|
* Add a Post-merge Steps comment
|
@@ -106,7 +105,7 @@ Perform these steps prior to pushing to DESTINATION or the build will be broke o
|
|
106
105
|
- [ ] Change `PRERELEASE` from `SOURCE_SUMMARY` to `DESTINATION_SUMMARY` to match the branch (DESTINATION) summary (DESTINATION_SUMMARY)
|
107
106
|
|
108
107
|
## Gem build
|
109
|
-
- [ ] gem build
|
108
|
+
- [ ] gem build *.gemspec
|
110
109
|
- [ ] VERIFY the prerelease suffix has change on the gem.
|
111
110
|
|
112
111
|
## RSpec
|
@@ -118,5 +117,38 @@ Perform these steps prior to pushing to DESTINATION or the build will be broke o
|
|
118
117
|
- [ ] `git push origin DESTINATION`
|
119
118
|
```
|
120
119
|
|
121
|
-
|
122
|
-
|
120
|
+
* Add a 'Release Steps' comment
|
121
|
+
|
122
|
+
The 'Release Steps' are a reminder to the reviewer of the Pull Request of how to release the gem.
|
123
|
+
|
124
|
+
```
|
125
|
+
# Release
|
126
|
+
|
127
|
+
Complete these steps on DESTINATION
|
128
|
+
|
129
|
+
## `VERSION`
|
130
|
+
|
131
|
+
### Compatible changes
|
132
|
+
|
133
|
+
If your change are compatible with the previous branch's API, then increment [`PATCH`](lib/metasploit/credential/version.rb).
|
134
|
+
|
135
|
+
### Incompatible changes
|
136
|
+
|
137
|
+
If your changes are incompatible with the previous branch's API, then increment [`MINOR`](lib/metasploit/credential/version.rb) and reset [`PATCH`](lib/metasploit/credential/version.rb) to `0`.
|
138
|
+
|
139
|
+
- [ ] Following the rules for [semantic versioning 2.0](http://semver.org/spec/v2.0.0.html), update [`MINOR`](lib/metasploit/credential/version.rb) and [`PATCH`](lib/metasploit/credential/version.rb) and commit the changes.
|
140
|
+
|
141
|
+
## MRI Ruby
|
142
|
+
- [ ] `rvm use ruby-2.1@metasploit_data_models`
|
143
|
+
- [ ] `rm Gemfile.lock`
|
144
|
+
- [ ] `bundle install`
|
145
|
+
- [ ] `rake release`
|
146
|
+
```
|
147
|
+
|
148
|
+
### Downstream dependencies
|
149
|
+
|
150
|
+
When releasing new versions, the following projects may need to be updated:
|
151
|
+
|
152
|
+
* [metasploit-framework](https://github.com/rapid7/metasploit-framework)
|
153
|
+
* [metasploit-pro-ui](https://github.com/rapid7/pro/tree/master/ui)
|
154
|
+
* [metasploit-pro-engine](https://github.com/rapid7/pro/tree/master/engine)
|
@@ -49,10 +49,10 @@ class Metasploit::Credential::Exporter::Core
|
|
49
49
|
# Attributes
|
50
50
|
#
|
51
51
|
|
52
|
-
# @!attribute
|
52
|
+
# @!attribute export_data
|
53
53
|
# Holds the raw information from the database before it is formatted into the {#data} attribute
|
54
54
|
# @return [Array]
|
55
|
-
|
55
|
+
attr_accessor :export_data
|
56
56
|
|
57
57
|
# @!attribute finalized_zip_file
|
58
58
|
# The final output artifacts, zipped
|
@@ -70,10 +70,10 @@ class Metasploit::Credential::Exporter::Pwdump
|
|
70
70
|
# Attributes
|
71
71
|
#
|
72
72
|
|
73
|
-
# @!attribute
|
73
|
+
# @!attribute logins
|
74
74
|
# Holds the raw information from the database before it is formatted into the {#data} attribute
|
75
75
|
# @return [Array<Metasploit::Credential::Login>]
|
76
|
-
|
76
|
+
attr_accessor :logins
|
77
77
|
|
78
78
|
|
79
79
|
#
|
@@ -104,7 +104,7 @@ class Metasploit::Credential::Migrator
|
|
104
104
|
# @return [String]
|
105
105
|
def key_data_from_file(path)
|
106
106
|
# Sometimes we will set the :pass attribute to a file path containing the key
|
107
|
-
if File.
|
107
|
+
if File.exists?(path)
|
108
108
|
File.read(path)
|
109
109
|
# In other cases we store the entire SSH key directly in the :pass attribute
|
110
110
|
elsif Metasploit::Credential::SSHKey.new(data: path).private?
|
@@ -4,26 +4,20 @@ module Metasploit
|
|
4
4
|
module Credential
|
5
5
|
# Holds components of {VERSION} as defined by {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0}.
|
6
6
|
module Version
|
7
|
-
#
|
8
|
-
# CONSTANTS
|
9
|
-
#
|
10
|
-
|
11
7
|
# The major version number.
|
12
8
|
MAJOR = 0
|
13
9
|
# The minor version number, scoped to the {MAJOR} version number.
|
14
10
|
MINOR = 14
|
15
|
-
# The patch
|
16
|
-
PATCH =
|
11
|
+
# The patch number, scoped to the {MAJOR} and {MINOR} version number.
|
12
|
+
PATCH = 8
|
13
|
+
# The prerelease version, scoped to the {MAJOR}, {MINOR}, and {PATCH} version number.
|
14
|
+
# PRERELEASE =
|
17
15
|
|
18
|
-
# The full version string, including the {
|
19
|
-
# {Metasploit::Credential::Version::MINOR}, {Metasploit::Credential::Version::PATCH}, and optionally, the
|
20
|
-
# `Metasploit::Credential::Version::PRERELEASE` in the
|
16
|
+
# The full version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
21
17
|
# {http://semver.org/spec/v2.0.0.html semantic versioning v2.0.0} format.
|
22
18
|
#
|
23
|
-
# @return [String] '{
|
24
|
-
#
|
25
|
-
# '{Metasploit::Credential::Version::MAJOR}.{Metasploit::Credential::Version::MINOR}.{Metasploit::Credential::Version::PATCH}-PRERELEASE'
|
26
|
-
# on any branch other than master.
|
19
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}-{PRERELEASE}' on any branch
|
20
|
+
# other than master.
|
27
21
|
def self.full
|
28
22
|
version = "#{MAJOR}.#{MINOR}.#{PATCH}"
|
29
23
|
|
@@ -34,23 +28,20 @@ module Metasploit
|
|
34
28
|
version
|
35
29
|
end
|
36
30
|
|
37
|
-
# The full gem version string, including the {
|
38
|
-
# {Metasploit::Credential::Version::MINOR}, {Metasploit::Credential::Version::PATCH}, and optionally, the
|
39
|
-
# `Metasploit::Credential::Version::PRERELEASE` in the
|
31
|
+
# The full gem version string, including the {MAJOR}, {MINOR}, {PATCH}, and optionally, the {PRERELEASE} in the
|
40
32
|
# {http://guides.rubygems.org/specification-reference/#version RubyGems versioning} format.
|
41
33
|
#
|
42
|
-
# @return [String] '{
|
43
|
-
#
|
44
|
-
# on any branch other than master.
|
34
|
+
# @return [String] '{MAJOR}.{MINOR}.{PATCH}' on master. '{MAJOR}.{MINOR}.{PATCH}.{PRERELEASE}' on any branch
|
35
|
+
# other than master.
|
45
36
|
def self.gem
|
46
37
|
full.gsub('-', '.pre.')
|
47
38
|
end
|
48
39
|
end
|
49
40
|
|
50
|
-
#
|
41
|
+
# @see Version.gem
|
51
42
|
GEM_VERSION = Version.gem
|
52
43
|
|
53
|
-
#
|
44
|
+
# @see Version.full
|
54
45
|
VERSION = Version.full
|
55
46
|
end
|
56
47
|
end
|
data/spec/dummy/db/structure.sql
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Credential::Creation do
|
2
4
|
include_context 'Mdm::Workspace'
|
3
5
|
let(:dummy_class) {
|
4
6
|
Class.new do
|
@@ -40,7 +42,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
40
42
|
|
41
43
|
it 'replicates realm in new credential' do
|
42
44
|
expect {
|
43
|
-
test_object.create_cracked_credential(
|
45
|
+
core = test_object.create_cracked_credential(
|
44
46
|
core_id: old_core.id,
|
45
47
|
workspace_id: workspace.id,
|
46
48
|
username: public.username,
|
@@ -158,7 +160,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
158
160
|
|
159
161
|
it 'should create an Mdm::Service in state "open"' do
|
160
162
|
service = test_object.create_credential_service opts
|
161
|
-
|
163
|
+
service.state.should == "open"
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
@@ -481,7 +483,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
481
483
|
task_id: task.id
|
482
484
|
}
|
483
485
|
core = test_object.create_credential(opts)
|
484
|
-
|
486
|
+
core.tasks.should include(task)
|
485
487
|
end
|
486
488
|
|
487
489
|
end
|
@@ -524,7 +526,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
524
526
|
task_id: task.id
|
525
527
|
}
|
526
528
|
core = test_object.create_credential_core(opts)
|
527
|
-
|
529
|
+
core.tasks.should include(task)
|
528
530
|
end
|
529
531
|
|
530
532
|
end
|
@@ -561,7 +563,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
561
563
|
status: Metasploit::Model::Login::Status::SUCCESSFUL,
|
562
564
|
}
|
563
565
|
login = test_object.create_credential_login(login_data)
|
564
|
-
|
566
|
+
login.tasks.should include(task)
|
565
567
|
|
566
568
|
end
|
567
569
|
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Credential::Exporter::Core do
|
2
4
|
include_context 'Mdm::Workspace'
|
3
5
|
include_context 'export objects'
|
4
6
|
|
@@ -22,19 +24,19 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
22
24
|
end
|
23
25
|
|
24
26
|
it 'should be in LOGIN_MODE by default' do
|
25
|
-
|
27
|
+
core_exporter.mode.should == Metasploit::Credential::Exporter::Core::LOGIN_MODE
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
describe "#export!" do
|
30
32
|
it 'should create the zipfile' do
|
31
33
|
core_exporter.export!
|
32
|
-
|
34
|
+
File.exists?(core_exporter.output_zipfile_path).should be_true
|
33
35
|
end
|
34
36
|
|
35
37
|
it 'should output to a directory whose name contains the standardized identifier' do
|
36
38
|
core_exporter.export!
|
37
|
-
|
39
|
+
core_exporter.output_final_directory_path.should include(Metasploit::Credential::Exporter::Core::CREDS_DUMP_FILE_IDENTIFIER)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -44,14 +46,14 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
44
46
|
describe "when the argument is a Core" do
|
45
47
|
it 'should be formed from the Public#username and the Private#id' do
|
46
48
|
key_path = core_exporter.path_for_key(core)
|
47
|
-
|
49
|
+
Pathname.new(key_path).basename.to_s.should == key_path_basename_string
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
51
53
|
describe "when the argument is a Login" do
|
52
54
|
it 'should be formed from the Public#username and the Private#id' do
|
53
55
|
key_path = core_exporter.path_for_key(login)
|
54
|
-
|
56
|
+
Pathname.new(key_path).basename.to_s.should == key_path_basename_string
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -60,27 +62,20 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
60
62
|
let(:result_hash) { core_exporter.line_for_core(core) }
|
61
63
|
|
62
64
|
it 'should produce values in the proper order' do
|
63
|
-
|
64
|
-
|
65
|
-
core.public.username,
|
66
|
-
core.private.type,
|
67
|
-
core.private.data,
|
68
|
-
core.realm.key,
|
69
|
-
core.realm.value
|
70
|
-
]
|
71
|
-
)
|
65
|
+
result_hash.values.should == [core.public.username, core.private.type,
|
66
|
+
core.private.data, core.realm.key, core.realm.value]
|
72
67
|
end
|
73
68
|
|
74
69
|
it 'should produce a hash with the public username' do
|
75
|
-
|
70
|
+
result_hash[:username].should == core.public.username
|
76
71
|
end
|
77
72
|
|
78
73
|
it 'should produce a hash with the private data' do
|
79
|
-
|
74
|
+
result_hash[:private_data].should == core.private.data
|
80
75
|
end
|
81
76
|
|
82
77
|
it 'should produce a hash with the name of the private type' do
|
83
|
-
|
78
|
+
result_hash[:private_type].should == core.private.type
|
84
79
|
end
|
85
80
|
end
|
86
81
|
|
@@ -89,94 +84,84 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
89
84
|
let(:result_hash) { core_exporter.line_for_login(login) }
|
90
85
|
|
91
86
|
it 'should produce values in the proper order' do
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
core.realm.value,
|
99
|
-
login.service.host.address,
|
100
|
-
login.service.port,
|
101
|
-
login.service.name,
|
102
|
-
login.service.proto,
|
103
|
-
login.status,
|
104
|
-
login.access_level,
|
105
|
-
login.last_attempted_at
|
106
|
-
]
|
107
|
-
)
|
87
|
+
result_hash.values.should == [core.public.username, core.private.type,
|
88
|
+
core.private.data, core.realm.key, core.realm.value,
|
89
|
+
login.service.host.address, login.service.port,
|
90
|
+
login.service.name, login.service.proto,
|
91
|
+
login.status, login.access_level, login.last_attempted_at
|
92
|
+
]
|
108
93
|
end
|
109
94
|
|
110
95
|
it 'should produce a hash with the service host address' do
|
111
|
-
|
96
|
+
result_hash[:host_address].should == login.service.host.address
|
112
97
|
end
|
113
98
|
|
114
99
|
it 'should produce a hash with the service port' do
|
115
|
-
|
100
|
+
result_hash[:service_port].should == login.service.port
|
116
101
|
end
|
117
102
|
|
118
103
|
it 'should produce a hash with the service name' do
|
119
|
-
|
104
|
+
result_hash[:service_name].should == login.service.name
|
120
105
|
end
|
121
106
|
|
122
107
|
it 'should produce a hash with the service protocol' do
|
123
|
-
|
108
|
+
result_hash[:service_protocol].should == login.service.proto
|
124
109
|
end
|
125
110
|
|
126
111
|
it 'should produce a hash with the login status' do
|
127
|
-
|
112
|
+
result_hash[:status].should == login.status
|
128
113
|
end
|
129
114
|
|
130
115
|
it 'should produce a hash with the login access_level' do
|
131
|
-
|
116
|
+
result_hash[:access_level].should == login.access_level
|
132
117
|
end
|
133
118
|
|
134
119
|
it 'should produce a hash with the login last_attempted_at' do
|
135
|
-
|
120
|
+
result_hash[:last_attempted_at].should == login.last_attempted_at
|
136
121
|
end
|
137
122
|
|
138
123
|
it 'should produce a hash with the public information' do
|
139
|
-
|
124
|
+
result_hash[:username].should == login.core.public.username
|
140
125
|
end
|
141
126
|
|
142
127
|
it 'should produce a hash with the private data' do
|
143
|
-
|
128
|
+
result_hash[:private_data].should == login.core.private.data
|
144
129
|
end
|
145
130
|
|
146
131
|
it 'should produce a hash with the demodulized name of the private type' do
|
147
|
-
|
132
|
+
result_hash[:private_type].should == login.core.private.type
|
148
133
|
end
|
149
134
|
end
|
150
135
|
|
151
136
|
describe "#output" do
|
152
137
|
it 'should be a writable File' do
|
153
138
|
file_stat = core_exporter.output.stat
|
154
|
-
|
139
|
+
file_stat.should be_writable
|
155
140
|
end
|
156
141
|
|
157
142
|
it 'should not be opened in binmode' do
|
158
|
-
|
143
|
+
core_exporter.output.should_not be_binmode
|
159
144
|
end
|
160
145
|
end
|
161
146
|
|
162
147
|
describe "#output_directory_path" do
|
163
148
|
it 'should be in the platform-agnostic temp directory' do
|
164
|
-
|
149
|
+
core_exporter.output_final_directory_path.should include(Dir.tmpdir)
|
165
150
|
end
|
166
151
|
|
167
152
|
it 'should have the set export prefix' do
|
168
|
-
|
153
|
+
core_exporter.output_final_directory_path.should include(Metasploit::Credential::Exporter::Core::TEMP_ZIP_PATH_PREFIX)
|
169
154
|
end
|
170
155
|
|
171
156
|
describe "uniqueness for export" do
|
172
157
|
let(:path_fragment){ "export-#{Time.now.to_s}" }
|
173
158
|
|
174
159
|
before(:each) do
|
175
|
-
|
160
|
+
core_exporter.stub(:output_final_subdirectory_name).and_return(path_fragment)
|
176
161
|
end
|
177
162
|
|
178
163
|
it 'should include a special time-stamped directory to contain the export data being staged' do
|
179
|
-
|
164
|
+
core_exporter.output_final_directory_path.should include(core_exporter.output_final_subdirectory_name)
|
180
165
|
end
|
181
166
|
end
|
182
167
|
end
|
@@ -184,44 +169,44 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
184
169
|
describe "#data" do
|
185
170
|
describe "in LOGIN_MODE" do
|
186
171
|
before(:each) do
|
187
|
-
|
172
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
|
188
173
|
end
|
189
174
|
|
190
175
|
describe "when whitelist_ids is present" do
|
191
176
|
before(:each) do
|
192
|
-
|
177
|
+
core_exporter.stub(:whitelist_ids).and_return([login1.id])
|
193
178
|
end
|
194
179
|
|
195
180
|
it 'should contain only those objects whose IDs are in the whitelist' do
|
196
|
-
|
181
|
+
core_exporter.data.should_not include(login2)
|
197
182
|
end
|
198
183
|
end
|
199
184
|
|
200
185
|
describe "when whitelist_ids is blank" do
|
201
186
|
it 'should be the same as #export_data' do
|
202
|
-
|
187
|
+
core_exporter.data.should == core_exporter.export_data
|
203
188
|
end
|
204
189
|
end
|
205
190
|
end
|
206
191
|
|
207
192
|
describe "in CORE_MODE" do
|
208
193
|
before(:each) do
|
209
|
-
|
194
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
|
210
195
|
end
|
211
196
|
|
212
197
|
describe "when whitelist_ids is present" do
|
213
198
|
before(:each) do
|
214
|
-
|
199
|
+
core_exporter.stub(:whitelist_ids).and_return([core1.id])
|
215
200
|
end
|
216
201
|
|
217
202
|
it 'should contain only those objects whose IDs are in the whitelist' do
|
218
|
-
|
203
|
+
core_exporter.data.should_not include(core2)
|
219
204
|
end
|
220
205
|
end
|
221
206
|
|
222
207
|
describe "when whitelist_ids is blank" do
|
223
208
|
it 'should be the same as #export_data' do
|
224
|
-
|
209
|
+
core_exporter.data.should == core_exporter.export_data
|
225
210
|
end
|
226
211
|
end
|
227
212
|
end
|
@@ -230,22 +215,22 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
230
215
|
describe "#export_data" do
|
231
216
|
describe "in CORE_MODE" do
|
232
217
|
before(:each) do
|
233
|
-
|
218
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
|
234
219
|
end
|
235
220
|
|
236
221
|
it 'should grab data using the proper scope' do
|
237
|
-
|
222
|
+
Metasploit::Credential::Core.should_receive(:workspace_id).with(core_exporter.workspace.id)
|
238
223
|
core_exporter.export_data
|
239
224
|
end
|
240
225
|
end
|
241
226
|
|
242
227
|
describe "in LOGIN_MODE" do
|
243
228
|
before(:each) do
|
244
|
-
|
229
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
|
245
230
|
end
|
246
231
|
|
247
232
|
it 'should grab data using the proper scope' do
|
248
|
-
|
233
|
+
Metasploit::Credential::Login.should_receive(:in_workspace_including_hosts_and_services).with(core_exporter.workspace)
|
249
234
|
core_exporter.export_data
|
250
235
|
end
|
251
236
|
end
|
@@ -255,7 +240,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
255
240
|
describe "#render_manifest_and_output_keys" do
|
256
241
|
describe "in CORE_MODE" do
|
257
242
|
before(:each) do
|
258
|
-
|
243
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
|
259
244
|
core_exporter.render_manifest_output_and_keys
|
260
245
|
path = core_exporter.output_final_directory_path + '/' + Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME
|
261
246
|
|
@@ -275,34 +260,34 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
275
260
|
end
|
276
261
|
|
277
262
|
it 'should contain the Public#username for all Core objects' do
|
278
|
-
|
279
|
-
|
263
|
+
@core_publics.should include(core1.public.username)
|
264
|
+
@core_publics.should include(core2.public.username)
|
280
265
|
end
|
281
266
|
|
282
267
|
it 'should contain the Private#type for all Core objects' do
|
283
|
-
|
284
|
-
|
268
|
+
@core_private_types.should include(core1.private.type)
|
269
|
+
@core_private_types.should include(core2.private.type)
|
285
270
|
end
|
286
271
|
|
287
272
|
it 'should contain the Private#data for all Core objects' do
|
288
|
-
|
289
|
-
|
273
|
+
@core_private_data.should include(core1.private.data)
|
274
|
+
@core_private_data.should include(core2.private.data)
|
290
275
|
end
|
291
276
|
|
292
277
|
it 'should contain the Realm#key for all Core objects' do
|
293
|
-
|
294
|
-
|
278
|
+
@core_realm_keys.should include(core1.realm.key)
|
279
|
+
@core_realm_keys.should include(core2.realm.key)
|
295
280
|
end
|
296
281
|
|
297
282
|
it 'should contain the Realm#value for all Core objects' do
|
298
|
-
|
299
|
-
|
283
|
+
@core_realm_values.should include(core1.realm.value)
|
284
|
+
@core_realm_values.should include(core2.realm.value)
|
300
285
|
end
|
301
286
|
end
|
302
287
|
|
303
288
|
describe "in LOGIN_MODE" do
|
304
289
|
before(:each) do
|
305
|
-
|
290
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::LOGIN_MODE
|
306
291
|
core_exporter.render_manifest_output_and_keys
|
307
292
|
path = core_exporter.output_final_directory_path + '/' + Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME
|
308
293
|
|
@@ -331,48 +316,48 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
331
316
|
|
332
317
|
|
333
318
|
it 'should contain the Public#username for all Login objects' do
|
334
|
-
|
335
|
-
|
319
|
+
@login_publics.should include(login1.core.public.username)
|
320
|
+
@login_publics.should include(login2.core.public.username)
|
336
321
|
end
|
337
322
|
|
338
323
|
it 'should contain the Private#type for all Login objects' do
|
339
|
-
|
340
|
-
|
324
|
+
@login_private_types.should include(login1.core.private.type)
|
325
|
+
@login_private_types.should include(login2.core.private.type)
|
341
326
|
end
|
342
327
|
|
343
328
|
it 'should contain the Private#data for all Login objects' do
|
344
|
-
|
345
|
-
|
329
|
+
@login_private_data.should include(login1.core.private.data)
|
330
|
+
@login_private_data.should include(login2.core.private.data)
|
346
331
|
end
|
347
332
|
|
348
333
|
it 'should contain the Realm#key for all Login objects' do
|
349
|
-
|
350
|
-
|
334
|
+
@login_realm_keys.should include(login1.core.realm.key)
|
335
|
+
@login_realm_keys.should include(login2.core.realm.key)
|
351
336
|
end
|
352
337
|
|
353
338
|
it 'should contain the Realm#value for all Login objects' do
|
354
|
-
|
355
|
-
|
339
|
+
@login_realm_values.should include(login1.core.realm.value)
|
340
|
+
@login_realm_values.should include(login2.core.realm.value)
|
356
341
|
end
|
357
342
|
|
358
343
|
it 'should contain the associated Mdm::Host#address for all Login objects' do
|
359
|
-
|
360
|
-
|
344
|
+
@login_host_addresses.should include(login1.service.host.address)
|
345
|
+
@login_host_addresses.should include(login2.service.host.address)
|
361
346
|
end
|
362
347
|
|
363
348
|
it 'should contain the associated Mdm::Service#port (stringified) for all Login objects' do
|
364
|
-
|
365
|
-
|
349
|
+
@login_service_ports.should include(login1.service.port.to_s)
|
350
|
+
@login_service_ports.should include(login2.service.port.to_s)
|
366
351
|
end
|
367
352
|
|
368
353
|
it 'should contain the associated Mdm::Service#name for all Login objects' do
|
369
|
-
|
370
|
-
|
354
|
+
@login_service_names.should include(login1.service.name)
|
355
|
+
@login_service_names.should include(login2.service.name)
|
371
356
|
end
|
372
357
|
|
373
358
|
it 'should contain the associated Mdm::Service#proto for all Login objects' do
|
374
|
-
|
375
|
-
|
359
|
+
@login_service_protocols.should include(login1.service.proto)
|
360
|
+
@login_service_protocols.should include(login2.service.proto)
|
376
361
|
end
|
377
362
|
end
|
378
363
|
end
|
@@ -380,7 +365,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
380
365
|
describe "#render_zip" do
|
381
366
|
describe "when there are no SSH keys in the dataset" do
|
382
367
|
before(:each) do
|
383
|
-
|
368
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
|
384
369
|
core_exporter.render_manifest_output_and_keys
|
385
370
|
core_exporter.render_zip
|
386
371
|
end
|
@@ -390,7 +375,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
390
375
|
Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
|
391
376
|
manifest_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME).first
|
392
377
|
end
|
393
|
-
|
378
|
+
manifest_entry.should_not be_blank
|
394
379
|
end
|
395
380
|
|
396
381
|
it 'should not contain a keys directory' do
|
@@ -398,7 +383,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
398
383
|
Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
|
399
384
|
keys_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::KEYS_SUBDIRECTORY_NAME).first
|
400
385
|
end
|
401
|
-
|
386
|
+
keys_entry.should be_blank
|
402
387
|
end
|
403
388
|
end
|
404
389
|
|
@@ -411,7 +396,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
411
396
|
workspace: workspace)}
|
412
397
|
|
413
398
|
before(:each) do
|
414
|
-
|
399
|
+
core_exporter.stub(:mode).and_return Metasploit::Credential::Exporter::Core::CORE_MODE
|
415
400
|
core_exporter.render_manifest_output_and_keys
|
416
401
|
core_exporter.render_zip
|
417
402
|
end
|
@@ -421,7 +406,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
421
406
|
Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
|
422
407
|
manifest_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME).first
|
423
408
|
end
|
424
|
-
|
409
|
+
manifest_entry.should_not be_blank
|
425
410
|
end
|
426
411
|
|
427
412
|
it 'should contain a keys directory' do
|
@@ -429,7 +414,7 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
429
414
|
Zip::File.open(core_exporter.output_zipfile_path) do |zip_file|
|
430
415
|
keys_entry = zip_file.glob(Metasploit::Credential::Importer::Zip::KEYS_SUBDIRECTORY_NAME).first
|
431
416
|
end
|
432
|
-
|
417
|
+
keys_entry.should_not be_blank
|
433
418
|
end
|
434
419
|
|
435
420
|
describe "the keys directory" do
|
@@ -441,12 +426,12 @@ RSpec.describe Metasploit::Credential::Exporter::Core do
|
|
441
426
|
end
|
442
427
|
|
443
428
|
it 'should contain a key for each SSH private in the export' do
|
444
|
-
|
429
|
+
@key_entries.size.should == core_exporter.data[:core].select{ |d| d.private.type == Metasploit::Credential::SSHKey.name }.size
|
445
430
|
end
|
446
431
|
|
447
432
|
it 'should contain key files named with Public#username and Private#id for each Core that uses an SSHKey' do
|
448
433
|
key_names = @key_entries.map{ |e| e.to_s.gsub("#{Metasploit::Credential::Importer::Zip::KEYS_SUBDIRECTORY_NAME}/", '') }
|
449
|
-
|
434
|
+
key_names.should include("#{core_with_key.public.username}-#{core_with_key.private.id}")
|
450
435
|
end
|
451
436
|
|
452
437
|
end
|