metasploit-credential 0.14.0 → 0.14.1
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/app/models/metasploit/credential/postgres_md5.rb +41 -0
- data/lib/metasploit/credential/creation.rb +3 -0
- data/lib/metasploit/credential/version.rb +1 -1
- data/lib/metasploit/credential/version.rb.orig +49 -0
- data/spec/dummy/config/database.yml +3 -0
- data/spec/dummy/config/environments/test.rb +0 -2
- data/spec/dummy/db/structure.sql +11 -1
- data/spec/dummy/db/structure.sql.orig +3699 -0
- data/spec/factories/metasploit/credential/cores.rb +5 -5
- data/spec/factories/metasploit/credential/logins.rb +1 -1
- data/spec/factories/metasploit/credential/origin/services.rb +1 -1
- data/spec/factories/metasploit/credential/password_hashes.rb +1 -1
- data/spec/factories/metasploit/credential/postgres_md5.rb +11 -0
- data/spec/factories/metasploit/credential/publics.rb +1 -1
- data/spec/factories/metasploit/credential/ssh_keys.rb +3 -3
- data/spec/models/metasploit/credential/postgres_md5_spec.rb +124 -0
- metadata +10 -2
@@ -1,7 +1,7 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :metasploit_credential_core,
|
3
3
|
class: Metasploit::Credential::Core do
|
4
|
-
|
4
|
+
transient do
|
5
5
|
origin_factory { generate :metasploit_credential_core_origin_factory }
|
6
6
|
private_factory { generate :metasploit_credential_core_private_factory }
|
7
7
|
realm_factory { generate :metasploit_credential_core_realm_factory }
|
@@ -34,25 +34,25 @@ FactoryGirl.define do
|
|
34
34
|
}
|
35
35
|
|
36
36
|
factory :metasploit_credential_core_import do
|
37
|
-
|
37
|
+
transient do
|
38
38
|
origin_factory :metasploit_credential_origin_import
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
factory :metasploit_credential_core_manual do
|
43
|
-
|
43
|
+
transient do
|
44
44
|
origin_factory :metasploit_credential_origin_manual
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
factory :metasploit_credential_core_service do
|
49
|
-
|
49
|
+
transient do
|
50
50
|
origin_factory :metasploit_credential_origin_service
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
factory :metasploit_credential_core_session do
|
55
|
-
|
55
|
+
transient do
|
56
56
|
origin_factory :metasploit_credential_origin_session
|
57
57
|
end
|
58
58
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :metasploit_credential_origin_service,
|
3
3
|
class: Metasploit::Credential::Origin::Service do
|
4
|
-
|
4
|
+
transient do
|
5
5
|
module_type { generate :metasploit_credential_origin_service_module_type }
|
6
6
|
reference_name { generate :metasploit_credential_origin_service_reference_name }
|
7
7
|
end
|
@@ -4,7 +4,7 @@ FactoryGirl.define do
|
|
4
4
|
# uses its own data sequence to differentiate password hashes from other private data and #type is
|
5
5
|
# automatically set by ActiveRecord because Metasploit::Credential::Password is an STI subclass.
|
6
6
|
class: Metasploit::Credential::Password do
|
7
|
-
|
7
|
+
transient do
|
8
8
|
password_data { generate :metasploit_credential_password_data }
|
9
9
|
end
|
10
10
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
FactoryGirl.define do
|
2
2
|
factory :metasploit_credential_ssh_key,
|
3
3
|
class: Metasploit::Credential::SSHKey do
|
4
|
-
|
4
|
+
transient do
|
5
5
|
key_type { generate :metasploit_credential_ssh_key_key_type }
|
6
6
|
# key size tuned for speed. DO NOT use for production, it is below current recommended key size of 2048
|
7
7
|
key_size { 512 }
|
@@ -13,13 +13,13 @@ FactoryGirl.define do
|
|
13
13
|
}
|
14
14
|
|
15
15
|
factory :metasploit_credential_dsa_key do
|
16
|
-
|
16
|
+
transient do
|
17
17
|
key_type :DSA
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
factory :metasploit_credential_rsa_key do
|
22
|
-
|
22
|
+
transient do
|
23
23
|
key_type :RSA
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Credential::PostgresMD5 do
|
4
|
+
it_should_behave_like 'Metasploit::Concern.run'
|
5
|
+
|
6
|
+
it { should be_a Metasploit::Credential::ReplayableHash }
|
7
|
+
|
8
|
+
context 'CONSTANTS' do
|
9
|
+
context 'DATA_REGEXP' do
|
10
|
+
subject(:data_regexp) do
|
11
|
+
described_class::DATA_REGEXP
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'is valid if the string is md5 and 32 hex chars' do
|
15
|
+
hash = "md5#{SecureRandom.hex(16)}"
|
16
|
+
expect(data_regexp).to match(hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'is not valid if it does not start with md5' do
|
20
|
+
expect(data_regexp).not_to match(SecureRandom.hex(16))
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'is not valid for an invalid length' do
|
24
|
+
expect(data_regexp).not_to match(SecureRandom.hex(6))
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'is not valid if it is not hex chars after the md5 tag' do
|
28
|
+
bogus = "md5#{SecureRandom.hex(15)}jk"
|
29
|
+
expect(data_regexp).not_to match(bogus)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'callbacks' do
|
36
|
+
context 'before_validation' do
|
37
|
+
context '#data' do
|
38
|
+
subject(:data) do
|
39
|
+
postgres_md5.data
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:postgres_md5) do
|
43
|
+
FactoryGirl.build(
|
44
|
+
:metasploit_credential_postgres_md5,
|
45
|
+
data: given_data
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
before(:each) do
|
50
|
+
postgres_md5.valid?
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with nil' do
|
54
|
+
let(:given_data) do
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it { should be_nil }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'with upper case characters' do
|
62
|
+
let(:given_data) do
|
63
|
+
'ABCDEF1234567890'
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'makes them lower case' do
|
67
|
+
expect(data).to eq(given_data.downcase)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with all lower case characters' do
|
72
|
+
let(:given_data) do
|
73
|
+
'abcdef1234567890'
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'does not change the case' do
|
77
|
+
expect(data).to eq(given_data)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'factories' do
|
85
|
+
context 'metasploit_credential_ntlm_hash' do
|
86
|
+
subject(:metasploit_credential_postgres_md5) do
|
87
|
+
FactoryGirl.build(:metasploit_credential_postgres_md5)
|
88
|
+
end
|
89
|
+
|
90
|
+
it { should be_valid }
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'validations' do
|
95
|
+
context '#data_format' do
|
96
|
+
subject(:data_errors) do
|
97
|
+
postgres_md5.errors[:data]
|
98
|
+
end
|
99
|
+
|
100
|
+
let(:data) { "md5#{SecureRandom.hex(16)}" }
|
101
|
+
|
102
|
+
let(:postgres_md5) do
|
103
|
+
FactoryGirl.build(
|
104
|
+
:metasploit_credential_postgres_md5,
|
105
|
+
data: data
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'with a valid postgres md5 hash' do
|
110
|
+
it 'should be valid' do
|
111
|
+
expect(postgres_md5).to be_valid
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'with an invalid postgres md5 hash' do
|
116
|
+
let(:data) { "invalidstring" }
|
117
|
+
it 'should not be valid' do
|
118
|
+
expect(postgres_md5).to_not be_valid
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metasploit-credential
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Imhoff
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: metasploit-concern
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- app/models/metasploit/credential/origin/session.rb
|
144
144
|
- app/models/metasploit/credential/password.rb
|
145
145
|
- app/models/metasploit/credential/password_hash.rb
|
146
|
+
- app/models/metasploit/credential/postgres_md5.rb
|
146
147
|
- app/models/metasploit/credential/private.rb
|
147
148
|
- app/models/metasploit/credential/public.rb
|
148
149
|
- app/models/metasploit/credential/realm.rb
|
@@ -193,6 +194,7 @@ files:
|
|
193
194
|
- lib/metasploit/credential/origin.rb
|
194
195
|
- lib/metasploit/credential/text.rb
|
195
196
|
- lib/metasploit/credential/version.rb
|
197
|
+
- lib/metasploit/credential/version.rb.orig
|
196
198
|
- lib/tasks/databases.rake
|
197
199
|
- lib/tasks/yard.rake
|
198
200
|
- spec/dummy/README.rdoc
|
@@ -221,6 +223,7 @@ files:
|
|
221
223
|
- spec/dummy/config/locales/en.yml
|
222
224
|
- spec/dummy/config/routes.rb
|
223
225
|
- spec/dummy/db/structure.sql
|
226
|
+
- spec/dummy/db/structure.sql.orig
|
224
227
|
- spec/dummy/public/404.html
|
225
228
|
- spec/dummy/public/422.html
|
226
229
|
- spec/dummy/public/500.html
|
@@ -240,6 +243,7 @@ files:
|
|
240
243
|
- spec/factories/metasploit/credential/origin/sessions.rb
|
241
244
|
- spec/factories/metasploit/credential/password_hashes.rb
|
242
245
|
- spec/factories/metasploit/credential/passwords.rb
|
246
|
+
- spec/factories/metasploit/credential/postgres_md5.rb
|
243
247
|
- spec/factories/metasploit/credential/privates.rb
|
244
248
|
- spec/factories/metasploit/credential/publics.rb
|
245
249
|
- spec/factories/metasploit/credential/realms.rb
|
@@ -274,6 +278,7 @@ files:
|
|
274
278
|
- spec/models/metasploit/credential/origin/session_spec.rb
|
275
279
|
- spec/models/metasploit/credential/password_hash_spec.rb
|
276
280
|
- spec/models/metasploit/credential/password_spec.rb
|
281
|
+
- spec/models/metasploit/credential/postgres_md5_spec.rb
|
277
282
|
- spec/models/metasploit/credential/private_spec.rb
|
278
283
|
- spec/models/metasploit/credential/public_spec.rb
|
279
284
|
- spec/models/metasploit/credential/realm_spec.rb
|
@@ -341,6 +346,7 @@ test_files:
|
|
341
346
|
- spec/dummy/config/locales/en.yml
|
342
347
|
- spec/dummy/config/routes.rb
|
343
348
|
- spec/dummy/db/structure.sql
|
349
|
+
- spec/dummy/db/structure.sql.orig
|
344
350
|
- spec/dummy/public/404.html
|
345
351
|
- spec/dummy/public/422.html
|
346
352
|
- spec/dummy/public/500.html
|
@@ -360,6 +366,7 @@ test_files:
|
|
360
366
|
- spec/factories/metasploit/credential/origin/sessions.rb
|
361
367
|
- spec/factories/metasploit/credential/password_hashes.rb
|
362
368
|
- spec/factories/metasploit/credential/passwords.rb
|
369
|
+
- spec/factories/metasploit/credential/postgres_md5.rb
|
363
370
|
- spec/factories/metasploit/credential/privates.rb
|
364
371
|
- spec/factories/metasploit/credential/publics.rb
|
365
372
|
- spec/factories/metasploit/credential/realms.rb
|
@@ -394,6 +401,7 @@ test_files:
|
|
394
401
|
- spec/models/metasploit/credential/origin/session_spec.rb
|
395
402
|
- spec/models/metasploit/credential/password_hash_spec.rb
|
396
403
|
- spec/models/metasploit/credential/password_spec.rb
|
404
|
+
- spec/models/metasploit/credential/postgres_md5_spec.rb
|
397
405
|
- spec/models/metasploit/credential/private_spec.rb
|
398
406
|
- spec/models/metasploit/credential/public_spec.rb
|
399
407
|
- spec/models/metasploit/credential/realm_spec.rb
|