metasploit-credential 2.0.14 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/metasploit/credential/engine.rb +2 -2
- data/lib/metasploit/credential/version.rb +3 -3
- data/spec/dummy/config/database.yml +2 -2
- data/spec/factories/metasploit/credential/blank_usernames.rb +1 -1
- data/spec/factories/metasploit/credential/cores.rb +6 -6
- data/spec/factories/metasploit/credential/importer/cores.rb +2 -2
- data/spec/factories/metasploit/credential/importer/pwdumps.rb +3 -3
- data/spec/factories/metasploit/credential/importer/zips.rb +8 -8
- data/spec/factories/metasploit/credential/logins.rb +3 -3
- data/spec/factories/metasploit/credential/nonreplayable_hashes.rb +1 -1
- data/spec/factories/metasploit/credential/ntlm_hashes.rb +1 -1
- data/spec/factories/metasploit/credential/origin/imports.rb +1 -1
- data/spec/factories/metasploit/credential/origin/manuals.rb +1 -1
- data/spec/factories/metasploit/credential/origin/services.rb +1 -1
- data/spec/factories/metasploit/credential/origin/sessions.rb +1 -1
- data/spec/factories/metasploit/credential/password_hashes.rb +1 -1
- data/spec/factories/metasploit/credential/passwords.rb +1 -1
- data/spec/factories/metasploit/credential/postgres_md5.rb +1 -1
- data/spec/factories/metasploit/credential/privates.rb +1 -1
- data/spec/factories/metasploit/credential/publics.rb +2 -2
- data/spec/factories/metasploit/credential/realms.rb +1 -1
- data/spec/factories/metasploit/credential/replayable_hashes.rb +1 -1
- data/spec/factories/metasploit/credential/ssh_keys.rb +1 -1
- data/spec/factories/metasploit/credential/usernames.rb +1 -1
- data/spec/lib/metasploit/credential/creation_spec.rb +52 -52
- data/spec/lib/metasploit/credential/exporter/core_spec.rb +3 -3
- data/spec/lib/metasploit/credential/exporter/pwdump_spec.rb +11 -11
- data/spec/lib/metasploit/credential/importer/core_spec.rb +19 -19
- data/spec/lib/metasploit/credential/importer/multi_spec.rb +4 -4
- data/spec/lib/metasploit/credential/importer/pwdump_spec.rb +3 -3
- data/spec/lib/metasploit/credential/importer/zip_spec.rb +3 -3
- data/spec/lib/metasploit/credential/migrator_spec.rb +22 -22
- data/spec/models/metasploit/credential/core_spec.rb +42 -42
- data/spec/models/metasploit/credential/login_spec.rb +20 -20
- data/spec/models/metasploit/credential/nonreplayable_hash_spec.rb +1 -1
- data/spec/models/metasploit/credential/ntlm_hash_spec.rb +5 -5
- data/spec/models/metasploit/credential/origin/import_spec.rb +1 -1
- data/spec/models/metasploit/credential/origin/manual_spec.rb +1 -1
- data/spec/models/metasploit/credential/origin/service_spec.rb +3 -3
- data/spec/models/metasploit/credential/origin/session_spec.rb +2 -2
- data/spec/models/metasploit/credential/password_hash_spec.rb +1 -1
- data/spec/models/metasploit/credential/password_spec.rb +1 -1
- data/spec/models/metasploit/credential/postgres_md5_spec.rb +3 -3
- data/spec/models/metasploit/credential/private_spec.rb +6 -6
- data/spec/models/metasploit/credential/public_spec.rb +1 -1
- data/spec/models/metasploit/credential/realm_spec.rb +9 -9
- data/spec/models/metasploit/credential/replayable_hash_spec.rb +1 -1
- data/spec/models/metasploit/credential/ssh_key_spec.rb +9 -27
- data/spec/models/metasploit/credential/username_spec.rb +1 -1
- data/spec/models/metasploit_data_models/search/visitor/relation_spec.rb +30 -30
- data/spec/support/shared/contexts/metasploit/credential/exporter/export_objects.rb +18 -18
- data/spec/support/shared/examples/core_validations.rb +38 -38
- metadata +18 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 950ddd91d6906dedbf6f98c7a30cfa16a04f5e25
|
4
|
+
data.tar.gz: 7f3b132fdddba7305aa0287bbc667e1df710fe48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 464d1f60fd21a66c76d2c10a6eccd27600bfa03678c4e4a7e1209d4af28c113982207cd16f50d8190d41d9ee19dec28e80f249f5d56c2b0da87412258f2b0f68
|
7
|
+
data.tar.gz: bc40e57d9df8fb61cacc60c37039d9e3e1deea35bab29091809415a84c8e162f5717149650bb4878cdd786ed5b3c95a760a3ddf95d76539bc8934180a2e43cb5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
@@ -29,12 +29,12 @@ class Metasploit::Credential::Engine < Rails::Engine
|
|
29
29
|
after: 'factory_girl.set_factory_paths',
|
30
30
|
# before metasploit_data_models because it prepends
|
31
31
|
before: 'metasploit_data_models.prepend_factory_path' do
|
32
|
-
if defined?
|
32
|
+
if defined? FactoryBot
|
33
33
|
relative_definition_file_path = config.generators.options[:factory_girl][:dir]
|
34
34
|
definition_file_path = root.join(relative_definition_file_path)
|
35
35
|
|
36
36
|
# unshift so that projects that use metasploit-credential can modify metasploit_credential_* factories
|
37
|
-
|
37
|
+
FactoryBot.definition_file_paths.unshift definition_file_path
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
development: &pgsql
|
2
2
|
adapter: postgresql
|
3
|
-
database: metasploit-
|
3
|
+
database: metasploit-credential_development0
|
4
4
|
username: msf
|
5
5
|
password: pass123
|
6
6
|
host: localhost
|
@@ -10,4 +10,4 @@ development: &pgsql
|
|
10
10
|
min_messages: warning
|
11
11
|
test:
|
12
12
|
<<: *pgsql
|
13
|
-
database: metasploit-
|
13
|
+
database: metasploit-credential_test0
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :metasploit_credential_core,
|
3
3
|
class: Metasploit::Credential::Core do
|
4
4
|
transient do
|
@@ -9,20 +9,20 @@ FactoryGirl.define do
|
|
9
9
|
|
10
10
|
association :public, factory: :metasploit_credential_public
|
11
11
|
|
12
|
-
origin {
|
13
|
-
private {
|
14
|
-
realm {
|
12
|
+
origin { FactoryBot.build(origin_factory) }
|
13
|
+
private { FactoryBot.build(private_factory) }
|
14
|
+
realm { FactoryBot.build(realm_factory) }
|
15
15
|
|
16
16
|
workspace {
|
17
17
|
case origin
|
18
18
|
when Metasploit::Credential::Origin::Import
|
19
|
-
|
19
|
+
FactoryBot.build(:mdm_workspace)
|
20
20
|
when Metasploit::Credential::Origin::Manual
|
21
21
|
user = origin.user
|
22
22
|
|
23
23
|
# an admin can use workspaces it is not a member of
|
24
24
|
if user.admin
|
25
|
-
|
25
|
+
FactoryBot.build(:mdm_workspace)
|
26
26
|
else
|
27
27
|
origin.user.workspaces.sample
|
28
28
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
long_form_headers = 'username,private_type,private_data,realm_key,realm_value,host_address,service_port,service_name,service_protocol,status,access_level,last_attempted_at'
|
3
3
|
short_form_headers = 'username,private_data'
|
4
4
|
login_status = Metasploit::Model::Login::Status::ALL.select {|x| x != Metasploit::Model::Login::Status::UNTRIED }.sample
|
@@ -7,7 +7,7 @@ FactoryGirl.define do
|
|
7
7
|
|
8
8
|
factory :metasploit_credential_core_importer,
|
9
9
|
class: Metasploit::Credential::Importer::Core do
|
10
|
-
origin {
|
10
|
+
origin { FactoryBot.build :metasploit_credential_origin_import }
|
11
11
|
input { generate(:well_formed_csv_compliant_header) }
|
12
12
|
end
|
13
13
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :metasploit_credential_importer_pwdump,
|
3
3
|
class: Metasploit::Credential::Importer::Pwdump do
|
4
4
|
filename "pwdump-import-#{Time.now.to_i}"
|
5
|
-
origin {
|
6
|
-
input {
|
5
|
+
origin {FactoryBot.build :metasploit_credential_origin_import }
|
6
|
+
input { FactoryBot.generate(:wellformed_pwdump) }
|
7
7
|
end
|
8
8
|
|
9
9
|
# Represents a file that should do an error-free import
|
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
require 'zip'
|
6
6
|
|
7
|
-
|
7
|
+
FactoryBot.define do
|
8
8
|
factory :metasploit_credential_importer_zip,
|
9
9
|
class: Metasploit::Credential::Importer::Zip do
|
10
10
|
input { generate :metasploit_credential_importer_zip_file }
|
11
|
-
origin {
|
11
|
+
origin {FactoryBot.build :metasploit_credential_origin_import }
|
12
12
|
end
|
13
13
|
|
14
14
|
|
@@ -29,12 +29,12 @@ FactoryGirl.define do
|
|
29
29
|
|
30
30
|
# Create keys
|
31
31
|
key_data = 5.times.collect do
|
32
|
-
|
32
|
+
FactoryBot.build(:metasploit_credential_ssh_key).data
|
33
33
|
end
|
34
34
|
|
35
35
|
# associate keys with usernames
|
36
36
|
csv_hash = key_data.inject({}) do |hash, data|
|
37
|
-
username =
|
37
|
+
username = FactoryBot.generate(:metasploit_credential_public_username)
|
38
38
|
hash[username] = data
|
39
39
|
hash
|
40
40
|
end
|
@@ -77,12 +77,12 @@ FactoryGirl.define do
|
|
77
77
|
|
78
78
|
# Create keys
|
79
79
|
key_data = 5.times.collect do
|
80
|
-
|
80
|
+
FactoryBot.build(:metasploit_credential_ssh_key).data
|
81
81
|
end
|
82
82
|
|
83
83
|
# associate keys with usernames
|
84
84
|
csv_hash = key_data.inject({}) do |hash, data|
|
85
|
-
username =
|
85
|
+
username = FactoryBot.generate(:metasploit_credential_public_username)
|
86
86
|
hash[username] = data
|
87
87
|
hash
|
88
88
|
end
|
@@ -121,12 +121,12 @@ FactoryGirl.define do
|
|
121
121
|
|
122
122
|
# Create keys
|
123
123
|
key_data = 5.times.collect do
|
124
|
-
|
124
|
+
FactoryBot.build(:metasploit_credential_ssh_key).data
|
125
125
|
end
|
126
126
|
|
127
127
|
# associate keys with usernames
|
128
128
|
csv_hash = key_data.inject({}) do |hash, data|
|
129
|
-
username =
|
129
|
+
username = FactoryBot.generate(:metasploit_credential_public_username)
|
130
130
|
hash[username] = data
|
131
131
|
hash
|
132
132
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :metasploit_credential_login,
|
3
3
|
class: Metasploit::Credential::Login do
|
4
4
|
transient do
|
5
5
|
host {
|
6
|
-
|
6
|
+
FactoryBot.build(
|
7
7
|
:mdm_host, workspace: workspace
|
8
8
|
)
|
9
9
|
}
|
@@ -20,7 +20,7 @@ FactoryGirl.define do
|
|
20
20
|
end
|
21
21
|
}
|
22
22
|
service {
|
23
|
-
|
23
|
+
FactoryBot.build(
|
24
24
|
:mdm_service,
|
25
25
|
host: host
|
26
26
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :metasploit_credential_password_hash,
|
3
3
|
# no need to declare metasploit_credential_private as the :parent because :metasploit_credential_password_hash
|
4
4
|
# uses its own data sequence to differentiate password hashes from other private data and #type is
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :metasploit_credential_password,
|
3
3
|
# no need to declare metasploit_credential_private as the :parent because :metasploit_credential_password uses
|
4
4
|
# its own data sequence to differentiate passwords from other private data and #type is automatically
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :metasploit_credential_public,
|
3
3
|
class: Metasploit::Credential::Username do
|
4
4
|
transient do
|
@@ -17,7 +17,7 @@ FactoryGirl.define do
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
initialize_with {
|
20
|
+
initialize_with { FactoryBot.build(public_factory, username: username) }
|
21
21
|
end
|
22
22
|
|
23
23
|
sequence :metasploit_credential_public_username do |n|
|
@@ -6,20 +6,20 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
6
6
|
end
|
7
7
|
}
|
8
8
|
|
9
|
-
let(:session) {
|
9
|
+
let(:session) { FactoryBot.create(:mdm_session) }
|
10
10
|
|
11
|
-
let(:task) {
|
11
|
+
let(:task) { FactoryBot.create(:mdm_task, workspace: workspace)}
|
12
12
|
|
13
|
-
let(:user) {
|
13
|
+
let(:user) { FactoryBot.create(:mdm_user)}
|
14
14
|
|
15
|
-
let(:workspace) {
|
15
|
+
let(:workspace) { FactoryBot.create(:mdm_workspace) }
|
16
16
|
|
17
17
|
subject(:test_object) { dummy_class.new }
|
18
|
-
|
18
|
+
|
19
19
|
context '#create_credential' do
|
20
|
-
let(:workspace) {
|
21
|
-
let(:service) {
|
22
|
-
let(:task) {
|
20
|
+
let(:workspace) { FactoryBot.create(:mdm_workspace) }
|
21
|
+
let(:service) { FactoryBot.create(:mdm_service, host: FactoryBot.create(:mdm_host, workspace: workspace)) }
|
22
|
+
let(:task) { FactoryBot.create(:mdm_task, workspace: workspace) }
|
23
23
|
{
|
24
24
|
cracked_password: Metasploit::Credential::Origin::CrackedPassword,
|
25
25
|
import: Metasploit::Credential::Origin::Import,
|
@@ -28,26 +28,26 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
28
28
|
session: Metasploit::Credential::Origin::Session
|
29
29
|
}.each_pair do |origin_type, origin_class|
|
30
30
|
context "Origin[#{origin_type}], Public[Username], Private[Password]" do
|
31
|
-
let(:service) {
|
31
|
+
let(:service) { FactoryBot.create(:mdm_service) }
|
32
32
|
let!(:origin_data) {{
|
33
33
|
cracked_password: {
|
34
|
-
originating_core_id:
|
34
|
+
originating_core_id: FactoryBot.create(
|
35
35
|
:metasploit_credential_core, workspace: workspace, origin_factory: :metasploit_credential_origin_manual).id
|
36
36
|
},
|
37
37
|
import: {
|
38
|
-
filename:
|
38
|
+
filename: FactoryBot.generate(:metasploit_credential_origin_import_filename)
|
39
39
|
},
|
40
40
|
manual: {user_id: user.id},
|
41
41
|
service: {
|
42
|
-
module_fullname: "exploit/" +
|
42
|
+
module_fullname: "exploit/" + FactoryBot.generate(:metasploit_credential_origin_service_reference_name),
|
43
43
|
address: service.host.address,
|
44
44
|
port: service.port,
|
45
45
|
service_name: service.name,
|
46
46
|
protocol: service.proto
|
47
47
|
},
|
48
48
|
session: {
|
49
|
-
session_id:
|
50
|
-
post_reference_name:
|
49
|
+
session_id: FactoryBot.create(:mdm_session, workspace: workspace, host: service.host),
|
50
|
+
post_reference_name: FactoryBot.generate(:metasploit_credential_origin_session_post_reference_name)
|
51
51
|
}
|
52
52
|
}}
|
53
53
|
let(:credential_data) {{
|
@@ -129,7 +129,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
129
129
|
it 'creates a Public with username \'username\'' do
|
130
130
|
expect{ test_object.create_credential(credential_data) }.to change{ Metasploit::Credential::Public.where(type: public_type).count }.by(1)
|
131
131
|
end
|
132
|
-
end
|
132
|
+
end
|
133
133
|
end
|
134
134
|
{
|
135
135
|
password: "Metasploit::Credential::Password",
|
@@ -170,14 +170,14 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
170
170
|
it 'creates a Public with username \'username\'' do
|
171
171
|
expect{ test_object.create_credential(credential_data) }.to change{ Metasploit::Credential::Public.where(username: 'admin').count }.by(1)
|
172
172
|
end
|
173
|
-
end
|
173
|
+
end
|
174
174
|
end
|
175
175
|
end
|
176
|
-
|
176
|
+
|
177
177
|
context '#create_credential_and_login' do
|
178
|
-
let(:workspace) {
|
179
|
-
let(:service) {
|
180
|
-
let(:task) {
|
178
|
+
let(:workspace) { FactoryBot.create(:mdm_workspace) }
|
179
|
+
let(:service) { FactoryBot.create(:mdm_service, host: FactoryBot.create(:mdm_host, workspace: workspace)) }
|
180
|
+
let(:task) { FactoryBot.create(:mdm_task, workspace: workspace) }
|
181
181
|
{
|
182
182
|
cracked_password: Metasploit::Credential::Origin::CrackedPassword,
|
183
183
|
import: Metasploit::Credential::Origin::Import,
|
@@ -188,23 +188,23 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
188
188
|
context "Origin[#{origin_type}], Public[Username], Private[Password]" do
|
189
189
|
let!(:origin_data) {{
|
190
190
|
cracked_password: {
|
191
|
-
originating_core_id:
|
191
|
+
originating_core_id: FactoryBot.create(
|
192
192
|
:metasploit_credential_core, workspace: workspace, origin_factory: :metasploit_credential_origin_manual).id
|
193
193
|
},
|
194
194
|
import: {
|
195
|
-
filename:
|
195
|
+
filename: FactoryBot.generate(:metasploit_credential_origin_import_filename)
|
196
196
|
},
|
197
197
|
manual: {user_id: user.id},
|
198
198
|
service: {
|
199
|
-
module_fullname: "exploit/" +
|
199
|
+
module_fullname: "exploit/" + FactoryBot.generate(:metasploit_credential_origin_service_reference_name),
|
200
200
|
address: service.host.address,
|
201
201
|
port: service.port,
|
202
202
|
service_name: service.name,
|
203
203
|
protocol: service.proto
|
204
204
|
},
|
205
205
|
session: {
|
206
|
-
session_id:
|
207
|
-
post_reference_name:
|
206
|
+
session_id: FactoryBot.create(:mdm_session, workspace: workspace, host: service.host),
|
207
|
+
post_reference_name: FactoryBot.generate(:metasploit_credential_origin_session_post_reference_name)
|
208
208
|
}
|
209
209
|
}}
|
210
210
|
let(:login_data) {{
|
@@ -281,7 +281,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
281
281
|
end
|
282
282
|
end
|
283
283
|
end
|
284
|
-
|
284
|
+
|
285
285
|
{
|
286
286
|
"Metasploit::Credential::Username" => 'admin',
|
287
287
|
"Metasploit::Credential::BlankUsername" => ''
|
@@ -314,7 +314,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
314
314
|
it 'creates a Login with status for the service' do
|
315
315
|
expect{ test_object.create_credential_and_login(login_data) }.to change{ Metasploit::Credential::Login.where(service_id: service.id, status: login_data[:status]).count }.by(1)
|
316
316
|
end
|
317
|
-
end
|
317
|
+
end
|
318
318
|
end
|
319
319
|
{
|
320
320
|
password: "Metasploit::Credential::Password",
|
@@ -364,19 +364,19 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
364
364
|
it 'creates a Login with status for the service' do
|
365
365
|
expect{ test_object.create_credential_and_login(login_data) }.to change{ Metasploit::Credential::Login.where(service_id: service.id, status: login_data[:status]).count }.by(1)
|
366
366
|
end
|
367
|
-
end
|
367
|
+
end
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
371
371
|
context '#create_cracked_credential' do
|
372
|
-
let(:public) {
|
373
|
-
let(:hash) {
|
374
|
-
let(:origin) {
|
372
|
+
let(:public) { FactoryBot.create(:metasploit_credential_public) }
|
373
|
+
let(:hash) { FactoryBot.create(:metasploit_credential_nonreplayable_hash) }
|
374
|
+
let(:origin) { FactoryBot.create(:metasploit_credential_origin_manual) }
|
375
375
|
let(:password) { "omgwtfbbq" }
|
376
|
-
let(:realm) {
|
376
|
+
let(:realm) { FactoryBot.create(:metasploit_credential_realm) }
|
377
377
|
|
378
378
|
let!(:old_core) do
|
379
|
-
|
379
|
+
FactoryBot.create(:metasploit_credential_core, public: public, private: hash, realm: realm, workspace: workspace, origin: origin)
|
380
380
|
end
|
381
381
|
|
382
382
|
it 'creates a Core' do
|
@@ -403,11 +403,11 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
403
403
|
end
|
404
404
|
|
405
405
|
context 'when previous core has logins' do
|
406
|
-
let(:host) {
|
407
|
-
let(:service) {
|
406
|
+
let(:host) { FactoryBot.create(:mdm_host, workspace: workspace) }
|
407
|
+
let(:service) { FactoryBot.create(:mdm_service, host: host) }
|
408
408
|
|
409
409
|
before do
|
410
|
-
|
410
|
+
FactoryBot.create(:metasploit_credential_login,
|
411
411
|
service: service,
|
412
412
|
core: old_core,
|
413
413
|
status: Metasploit::Model::Login::Status::UNTRIED
|
@@ -545,7 +545,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
545
545
|
workspace_id: workspace.id,
|
546
546
|
origin_type: :service
|
547
547
|
}
|
548
|
-
|
548
|
+
FactoryBot.create(:mdm_host, address: opts[:address], workspace_id: opts[:workspace_id])
|
549
549
|
expect { test_object.create_credential_origin_service(opts)}.to_not change{Mdm::Host.count }
|
550
550
|
end
|
551
551
|
end
|
@@ -576,8 +576,8 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
576
576
|
workspace_id: workspace.id,
|
577
577
|
origin_type: :service
|
578
578
|
}
|
579
|
-
host =
|
580
|
-
|
579
|
+
host = FactoryBot.create(:mdm_host, address: opts[:address], workspace_id: opts[:workspace_id])
|
580
|
+
FactoryBot.create(:mdm_service, host_id: host.id, port: opts[:port], proto: opts[:protocol])
|
581
581
|
expect { test_object.create_credential_origin_service(opts)}.to_not change{Mdm::Service.count }
|
582
582
|
end
|
583
583
|
end
|
@@ -822,12 +822,12 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
822
822
|
end
|
823
823
|
|
824
824
|
context '#create_credential_core' do
|
825
|
-
let(:origin) {
|
826
|
-
let(:public) {
|
827
|
-
let(:private) {
|
828
|
-
let(:realm) {
|
825
|
+
let(:origin) { FactoryBot.create(:metasploit_credential_origin_service) }
|
826
|
+
let(:public) { FactoryBot.create(:metasploit_credential_public)}
|
827
|
+
let(:private) { FactoryBot.create(:metasploit_credential_password)}
|
828
|
+
let(:realm) { FactoryBot.create(:metasploit_credential_realm)}
|
829
829
|
let(:workspace) { origin.service.host.workspace }
|
830
|
-
let(:task) {
|
830
|
+
let(:task) { FactoryBot.create(:mdm_task, workspace: workspace) }
|
831
831
|
|
832
832
|
it 'raises a KeyError if any required option is missing' do
|
833
833
|
opts = {}
|
@@ -865,10 +865,10 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
865
865
|
end
|
866
866
|
|
867
867
|
context '#create_credential_login' do
|
868
|
-
let(:workspace) {
|
869
|
-
let(:service) {
|
870
|
-
let(:task) {
|
871
|
-
let(:credential_core) {
|
868
|
+
let(:workspace) { FactoryBot.create(:mdm_workspace) }
|
869
|
+
let(:service) { FactoryBot.create(:mdm_service, host: FactoryBot.create(:mdm_host, workspace: workspace)) }
|
870
|
+
let(:task) { FactoryBot.create(:mdm_task, workspace: workspace) }
|
871
|
+
let(:credential_core) { FactoryBot.create(:metasploit_credential_core_manual, workspace: workspace) }
|
872
872
|
|
873
873
|
it 'creates a Metasploit::Credential::Login' do
|
874
874
|
login_data = {
|
@@ -905,7 +905,7 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
905
905
|
context '#invalidate_login' do
|
906
906
|
|
907
907
|
context 'when an untried login exists' do
|
908
|
-
let(:untried_login) {
|
908
|
+
let(:untried_login) { FactoryBot.create(:metasploit_credential_login, status: Metasploit::Model::Login::Status::UNTRIED)}
|
909
909
|
|
910
910
|
let(:opts) {{
|
911
911
|
address: untried_login.service.host.address.to_s,
|
@@ -928,16 +928,16 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
928
928
|
|
929
929
|
context 'when a login exists on the same service for a different credential' do
|
930
930
|
let(:other_origin) {
|
931
|
-
|
931
|
+
FactoryBot.create(:metasploit_credential_origin_manual)
|
932
932
|
}
|
933
933
|
let(:other_core) {
|
934
|
-
|
934
|
+
FactoryBot.create(:metasploit_credential_core,
|
935
935
|
workspace: untried_login.core.workspace,
|
936
936
|
origin: other_origin
|
937
937
|
)
|
938
938
|
}
|
939
939
|
let(:other_login) {
|
940
|
-
|
940
|
+
FactoryBot.create(:metasploit_credential_login,
|
941
941
|
status: Metasploit::Model::Login::Status::UNTRIED,
|
942
942
|
service: untried_login.service,
|
943
943
|
core: other_core
|