metasploit-credential 6.0.12 → 6.0.14
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/README.md +1 -1
- data/app/models/metasploit/credential/pkcs12.rb +51 -2
- data/app/models/metasploit/credential/private.rb +8 -0
- data/config/locales/en.yml +1 -1
- data/db/migrate/20250204172657_add_metadata_to_metasploit_credential_privates.rb +5 -0
- data/lib/metasploit/credential/creation.rb +1 -1
- data/lib/metasploit/credential/version.rb +1 -1
- data/spec/dummy/config/database.yml +4 -2
- data/spec/dummy/db/structure.sql +81 -2
- data/spec/factories/metasploit/credential/pkcs12.rb +66 -6
- data/spec/lib/metasploit/credential/creation_spec.rb +25 -2
- data/spec/models/metasploit/credential/pkcs12_spec.rb +238 -0
- data/spec/models/metasploit/credential/private_spec.rb +9 -0
- metadata +8 -33
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b08c247237833c0a93eee32f6d14a678a2f320d46827eec1553d999e2601447
|
4
|
+
data.tar.gz: 8c446fa6be10d1040cb8bbcdee59fc6be9cc167bcc569d4e608ac80aafbc4b01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5922d220d8a3614d21b3a6a4639527b0d0486dac4edf6d7832f9e0354274b5b3903d6ab6049722ff3ec66f5ec7bd2aedb09155980f49582307c54f08f9efe5d0
|
7
|
+
data.tar.gz: 40dbe1b8f9ebf70be13840c791ffc05149759e44347a08946291b4c0e76b3450a4fc718910b20d7585509731d8d4432a52dbaa5067726fefd68cd475dc118bcf
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Metasploit::Credential [](https://github.com/rapid7/metasploit-credential/actions/workflows/verify.yml)[](https://github.com/rapid7/metasploit-credential/actions/workflows/verify.yml)[](https://gemnasium.com/rapid7/metasploit-credential)[](http://badge.fury.io/rb/metasploit-credential)[](http://inch-ci.org/github/rapid7/metasploit-credential)
|
2
2
|
|
3
3
|
## Versioning
|
4
4
|
|
@@ -3,6 +3,7 @@ require 'base64'
|
|
3
3
|
|
4
4
|
# A private Pkcs12 file.
|
5
5
|
class Metasploit::Credential::Pkcs12 < Metasploit::Credential::Private
|
6
|
+
|
6
7
|
#
|
7
8
|
# Attributes
|
8
9
|
#
|
@@ -12,6 +13,14 @@ class Metasploit::Credential::Pkcs12 < Metasploit::Credential::Private
|
|
12
13
|
#
|
13
14
|
# @return [String]
|
14
15
|
|
16
|
+
# @!attribute metadata
|
17
|
+
# Metadata for this Pkcs12:
|
18
|
+
# adcs_ca: The Certificate Authority that issued the certificate
|
19
|
+
# adcs_template: The certificate template used to issue the certificate
|
20
|
+
# pkcs12_password: The password to decrypt the Pkcs12
|
21
|
+
#
|
22
|
+
# @return [JSONB]
|
23
|
+
|
15
24
|
#
|
16
25
|
#
|
17
26
|
# Validations
|
@@ -24,15 +33,49 @@ class Metasploit::Credential::Pkcs12 < Metasploit::Credential::Private
|
|
24
33
|
|
25
34
|
validates :data,
|
26
35
|
presence: true
|
36
|
+
|
27
37
|
#
|
28
38
|
# Method Validations
|
29
39
|
#
|
30
40
|
|
31
41
|
validate :readable
|
32
42
|
|
43
|
+
#
|
44
|
+
# Class methods
|
45
|
+
#
|
46
|
+
|
33
47
|
#
|
34
48
|
# Instance Methods
|
35
49
|
#
|
50
|
+
#
|
51
|
+
|
52
|
+
# The CA that issued the certificate
|
53
|
+
#
|
54
|
+
# @return [String]
|
55
|
+
def adcs_ca
|
56
|
+
metadata['adcs_ca']
|
57
|
+
end
|
58
|
+
|
59
|
+
# The certificate template used to issue the certificate
|
60
|
+
#
|
61
|
+
# @return [String]
|
62
|
+
def adcs_template
|
63
|
+
metadata['adcs_template']
|
64
|
+
end
|
65
|
+
|
66
|
+
# The password to decrypt the Pkcs12
|
67
|
+
#
|
68
|
+
# @return [String]
|
69
|
+
def pkcs12_password
|
70
|
+
metadata['pkcs12_password']
|
71
|
+
end
|
72
|
+
|
73
|
+
# The status if the certificate (active or inactive)
|
74
|
+
#
|
75
|
+
# @return [String]
|
76
|
+
def status
|
77
|
+
metadata['status']
|
78
|
+
end
|
36
79
|
|
37
80
|
# Converts the private pkcs12 data in {#data} to an `OpenSSL::PKCS12` instance.
|
38
81
|
#
|
@@ -41,7 +84,7 @@ class Metasploit::Credential::Pkcs12 < Metasploit::Credential::Private
|
|
41
84
|
def openssl_pkcs12
|
42
85
|
if data
|
43
86
|
begin
|
44
|
-
password = ''
|
87
|
+
password = metadata.fetch('pkcs12_password', '')
|
45
88
|
OpenSSL::PKCS12.new(Base64.strict_decode64(data), password)
|
46
89
|
rescue OpenSSL::PKCS12::PKCS12Error => error
|
47
90
|
raise ArgumentError.new(error)
|
@@ -50,7 +93,7 @@ class Metasploit::Credential::Pkcs12 < Metasploit::Credential::Private
|
|
50
93
|
end
|
51
94
|
|
52
95
|
# The {#data key data}'s fingerprint, suitable for displaying to the
|
53
|
-
# user.
|
96
|
+
# user. The Pkcs12 password is voluntarily not included.
|
54
97
|
#
|
55
98
|
# @return [String]
|
56
99
|
def to_s
|
@@ -60,9 +103,12 @@ class Metasploit::Credential::Pkcs12 < Metasploit::Credential::Private
|
|
60
103
|
result = []
|
61
104
|
result << "subject:#{cert.subject.to_s}"
|
62
105
|
result << "issuer:#{cert.issuer.to_s}"
|
106
|
+
result << "ADCS CA:#{metadata['adcs_ca']}" if metadata['adcs_ca']
|
107
|
+
result << "ADCS template:#{metadata['adcs_template']}" if metadata['adcs_template']
|
63
108
|
result.join(',')
|
64
109
|
end
|
65
110
|
|
111
|
+
|
66
112
|
private
|
67
113
|
|
68
114
|
#
|
@@ -80,5 +126,8 @@ class Metasploit::Credential::Pkcs12 < Metasploit::Credential::Private
|
|
80
126
|
end
|
81
127
|
end
|
82
128
|
|
129
|
+
|
130
|
+
public
|
131
|
+
|
83
132
|
Metasploit::Concern.run(self)
|
84
133
|
end
|
@@ -50,6 +50,11 @@ class Metasploit::Credential::Private < ApplicationRecord
|
|
50
50
|
#
|
51
51
|
# @return [DateTime]
|
52
52
|
|
53
|
+
# @!attribute metadata
|
54
|
+
# Metadata related to the private data. The data contained in this JSONB structure varies based on the subclass.
|
55
|
+
#
|
56
|
+
# @return [JSONB]
|
57
|
+
|
53
58
|
#
|
54
59
|
#
|
55
60
|
# Search
|
@@ -63,6 +68,9 @@ class Metasploit::Credential::Private < ApplicationRecord
|
|
63
68
|
search_attribute :data,
|
64
69
|
type: :string
|
65
70
|
|
71
|
+
search_attribute :metadata,
|
72
|
+
type: :jsonb
|
73
|
+
|
66
74
|
#
|
67
75
|
# Search Withs
|
68
76
|
#
|
data/config/locales/en.yml
CHANGED
@@ -87,7 +87,7 @@ en:
|
|
87
87
|
metasploit/credential/pkcs12:
|
88
88
|
attributes:
|
89
89
|
data:
|
90
|
-
format: "is not a Base64 encoded pkcs12 file without a password"
|
90
|
+
format: "is not a serialized data containing Base64 encoded pkcs12 file without a password and metadata"
|
91
91
|
metasploit/credential/ssh_key:
|
92
92
|
attributes:
|
93
93
|
data:
|
@@ -480,7 +480,7 @@ module Metasploit::Credential::Creation
|
|
480
480
|
when :ssh_key
|
481
481
|
private_object = Metasploit::Credential::SSHKey.where(data: private_data).first_or_create
|
482
482
|
when :pkcs12
|
483
|
-
private_object = Metasploit::Credential::Pkcs12.where(data: private_data).first_or_create
|
483
|
+
private_object = Metasploit::Credential::Pkcs12.where(data: private_data, metadata: opts.fetch(:private_metadata, {})).first_or_create
|
484
484
|
when :krb_enc_key
|
485
485
|
private_object = Metasploit::Credential::KrbEncKey.where(data: private_data).first_or_create
|
486
486
|
when :ntlm_hash
|
@@ -1,6 +1,6 @@
|
|
1
1
|
development: &pgsql
|
2
2
|
adapter: postgresql
|
3
|
-
database: metasploit-
|
3
|
+
database: metasploit-credential_development_0
|
4
4
|
username: msf
|
5
5
|
password: pass123
|
6
6
|
host: localhost
|
@@ -8,6 +8,8 @@ development: &pgsql
|
|
8
8
|
pool: 5
|
9
9
|
timeout: 5
|
10
10
|
min_messages: warning
|
11
|
+
production:
|
12
|
+
<<: *pgsql
|
11
13
|
test:
|
12
14
|
<<: *pgsql
|
13
|
-
database: metasploit-
|
15
|
+
database: metasploit-credential_test0
|
data/spec/dummy/db/structure.sql
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
SET statement_timeout = 0;
|
2
2
|
SET lock_timeout = 0;
|
3
3
|
SET idle_in_transaction_session_timeout = 0;
|
4
|
+
SET transaction_timeout = 0;
|
4
5
|
SET client_encoding = 'UTF8';
|
5
6
|
SET standard_conforming_strings = on;
|
6
7
|
SELECT pg_catalog.set_config('search_path', '', false);
|
@@ -11,6 +12,8 @@ SET row_security = off;
|
|
11
12
|
|
12
13
|
SET default_tablespace = '';
|
13
14
|
|
15
|
+
SET default_table_access_method = heap;
|
16
|
+
|
14
17
|
--
|
15
18
|
-- Name: api_keys; Type: TABLE; Schema: public; Owner: -
|
16
19
|
--
|
@@ -28,6 +31,7 @@ CREATE TABLE public.api_keys (
|
|
28
31
|
--
|
29
32
|
|
30
33
|
CREATE SEQUENCE public.api_keys_id_seq
|
34
|
+
AS integer
|
31
35
|
START WITH 1
|
32
36
|
INCREMENT BY 1
|
33
37
|
NO MINVALUE
|
@@ -75,6 +79,7 @@ CREATE TABLE public.async_callbacks (
|
|
75
79
|
--
|
76
80
|
|
77
81
|
CREATE SEQUENCE public.async_callbacks_id_seq
|
82
|
+
AS integer
|
78
83
|
START WITH 1
|
79
84
|
INCREMENT BY 1
|
80
85
|
NO MINVALUE
|
@@ -108,6 +113,7 @@ CREATE TABLE public.automatic_exploitation_match_results (
|
|
108
113
|
--
|
109
114
|
|
110
115
|
CREATE SEQUENCE public.automatic_exploitation_match_results_id_seq
|
116
|
+
AS integer
|
111
117
|
START WITH 1
|
112
118
|
INCREMENT BY 1
|
113
119
|
NO MINVALUE
|
@@ -140,6 +146,7 @@ CREATE TABLE public.automatic_exploitation_match_sets (
|
|
140
146
|
--
|
141
147
|
|
142
148
|
CREATE SEQUENCE public.automatic_exploitation_match_sets_id_seq
|
149
|
+
AS integer
|
143
150
|
START WITH 1
|
144
151
|
INCREMENT BY 1
|
145
152
|
NO MINVALUE
|
@@ -177,6 +184,7 @@ CREATE TABLE public.automatic_exploitation_matches (
|
|
177
184
|
--
|
178
185
|
|
179
186
|
CREATE SEQUENCE public.automatic_exploitation_matches_id_seq
|
187
|
+
AS integer
|
180
188
|
START WITH 1
|
181
189
|
INCREMENT BY 1
|
182
190
|
NO MINVALUE
|
@@ -210,6 +218,7 @@ CREATE TABLE public.automatic_exploitation_runs (
|
|
210
218
|
--
|
211
219
|
|
212
220
|
CREATE SEQUENCE public.automatic_exploitation_runs_id_seq
|
221
|
+
AS integer
|
213
222
|
START WITH 1
|
214
223
|
INCREMENT BY 1
|
215
224
|
NO MINVALUE
|
@@ -244,6 +253,7 @@ CREATE TABLE public.clients (
|
|
244
253
|
--
|
245
254
|
|
246
255
|
CREATE SEQUENCE public.clients_id_seq
|
256
|
+
AS integer
|
247
257
|
START WITH 1
|
248
258
|
INCREMENT BY 1
|
249
259
|
NO MINVALUE
|
@@ -302,6 +312,7 @@ CREATE TABLE public.creds (
|
|
302
312
|
--
|
303
313
|
|
304
314
|
CREATE SEQUENCE public.creds_id_seq
|
315
|
+
AS integer
|
305
316
|
START WITH 1
|
306
317
|
INCREMENT BY 1
|
307
318
|
NO MINVALUE
|
@@ -339,6 +350,7 @@ CREATE TABLE public.events (
|
|
339
350
|
--
|
340
351
|
|
341
352
|
CREATE SEQUENCE public.events_id_seq
|
353
|
+
AS integer
|
342
354
|
START WITH 1
|
343
355
|
INCREMENT BY 1
|
344
356
|
NO MINVALUE
|
@@ -380,6 +392,7 @@ CREATE TABLE public.exploit_attempts (
|
|
380
392
|
--
|
381
393
|
|
382
394
|
CREATE SEQUENCE public.exploit_attempts_id_seq
|
395
|
+
AS integer
|
383
396
|
START WITH 1
|
384
397
|
INCREMENT BY 1
|
385
398
|
NO MINVALUE
|
@@ -415,6 +428,7 @@ CREATE TABLE public.exploited_hosts (
|
|
415
428
|
--
|
416
429
|
|
417
430
|
CREATE SEQUENCE public.exploited_hosts_id_seq
|
431
|
+
AS integer
|
418
432
|
START WITH 1
|
419
433
|
INCREMENT BY 1
|
420
434
|
NO MINVALUE
|
@@ -451,6 +465,7 @@ CREATE TABLE public.host_details (
|
|
451
465
|
--
|
452
466
|
|
453
467
|
CREATE SEQUENCE public.host_details_id_seq
|
468
|
+
AS integer
|
454
469
|
START WITH 1
|
455
470
|
INCREMENT BY 1
|
456
471
|
NO MINVALUE
|
@@ -505,6 +520,7 @@ CREATE TABLE public.hosts (
|
|
505
520
|
--
|
506
521
|
|
507
522
|
CREATE SEQUENCE public.hosts_id_seq
|
523
|
+
AS integer
|
508
524
|
START WITH 1
|
509
525
|
INCREMENT BY 1
|
510
526
|
NO MINVALUE
|
@@ -535,6 +551,7 @@ CREATE TABLE public.hosts_tags (
|
|
535
551
|
--
|
536
552
|
|
537
553
|
CREATE SEQUENCE public.hosts_tags_id_seq
|
554
|
+
AS integer
|
538
555
|
START WITH 1
|
539
556
|
INCREMENT BY 1
|
540
557
|
NO MINVALUE
|
@@ -574,6 +591,7 @@ CREATE TABLE public.listeners (
|
|
574
591
|
--
|
575
592
|
|
576
593
|
CREATE SEQUENCE public.listeners_id_seq
|
594
|
+
AS integer
|
577
595
|
START WITH 1
|
578
596
|
INCREMENT BY 1
|
579
597
|
NO MINVALUE
|
@@ -614,6 +632,7 @@ CREATE TABLE public.loots (
|
|
614
632
|
--
|
615
633
|
|
616
634
|
CREATE SEQUENCE public.loots_id_seq
|
635
|
+
AS integer
|
617
636
|
START WITH 1
|
618
637
|
INCREMENT BY 1
|
619
638
|
NO MINVALUE
|
@@ -649,6 +668,7 @@ CREATE TABLE public.macros (
|
|
649
668
|
--
|
650
669
|
|
651
670
|
CREATE SEQUENCE public.macros_id_seq
|
671
|
+
AS integer
|
652
672
|
START WITH 1
|
653
673
|
INCREMENT BY 1
|
654
674
|
NO MINVALUE
|
@@ -686,6 +706,7 @@ CREATE TABLE public.metasploit_credential_cores (
|
|
686
706
|
--
|
687
707
|
|
688
708
|
CREATE SEQUENCE public.metasploit_credential_cores_id_seq
|
709
|
+
AS integer
|
689
710
|
START WITH 1
|
690
711
|
INCREMENT BY 1
|
691
712
|
NO MINVALUE
|
@@ -721,6 +742,7 @@ CREATE TABLE public.metasploit_credential_logins (
|
|
721
742
|
--
|
722
743
|
|
723
744
|
CREATE SEQUENCE public.metasploit_credential_logins_id_seq
|
745
|
+
AS integer
|
724
746
|
START WITH 1
|
725
747
|
INCREMENT BY 1
|
726
748
|
NO MINVALUE
|
@@ -752,6 +774,7 @@ CREATE TABLE public.metasploit_credential_origin_cracked_passwords (
|
|
752
774
|
--
|
753
775
|
|
754
776
|
CREATE SEQUENCE public.metasploit_credential_origin_cracked_passwords_id_seq
|
777
|
+
AS integer
|
755
778
|
START WITH 1
|
756
779
|
INCREMENT BY 1
|
757
780
|
NO MINVALUE
|
@@ -784,6 +807,7 @@ CREATE TABLE public.metasploit_credential_origin_imports (
|
|
784
807
|
--
|
785
808
|
|
786
809
|
CREATE SEQUENCE public.metasploit_credential_origin_imports_id_seq
|
810
|
+
AS integer
|
787
811
|
START WITH 1
|
788
812
|
INCREMENT BY 1
|
789
813
|
NO MINVALUE
|
@@ -815,6 +839,7 @@ CREATE TABLE public.metasploit_credential_origin_manuals (
|
|
815
839
|
--
|
816
840
|
|
817
841
|
CREATE SEQUENCE public.metasploit_credential_origin_manuals_id_seq
|
842
|
+
AS integer
|
818
843
|
START WITH 1
|
819
844
|
INCREMENT BY 1
|
820
845
|
NO MINVALUE
|
@@ -847,6 +872,7 @@ CREATE TABLE public.metasploit_credential_origin_services (
|
|
847
872
|
--
|
848
873
|
|
849
874
|
CREATE SEQUENCE public.metasploit_credential_origin_services_id_seq
|
875
|
+
AS integer
|
850
876
|
START WITH 1
|
851
877
|
INCREMENT BY 1
|
852
878
|
NO MINVALUE
|
@@ -879,6 +905,7 @@ CREATE TABLE public.metasploit_credential_origin_sessions (
|
|
879
905
|
--
|
880
906
|
|
881
907
|
CREATE SEQUENCE public.metasploit_credential_origin_sessions_id_seq
|
908
|
+
AS integer
|
882
909
|
START WITH 1
|
883
910
|
INCREMENT BY 1
|
884
911
|
NO MINVALUE
|
@@ -903,7 +930,8 @@ CREATE TABLE public.metasploit_credential_privates (
|
|
903
930
|
data text NOT NULL,
|
904
931
|
created_at timestamp without time zone NOT NULL,
|
905
932
|
updated_at timestamp without time zone NOT NULL,
|
906
|
-
jtr_format character varying
|
933
|
+
jtr_format character varying,
|
934
|
+
metadata jsonb DEFAULT '{}'::jsonb NOT NULL
|
907
935
|
);
|
908
936
|
|
909
937
|
|
@@ -912,6 +940,7 @@ CREATE TABLE public.metasploit_credential_privates (
|
|
912
940
|
--
|
913
941
|
|
914
942
|
CREATE SEQUENCE public.metasploit_credential_privates_id_seq
|
943
|
+
AS integer
|
915
944
|
START WITH 1
|
916
945
|
INCREMENT BY 1
|
917
946
|
NO MINVALUE
|
@@ -944,6 +973,7 @@ CREATE TABLE public.metasploit_credential_publics (
|
|
944
973
|
--
|
945
974
|
|
946
975
|
CREATE SEQUENCE public.metasploit_credential_publics_id_seq
|
976
|
+
AS integer
|
947
977
|
START WITH 1
|
948
978
|
INCREMENT BY 1
|
949
979
|
NO MINVALUE
|
@@ -976,6 +1006,7 @@ CREATE TABLE public.metasploit_credential_realms (
|
|
976
1006
|
--
|
977
1007
|
|
978
1008
|
CREATE SEQUENCE public.metasploit_credential_realms_id_seq
|
1009
|
+
AS integer
|
979
1010
|
START WITH 1
|
980
1011
|
INCREMENT BY 1
|
981
1012
|
NO MINVALUE
|
@@ -1007,6 +1038,7 @@ CREATE TABLE public.mod_refs (
|
|
1007
1038
|
--
|
1008
1039
|
|
1009
1040
|
CREATE SEQUENCE public.mod_refs_id_seq
|
1041
|
+
AS integer
|
1010
1042
|
START WITH 1
|
1011
1043
|
INCREMENT BY 1
|
1012
1044
|
NO MINVALUE
|
@@ -1037,6 +1069,7 @@ CREATE TABLE public.module_actions (
|
|
1037
1069
|
--
|
1038
1070
|
|
1039
1071
|
CREATE SEQUENCE public.module_actions_id_seq
|
1072
|
+
AS integer
|
1040
1073
|
START WITH 1
|
1041
1074
|
INCREMENT BY 1
|
1042
1075
|
NO MINVALUE
|
@@ -1067,6 +1100,7 @@ CREATE TABLE public.module_archs (
|
|
1067
1100
|
--
|
1068
1101
|
|
1069
1102
|
CREATE SEQUENCE public.module_archs_id_seq
|
1103
|
+
AS integer
|
1070
1104
|
START WITH 1
|
1071
1105
|
INCREMENT BY 1
|
1072
1106
|
NO MINVALUE
|
@@ -1098,6 +1132,7 @@ CREATE TABLE public.module_authors (
|
|
1098
1132
|
--
|
1099
1133
|
|
1100
1134
|
CREATE SEQUENCE public.module_authors_id_seq
|
1135
|
+
AS integer
|
1101
1136
|
START WITH 1
|
1102
1137
|
INCREMENT BY 1
|
1103
1138
|
NO MINVALUE
|
@@ -1141,6 +1176,7 @@ CREATE TABLE public.module_details (
|
|
1141
1176
|
--
|
1142
1177
|
|
1143
1178
|
CREATE SEQUENCE public.module_details_id_seq
|
1179
|
+
AS integer
|
1144
1180
|
START WITH 1
|
1145
1181
|
INCREMENT BY 1
|
1146
1182
|
NO MINVALUE
|
@@ -1171,6 +1207,7 @@ CREATE TABLE public.module_mixins (
|
|
1171
1207
|
--
|
1172
1208
|
|
1173
1209
|
CREATE SEQUENCE public.module_mixins_id_seq
|
1210
|
+
AS integer
|
1174
1211
|
START WITH 1
|
1175
1212
|
INCREMENT BY 1
|
1176
1213
|
NO MINVALUE
|
@@ -1201,6 +1238,7 @@ CREATE TABLE public.module_platforms (
|
|
1201
1238
|
--
|
1202
1239
|
|
1203
1240
|
CREATE SEQUENCE public.module_platforms_id_seq
|
1241
|
+
AS integer
|
1204
1242
|
START WITH 1
|
1205
1243
|
INCREMENT BY 1
|
1206
1244
|
NO MINVALUE
|
@@ -1231,6 +1269,7 @@ CREATE TABLE public.module_refs (
|
|
1231
1269
|
--
|
1232
1270
|
|
1233
1271
|
CREATE SEQUENCE public.module_refs_id_seq
|
1272
|
+
AS integer
|
1234
1273
|
START WITH 1
|
1235
1274
|
INCREMENT BY 1
|
1236
1275
|
NO MINVALUE
|
@@ -1273,6 +1312,7 @@ CREATE TABLE public.module_runs (
|
|
1273
1312
|
--
|
1274
1313
|
|
1275
1314
|
CREATE SEQUENCE public.module_runs_id_seq
|
1315
|
+
AS integer
|
1276
1316
|
START WITH 1
|
1277
1317
|
INCREMENT BY 1
|
1278
1318
|
NO MINVALUE
|
@@ -1304,6 +1344,7 @@ CREATE TABLE public.module_targets (
|
|
1304
1344
|
--
|
1305
1345
|
|
1306
1346
|
CREATE SEQUENCE public.module_targets_id_seq
|
1347
|
+
AS integer
|
1307
1348
|
START WITH 1
|
1308
1349
|
INCREMENT BY 1
|
1309
1350
|
NO MINVALUE
|
@@ -1345,6 +1386,7 @@ CREATE TABLE public.nexpose_consoles (
|
|
1345
1386
|
--
|
1346
1387
|
|
1347
1388
|
CREATE SEQUENCE public.nexpose_consoles_id_seq
|
1389
|
+
AS integer
|
1348
1390
|
START WITH 1
|
1349
1391
|
INCREMENT BY 1
|
1350
1392
|
NO MINVALUE
|
@@ -1383,6 +1425,7 @@ CREATE TABLE public.notes (
|
|
1383
1425
|
--
|
1384
1426
|
|
1385
1427
|
CREATE SEQUENCE public.notes_id_seq
|
1428
|
+
AS integer
|
1386
1429
|
START WITH 1
|
1387
1430
|
INCREMENT BY 1
|
1388
1431
|
NO MINVALUE
|
@@ -1425,6 +1468,7 @@ CREATE TABLE public.payloads (
|
|
1425
1468
|
--
|
1426
1469
|
|
1427
1470
|
CREATE SEQUENCE public.payloads_id_seq
|
1471
|
+
AS integer
|
1428
1472
|
START WITH 1
|
1429
1473
|
INCREMENT BY 1
|
1430
1474
|
NO MINVALUE
|
@@ -1459,6 +1503,7 @@ CREATE TABLE public.profiles (
|
|
1459
1503
|
--
|
1460
1504
|
|
1461
1505
|
CREATE SEQUENCE public.profiles_id_seq
|
1506
|
+
AS integer
|
1462
1507
|
START WITH 1
|
1463
1508
|
INCREMENT BY 1
|
1464
1509
|
NO MINVALUE
|
@@ -1491,6 +1536,7 @@ CREATE TABLE public.refs (
|
|
1491
1536
|
--
|
1492
1537
|
|
1493
1538
|
CREATE SEQUENCE public.refs_id_seq
|
1539
|
+
AS integer
|
1494
1540
|
START WITH 1
|
1495
1541
|
INCREMENT BY 1
|
1496
1542
|
NO MINVALUE
|
@@ -1525,6 +1571,7 @@ CREATE TABLE public.report_templates (
|
|
1525
1571
|
--
|
1526
1572
|
|
1527
1573
|
CREATE SEQUENCE public.report_templates_id_seq
|
1574
|
+
AS integer
|
1528
1575
|
START WITH 1
|
1529
1576
|
INCREMENT BY 1
|
1530
1577
|
NO MINVALUE
|
@@ -1563,6 +1610,7 @@ CREATE TABLE public.reports (
|
|
1563
1610
|
--
|
1564
1611
|
|
1565
1612
|
CREATE SEQUENCE public.reports_id_seq
|
1613
|
+
AS integer
|
1566
1614
|
START WITH 1
|
1567
1615
|
INCREMENT BY 1
|
1568
1616
|
NO MINVALUE
|
@@ -1594,6 +1642,7 @@ CREATE TABLE public.routes (
|
|
1594
1642
|
--
|
1595
1643
|
|
1596
1644
|
CREATE SEQUENCE public.routes_id_seq
|
1645
|
+
AS integer
|
1597
1646
|
START WITH 1
|
1598
1647
|
INCREMENT BY 1
|
1599
1648
|
NO MINVALUE
|
@@ -1639,6 +1688,7 @@ CREATE TABLE public.services (
|
|
1639
1688
|
--
|
1640
1689
|
|
1641
1690
|
CREATE SEQUENCE public.services_id_seq
|
1691
|
+
AS integer
|
1642
1692
|
START WITH 1
|
1643
1693
|
INCREMENT BY 1
|
1644
1694
|
NO MINVALUE
|
@@ -1674,6 +1724,7 @@ CREATE TABLE public.session_events (
|
|
1674
1724
|
--
|
1675
1725
|
|
1676
1726
|
CREATE SEQUENCE public.session_events_id_seq
|
1727
|
+
AS integer
|
1677
1728
|
START WITH 1
|
1678
1729
|
INCREMENT BY 1
|
1679
1730
|
NO MINVALUE
|
@@ -1716,6 +1767,7 @@ CREATE TABLE public.sessions (
|
|
1716
1767
|
--
|
1717
1768
|
|
1718
1769
|
CREATE SEQUENCE public.sessions_id_seq
|
1770
|
+
AS integer
|
1719
1771
|
START WITH 1
|
1720
1772
|
INCREMENT BY 1
|
1721
1773
|
NO MINVALUE
|
@@ -1752,6 +1804,7 @@ CREATE TABLE public.tags (
|
|
1752
1804
|
--
|
1753
1805
|
|
1754
1806
|
CREATE SEQUENCE public.tags_id_seq
|
1807
|
+
AS integer
|
1755
1808
|
START WITH 1
|
1756
1809
|
INCREMENT BY 1
|
1757
1810
|
NO MINVALUE
|
@@ -1784,6 +1837,7 @@ CREATE TABLE public.task_creds (
|
|
1784
1837
|
--
|
1785
1838
|
|
1786
1839
|
CREATE SEQUENCE public.task_creds_id_seq
|
1840
|
+
AS integer
|
1787
1841
|
START WITH 1
|
1788
1842
|
INCREMENT BY 1
|
1789
1843
|
NO MINVALUE
|
@@ -1816,6 +1870,7 @@ CREATE TABLE public.task_hosts (
|
|
1816
1870
|
--
|
1817
1871
|
|
1818
1872
|
CREATE SEQUENCE public.task_hosts_id_seq
|
1873
|
+
AS integer
|
1819
1874
|
START WITH 1
|
1820
1875
|
INCREMENT BY 1
|
1821
1876
|
NO MINVALUE
|
@@ -1848,6 +1903,7 @@ CREATE TABLE public.task_services (
|
|
1848
1903
|
--
|
1849
1904
|
|
1850
1905
|
CREATE SEQUENCE public.task_services_id_seq
|
1906
|
+
AS integer
|
1851
1907
|
START WITH 1
|
1852
1908
|
INCREMENT BY 1
|
1853
1909
|
NO MINVALUE
|
@@ -1880,6 +1936,7 @@ CREATE TABLE public.task_sessions (
|
|
1880
1936
|
--
|
1881
1937
|
|
1882
1938
|
CREATE SEQUENCE public.task_sessions_id_seq
|
1939
|
+
AS integer
|
1883
1940
|
START WITH 1
|
1884
1941
|
INCREMENT BY 1
|
1885
1942
|
NO MINVALUE
|
@@ -1923,6 +1980,7 @@ CREATE TABLE public.tasks (
|
|
1923
1980
|
--
|
1924
1981
|
|
1925
1982
|
CREATE SEQUENCE public.tasks_id_seq
|
1983
|
+
AS integer
|
1926
1984
|
START WITH 1
|
1927
1985
|
INCREMENT BY 1
|
1928
1986
|
NO MINVALUE
|
@@ -1963,6 +2021,7 @@ CREATE TABLE public.users (
|
|
1963
2021
|
--
|
1964
2022
|
|
1965
2023
|
CREATE SEQUENCE public.users_id_seq
|
2024
|
+
AS integer
|
1966
2025
|
START WITH 1
|
1967
2026
|
INCREMENT BY 1
|
1968
2027
|
NO MINVALUE
|
@@ -2000,6 +2059,7 @@ CREATE TABLE public.vuln_attempts (
|
|
2000
2059
|
--
|
2001
2060
|
|
2002
2061
|
CREATE SEQUENCE public.vuln_attempts_id_seq
|
2062
|
+
AS integer
|
2003
2063
|
START WITH 1
|
2004
2064
|
INCREMENT BY 1
|
2005
2065
|
NO MINVALUE
|
@@ -2050,6 +2110,7 @@ CREATE TABLE public.vuln_details (
|
|
2050
2110
|
--
|
2051
2111
|
|
2052
2112
|
CREATE SEQUENCE public.vuln_details_id_seq
|
2113
|
+
AS integer
|
2053
2114
|
START WITH 1
|
2054
2115
|
INCREMENT BY 1
|
2055
2116
|
NO MINVALUE
|
@@ -2089,6 +2150,7 @@ CREATE TABLE public.vulns (
|
|
2089
2150
|
--
|
2090
2151
|
|
2091
2152
|
CREATE SEQUENCE public.vulns_id_seq
|
2153
|
+
AS integer
|
2092
2154
|
START WITH 1
|
2093
2155
|
INCREMENT BY 1
|
2094
2156
|
NO MINVALUE
|
@@ -2119,6 +2181,7 @@ CREATE TABLE public.vulns_refs (
|
|
2119
2181
|
--
|
2120
2182
|
|
2121
2183
|
CREATE SEQUENCE public.vulns_refs_id_seq
|
2184
|
+
AS integer
|
2122
2185
|
START WITH 1
|
2123
2186
|
INCREMENT BY 1
|
2124
2187
|
NO MINVALUE
|
@@ -2154,6 +2217,7 @@ CREATE TABLE public.web_forms (
|
|
2154
2217
|
--
|
2155
2218
|
|
2156
2219
|
CREATE SEQUENCE public.web_forms_id_seq
|
2220
|
+
AS integer
|
2157
2221
|
START WITH 1
|
2158
2222
|
INCREMENT BY 1
|
2159
2223
|
NO MINVALUE
|
@@ -2196,6 +2260,7 @@ CREATE TABLE public.web_pages (
|
|
2196
2260
|
--
|
2197
2261
|
|
2198
2262
|
CREATE SEQUENCE public.web_pages_id_seq
|
2263
|
+
AS integer
|
2199
2264
|
START WITH 1
|
2200
2265
|
INCREMENT BY 1
|
2201
2266
|
NO MINVALUE
|
@@ -2230,6 +2295,7 @@ CREATE TABLE public.web_sites (
|
|
2230
2295
|
--
|
2231
2296
|
|
2232
2297
|
CREATE SEQUENCE public.web_sites_id_seq
|
2298
|
+
AS integer
|
2233
2299
|
START WITH 1
|
2234
2300
|
INCREMENT BY 1
|
2235
2301
|
NO MINVALUE
|
@@ -2276,6 +2342,7 @@ CREATE TABLE public.web_vulns (
|
|
2276
2342
|
--
|
2277
2343
|
|
2278
2344
|
CREATE SEQUENCE public.web_vulns_id_seq
|
2345
|
+
AS integer
|
2279
2346
|
START WITH 1
|
2280
2347
|
INCREMENT BY 1
|
2281
2348
|
NO MINVALUE
|
@@ -2318,6 +2385,7 @@ CREATE TABLE public.wmap_requests (
|
|
2318
2385
|
--
|
2319
2386
|
|
2320
2387
|
CREATE SEQUENCE public.wmap_requests_id_seq
|
2388
|
+
AS integer
|
2321
2389
|
START WITH 1
|
2322
2390
|
INCREMENT BY 1
|
2323
2391
|
NO MINVALUE
|
@@ -2353,6 +2421,7 @@ CREATE TABLE public.wmap_targets (
|
|
2353
2421
|
--
|
2354
2422
|
|
2355
2423
|
CREATE SEQUENCE public.wmap_targets_id_seq
|
2424
|
+
AS integer
|
2356
2425
|
START WITH 1
|
2357
2426
|
INCREMENT BY 1
|
2358
2427
|
NO MINVALUE
|
@@ -2399,6 +2468,7 @@ CREATE TABLE public.workspaces (
|
|
2399
2468
|
--
|
2400
2469
|
|
2401
2470
|
CREATE SEQUENCE public.workspaces_id_seq
|
2471
|
+
AS integer
|
2402
2472
|
START WITH 1
|
2403
2473
|
INCREMENT BY 1
|
2404
2474
|
NO MINVALUE
|
@@ -3598,7 +3668,14 @@ CREATE INDEX index_metasploit_credential_origin_manuals_on_user_id ON public.met
|
|
3598
3668
|
-- Name: index_metasploit_credential_privates_on_type_and_data; Type: INDEX; Schema: public; Owner: -
|
3599
3669
|
--
|
3600
3670
|
|
3601
|
-
CREATE UNIQUE INDEX index_metasploit_credential_privates_on_type_and_data ON public.metasploit_credential_privates USING btree (type, data) WHERE (NOT ((type)::text = 'Metasploit::Credential::SSHKey'::text));
|
3671
|
+
CREATE UNIQUE INDEX index_metasploit_credential_privates_on_type_and_data ON public.metasploit_credential_privates USING btree (type, data) WHERE (NOT (((type)::text = 'Metasploit::Credential::SSHKey'::text) OR ((type)::text = 'Metasploit::Credential::Pkcs12'::text)));
|
3672
|
+
|
3673
|
+
|
3674
|
+
--
|
3675
|
+
-- Name: index_metasploit_credential_privates_on_type_and_data_pkcs12; Type: INDEX; Schema: public; Owner: -
|
3676
|
+
--
|
3677
|
+
|
3678
|
+
CREATE UNIQUE INDEX index_metasploit_credential_privates_on_type_and_data_pkcs12 ON public.metasploit_credential_privates USING btree (type, decode(md5(data), 'hex'::text)) WHERE ((type)::text = 'Metasploit::Credential::Pkcs12'::text);
|
3602
3679
|
|
3603
3680
|
|
3604
3681
|
--
|
@@ -4071,6 +4148,8 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|
4071
4148
|
('20180904120211'),
|
4072
4149
|
('20190308134512'),
|
4073
4150
|
('20190507120211'),
|
4151
|
+
('20221209005658'),
|
4152
|
+
('20250204172657'),
|
4074
4153
|
('21'),
|
4075
4154
|
('22'),
|
4076
4155
|
('23'),
|
@@ -10,10 +10,15 @@ FactoryBot.define do
|
|
10
10
|
subject { '/C=BE/O=Test/OU=Test/CN=Test' }
|
11
11
|
# the cert issuer
|
12
12
|
issuer { '/C=BE/O=Test/OU=Test/CN=Test' }
|
13
|
+
# the pkcs12 password
|
14
|
+
pkcs12_password { '' }
|
15
|
+
# the cert not_before date
|
16
|
+
not_before { Time.now }
|
17
|
+
# the cert not_after date
|
18
|
+
not_after { Time.now + 365 * 24 * 60 * 60 }
|
13
19
|
end
|
14
20
|
|
15
21
|
data {
|
16
|
-
password = ''
|
17
22
|
pkcs12_name = ''
|
18
23
|
|
19
24
|
private_key = OpenSSL::PKey::RSA.new(key_size)
|
@@ -22,16 +27,71 @@ FactoryBot.define do
|
|
22
27
|
cert = OpenSSL::X509::Certificate.new
|
23
28
|
cert.subject = OpenSSL::X509::Name.parse(subject)
|
24
29
|
cert.issuer = OpenSSL::X509::Name.parse(issuer)
|
25
|
-
cert.not_before =
|
26
|
-
cert.not_after =
|
30
|
+
cert.not_before = not_before
|
31
|
+
cert.not_after = not_after
|
27
32
|
cert.public_key = public_key
|
28
33
|
cert.serial = 0x0
|
29
34
|
cert.version = 2
|
30
35
|
cert.sign(private_key, OpenSSL::Digest.new(signing_algorithm))
|
31
36
|
|
32
|
-
pkcs12 = OpenSSL::PKCS12.create(
|
33
|
-
|
34
|
-
pkcs12_base64
|
37
|
+
pkcs12 = OpenSSL::PKCS12.create(pkcs12_password, pkcs12_name, private_key, cert)
|
38
|
+
Base64.strict_encode64(pkcs12.to_der)
|
35
39
|
}
|
36
40
|
end
|
41
|
+
|
42
|
+
factory :metasploit_credential_pkcs12_with_ca, parent: :metasploit_credential_pkcs12 do
|
43
|
+
transient do
|
44
|
+
# The CA that issued the certificate
|
45
|
+
adcs_ca { 'test-ca' }
|
46
|
+
end
|
47
|
+
|
48
|
+
metadata { { adcs_ca: adcs_ca } }
|
49
|
+
end
|
50
|
+
|
51
|
+
factory :metasploit_credential_pkcs12_with_adcs_template, parent: :metasploit_credential_pkcs12 do
|
52
|
+
transient do
|
53
|
+
# The certificate template used to issue the certificate
|
54
|
+
adcs_template { 'User' }
|
55
|
+
end
|
56
|
+
|
57
|
+
metadata { { adcs_template: adcs_template} }
|
58
|
+
end
|
59
|
+
|
60
|
+
factory :metasploit_credential_pkcs12_with_pkcs12_password, parent: :metasploit_credential_pkcs12 do
|
61
|
+
transient do
|
62
|
+
# The password to decrypt the pkcs12
|
63
|
+
pkcs12_password { 'Password!' }
|
64
|
+
end
|
65
|
+
|
66
|
+
metadata { { pkcs12_password: pkcs12_password } }
|
67
|
+
end
|
68
|
+
|
69
|
+
factory :metasploit_credential_pkcs12_with_status, parent: :metasploit_credential_pkcs12 do
|
70
|
+
transient do
|
71
|
+
# The CA that issued the certificate
|
72
|
+
status { 'active' }
|
73
|
+
end
|
74
|
+
|
75
|
+
metadata { { status: status } }
|
76
|
+
end
|
77
|
+
|
78
|
+
factory :metasploit_credential_pkcs12_with_ca_and_adcs_template, parent: :metasploit_credential_pkcs12 do
|
79
|
+
transient do
|
80
|
+
adcs_ca { 'test-ca' }
|
81
|
+
adcs_template { 'User' }
|
82
|
+
end
|
83
|
+
|
84
|
+
metadata { { adcs_ca: adcs_ca, adcs_template: adcs_template } }
|
85
|
+
end
|
86
|
+
|
87
|
+
factory :metasploit_credential_pkcs12_with_ca_and_adcs_template_and_pkcs12_password, parent: :metasploit_credential_pkcs12 do
|
88
|
+
transient do
|
89
|
+
adcs_ca { 'test-ca' }
|
90
|
+
adcs_template { 'User' }
|
91
|
+
pkcs12_password { 'Password!' }
|
92
|
+
end
|
93
|
+
|
94
|
+
metadata { { adcs_ca: adcs_ca, adcs_template: adcs_template, pkcs12_password: pkcs12_password } }
|
95
|
+
end
|
96
|
+
|
37
97
|
end
|
@@ -864,13 +864,36 @@ RSpec.describe Metasploit::Credential::Creation do
|
|
864
864
|
end
|
865
865
|
|
866
866
|
context 'when :private_type is pkcs12' do
|
867
|
-
|
868
|
-
|
867
|
+
let(:opts) {
|
868
|
+
{
|
869
869
|
private_data: FactoryBot.build(:metasploit_credential_pkcs12).data,
|
870
870
|
private_type: :pkcs12
|
871
871
|
}
|
872
|
+
}
|
873
|
+
it 'creates a Metasploit::Credential::Pkcs12' do
|
872
874
|
expect{ test_object.create_credential_private(opts) }.to change{ Metasploit::Credential::Pkcs12.count }.by(1)
|
873
875
|
end
|
876
|
+
|
877
|
+
context 'with metadata' do
|
878
|
+
it 'creates a Metasploit::Credential::Pkcs12 with the expected metadata' do
|
879
|
+
adcs_ca = 'test_ca'
|
880
|
+
adcs_template = 'test_template'
|
881
|
+
opts[:private_metadata] = { adcs_ca: adcs_ca, adcs_template: adcs_template }
|
882
|
+
pkcs12 = test_object.create_credential_private(opts)
|
883
|
+
expect(pkcs12.adcs_ca).to eq(adcs_ca)
|
884
|
+
expect(pkcs12.adcs_template).to eq(adcs_template)
|
885
|
+
end
|
886
|
+
end
|
887
|
+
|
888
|
+
context 'and the Pkcs12 has a password' do
|
889
|
+
it 'creates a valid Metasploit::Credential::Pkcs12' do
|
890
|
+
pkcs12_password = 'test_password'
|
891
|
+
opts[:private_data] = FactoryBot.build(:metasploit_credential_pkcs12, pkcs12_password: pkcs12_password ).data
|
892
|
+
opts[:private_metadata] = { pkcs12_password: pkcs12_password }
|
893
|
+
pkcs12 = test_object.create_credential_private(opts)
|
894
|
+
expect(pkcs12).to be_valid
|
895
|
+
end
|
896
|
+
end
|
874
897
|
end
|
875
898
|
end
|
876
899
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
RSpec.describe Metasploit::Credential::Pkcs12, type: :model do
|
2
2
|
it_should_behave_like 'Metasploit::Concern.run'
|
3
3
|
|
4
|
+
it { is_expected.to be_a Metasploit::Credential::Private }
|
5
|
+
|
4
6
|
context 'factories' do
|
5
7
|
context 'metasploit_credential_pkcs12' do
|
6
8
|
subject(:metasploit_credential_pkcs12) do
|
@@ -9,6 +11,54 @@ RSpec.describe Metasploit::Credential::Pkcs12, type: :model do
|
|
9
11
|
|
10
12
|
it { is_expected.to be_valid }
|
11
13
|
end
|
14
|
+
|
15
|
+
context 'metasploit_credential_pkcs12_with_ca' do
|
16
|
+
subject(:metasploit_credential_pkcs12_with_ca) do
|
17
|
+
FactoryBot.build(:metasploit_credential_pkcs12_with_ca)
|
18
|
+
end
|
19
|
+
|
20
|
+
it { is_expected.to be_valid }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'metasploit_credential_pkcs12_with_adcs_template' do
|
24
|
+
subject(:metasploit_credential_pkcs12_with_adcs_template) do
|
25
|
+
FactoryBot.build(:metasploit_credential_pkcs12_with_adcs_template)
|
26
|
+
end
|
27
|
+
|
28
|
+
it { is_expected.to be_valid }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'metasploit_credential_pkcs12_with_pkcs12_password' do
|
32
|
+
subject(:metasploit_credential_pkcs12_with_pkcs12_password) do
|
33
|
+
FactoryBot.build(:metasploit_credential_pkcs12_with_pkcs12_password)
|
34
|
+
end
|
35
|
+
|
36
|
+
it { is_expected.to be_valid }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'metasploit_credential_pkcs12_with_status' do
|
40
|
+
subject(:metasploit_credential_pkcs12_with_status) do
|
41
|
+
FactoryBot.build(:metasploit_credential_pkcs12_with_status)
|
42
|
+
end
|
43
|
+
|
44
|
+
it { is_expected.to be_valid }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'metasploit_credential_pkcs12_with_ca_and_adcs_template' do
|
48
|
+
subject(:metasploit_credential_pkcs12_with_ca_and_adcs_template) do
|
49
|
+
FactoryBot.build(:metasploit_credential_pkcs12_with_ca_and_adcs_template)
|
50
|
+
end
|
51
|
+
|
52
|
+
it { is_expected.to be_valid }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'metasploit_credential_pkcs12_with_ca_and_adcs_template_and_pkcs12_password' do
|
56
|
+
subject(:metasploit_credential_pkcs12_with_ca_and_adcs_template_and_pkcs12_password) do
|
57
|
+
FactoryBot.build(:metasploit_credential_pkcs12_with_ca_and_adcs_template_and_pkcs12_password)
|
58
|
+
end
|
59
|
+
|
60
|
+
it { is_expected.to be_valid }
|
61
|
+
end
|
12
62
|
end
|
13
63
|
|
14
64
|
context 'validations' do
|
@@ -105,6 +155,194 @@ RSpec.describe Metasploit::Credential::Pkcs12, type: :model do
|
|
105
155
|
it { is_expected.to include(error) }
|
106
156
|
end
|
107
157
|
end
|
158
|
+
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context '#data' do
|
163
|
+
it 'returns the base64 encoded pkcs12' do
|
164
|
+
cert = 'mycert'
|
165
|
+
data = Base64.strict_encode64(cert)
|
166
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data)
|
167
|
+
expect(pkcs12.data).to eq(data)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context '#metadata' do
|
172
|
+
let(:cert) { 'mycert' }
|
173
|
+
let(:data) { Base64.strict_encode64(cert) }
|
174
|
+
|
175
|
+
context 'with the CA' do
|
176
|
+
it 'returns the CA in the metadata' do
|
177
|
+
adcs_ca = 'myca'
|
178
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data, metadata: { adcs_ca: adcs_ca })
|
179
|
+
expect(pkcs12.metadata).to eq( { 'adcs_ca' => adcs_ca } )
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'with the Certififate Template' do
|
184
|
+
it 'returns the certificate template in the metadata' do
|
185
|
+
adcs_template = 'mytemplate'
|
186
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data, metadata: { adcs_template: adcs_template })
|
187
|
+
expect(pkcs12.metadata).to eq( { 'adcs_template' => adcs_template } )
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context 'with both the CA and the Certififate Template' do
|
192
|
+
it 'returns the CA and the certificate template in the metadata' do
|
193
|
+
adcs_ca = 'myca'
|
194
|
+
adcs_template = 'mytemplate'
|
195
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data, metadata: { adcs_ca: adcs_ca, adcs_template: adcs_template })
|
196
|
+
expect(pkcs12.metadata).to eq( { 'adcs_ca' => adcs_ca, 'adcs_template' => adcs_template } )
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'with both the CA, the Certififate Template and the cert password' do
|
201
|
+
it 'returns the CA and the certificate template in the metadata' do
|
202
|
+
adcs_ca = 'myca'
|
203
|
+
adcs_template = 'mytemplate'
|
204
|
+
pkcs12_password = 'mypassword'
|
205
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data, metadata: { adcs_ca: adcs_ca, adcs_template: adcs_template, pkcs12_password: pkcs12_password })
|
206
|
+
expect(pkcs12.metadata).to eq( { 'adcs_ca' => adcs_ca, 'adcs_template' => adcs_template, 'pkcs12_password' => pkcs12_password } )
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context '#adcs_ca' do
|
212
|
+
it 'returns the CA' do
|
213
|
+
cert = 'mycert'
|
214
|
+
data = Base64.strict_encode64(cert)
|
215
|
+
adcs_ca = 'myca'
|
216
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data, metadata: { adcs_ca: adcs_ca })
|
217
|
+
expect(pkcs12.adcs_ca).to eq(adcs_ca)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
context '#adcs_template' do
|
222
|
+
it 'returns the certificate template' do
|
223
|
+
cert = 'mycert'
|
224
|
+
data = Base64.strict_encode64(cert)
|
225
|
+
adcs_template = 'mytemplate'
|
226
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data, metadata: { adcs_template: adcs_template })
|
227
|
+
expect(pkcs12.adcs_template).to eq(adcs_template)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
context '#pkcs12_password' do
|
232
|
+
it 'returns the Pkcs12 password' do
|
233
|
+
cert = 'mycert'
|
234
|
+
data = Base64.strict_encode64(cert)
|
235
|
+
pkcs12_password = 'mypassword'
|
236
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: data, metadata: { pkcs12_password: pkcs12_password })
|
237
|
+
expect(pkcs12.pkcs12_password).to eq(pkcs12_password)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
context '#openssl_pkcs12' do
|
242
|
+
subject { FactoryBot.build(:metasploit_credential_pkcs12).openssl_pkcs12 }
|
243
|
+
|
244
|
+
it { is_expected.to be_a OpenSSL::PKCS12 }
|
245
|
+
|
246
|
+
it 'raises an exception if data is not a base64-encoded certificate' do
|
247
|
+
expect {
|
248
|
+
FactoryBot.build(:metasploit_credential_pkcs12, data: 'wrong_cert').openssl_pkcs12
|
249
|
+
}.to raise_error(ArgumentError)
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'returns the expected OpenSSL::PKCS12' do
|
253
|
+
subject = '/C=FR/O=Yeah/OU=Yeah/CN=Yeah'
|
254
|
+
issuer = '/C=FR/O=Issuer1/OU=Issuer1/CN=Issuer1'
|
255
|
+
pkcs12 = FactoryBot.build(
|
256
|
+
:metasploit_credential_pkcs12,
|
257
|
+
signing_algorithm: 'SHA512',
|
258
|
+
subject: subject,
|
259
|
+
issuer: issuer
|
260
|
+
)
|
261
|
+
openssl_pkcs12 = pkcs12.openssl_pkcs12
|
262
|
+
expect(openssl_pkcs12.certificate.signature_algorithm).to eq("sha512WithRSAEncryption")
|
263
|
+
expect(openssl_pkcs12.certificate.subject.to_s).to eq(subject)
|
264
|
+
expect(openssl_pkcs12.certificate.issuer.to_s).to eq(issuer)
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
context '#to_s' do
|
269
|
+
let(:subject) { '/C=FR/O=Yeah/OU=Yeah/CN=Yeah' }
|
270
|
+
let(:issuer) { '/C=FR/O=Issuer1/OU=Issuer1/CN=Issuer1' }
|
271
|
+
let(:adcs_ca) { 'myca' }
|
272
|
+
let(:adcs_template) { 'mytemplate' }
|
273
|
+
let(:pkcs12_password) { 'mypassword' }
|
274
|
+
|
275
|
+
context 'with the pkcs21 only' do
|
276
|
+
it 'returns the expected string' do
|
277
|
+
pkcs12 = FactoryBot.build(
|
278
|
+
:metasploit_credential_pkcs12,
|
279
|
+
subject: subject,
|
280
|
+
issuer: issuer
|
281
|
+
)
|
282
|
+
expect(pkcs12.to_s).to eq("subject:#{subject},issuer:#{issuer}")
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
context 'with the pkcs21 and the CA' do
|
287
|
+
it 'returns the expected string' do
|
288
|
+
pkcs12 = FactoryBot.build(
|
289
|
+
:metasploit_credential_pkcs12_with_ca,
|
290
|
+
subject: subject,
|
291
|
+
issuer: issuer,
|
292
|
+
metadata: { adcs_ca: adcs_ca }
|
293
|
+
)
|
294
|
+
expect(pkcs12.to_s).to eq("subject:#{subject},issuer:#{issuer},ADCS CA:#{adcs_ca}")
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
context 'with the pkcs21 and the ADCS template' do
|
299
|
+
it 'returns the expected string' do
|
300
|
+
pkcs12 = FactoryBot.build(
|
301
|
+
:metasploit_credential_pkcs12_with_adcs_template,
|
302
|
+
subject: subject,
|
303
|
+
issuer: issuer,
|
304
|
+
metadata: { adcs_template: adcs_template }
|
305
|
+
)
|
306
|
+
expect(pkcs12.to_s).to eq("subject:#{subject},issuer:#{issuer},ADCS template:#{adcs_template}")
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
context 'with the pkcs21, the CA and the ADCS template' do
|
311
|
+
it 'returns the expected string' do
|
312
|
+
subject = '/C=FR/O=Yeah/OU=Yeah/CN=Yeah'
|
313
|
+
issuer = '/C=FR/O=Issuer1/OU=Issuer1/CN=Issuer1'
|
314
|
+
pkcs12 = FactoryBot.build(
|
315
|
+
:metasploit_credential_pkcs12_with_ca_and_adcs_template,
|
316
|
+
subject: subject,
|
317
|
+
issuer: issuer,
|
318
|
+
metadata: { adcs_ca: adcs_ca, adcs_template: adcs_template }
|
319
|
+
)
|
320
|
+
expect(pkcs12.to_s).to eq("subject:#{subject},issuer:#{issuer},ADCS CA:#{adcs_ca},ADCS template:#{adcs_template}")
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
context 'with the pkcs21, the CA, the ADCS template and the pkcs12 password' do
|
325
|
+
it 'returns the expected string' do
|
326
|
+
subject = '/C=FR/O=Yeah/OU=Yeah/CN=Yeah'
|
327
|
+
issuer = '/C=FR/O=Issuer1/OU=Issuer1/CN=Issuer1'
|
328
|
+
pkcs12_password = 'mypassword'
|
329
|
+
pkcs12 = FactoryBot.build(
|
330
|
+
:metasploit_credential_pkcs12_with_ca_and_adcs_template_and_pkcs12_password,
|
331
|
+
subject: subject,
|
332
|
+
issuer: issuer,
|
333
|
+
pkcs12_password: pkcs12_password,
|
334
|
+
metadata: { adcs_ca: adcs_ca, adcs_template: adcs_template, pkcs12_password: pkcs12_password }
|
335
|
+
)
|
336
|
+
# The Pkcs12 password is voluntarily not included
|
337
|
+
expect(pkcs12.to_s).to eq("subject:#{subject},issuer:#{issuer},ADCS CA:#{adcs_ca},ADCS template:#{adcs_template}")
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
context 'with no data' do
|
342
|
+
it 'returns an empty string' do
|
343
|
+
pkcs12 = FactoryBot.build(:metasploit_credential_pkcs12, data: nil)
|
344
|
+
expect(pkcs12.to_s).to eq('')
|
345
|
+
end
|
108
346
|
end
|
109
347
|
end
|
110
348
|
|
@@ -126,6 +126,15 @@ RSpec.describe Metasploit::Credential::Private, type: :model do
|
|
126
126
|
:type,
|
127
127
|
type: :string
|
128
128
|
|
129
|
+
it_should_behave_like 'search_attribute',
|
130
|
+
:data,
|
131
|
+
type: :string
|
132
|
+
|
133
|
+
it_should_behave_like 'search_attribute',
|
134
|
+
:metadata,
|
135
|
+
type: :jsonb
|
136
|
+
|
137
|
+
|
129
138
|
it_should_behave_like 'search_with',
|
130
139
|
Metasploit::Credential::Search::Operator::Type,
|
131
140
|
name: :type,
|
metadata
CHANGED
@@ -1,40 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metasploit-credential
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Metasploit Hackers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIERDCCAqygAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBttc2Zk
|
14
|
-
ZXYvREM9bWV0YXNwbG9pdC9EQz1jb20wHhcNMjMxMDMwMTYwNDI1WhcNMjUxMDI5
|
15
|
-
MTYwNDI1WjAmMSQwIgYDVQQDDBttc2ZkZXYvREM9bWV0YXNwbG9pdC9EQz1jb20w
|
16
|
-
ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDZN/EKv+yVjwiKWvjAVhjF
|
17
|
-
aWNYI0E9bJ5d1qKd29omRYX9a+OOKBCu5+394fyF5RjwU4mYGr2iopX9ixRJrWXH
|
18
|
-
ojs70tEvV1CmvP9rhz7JKzQQoJOkinrz4d+StIylxVxVdgm7DeiB3ruTwvl7qKUv
|
19
|
-
piWzhrBFiVU6XIEAwq6wNEmnv2D+Omyf4h0Tf99hc6G0QmBnU3XydqvnZ+AzUbBV
|
20
|
-
24RH3+NQoigLbvK4M5aOeYhk19di58hznebOw6twHzNczshrBeMFQp985ScNgsvF
|
21
|
-
rL+7HNNwpcpngERwZfzDNn7iYN5X3cyvTcykShtsuPMa5zXsYo42LZrsTF87DW38
|
22
|
-
D8sxL6Dgdqu25Mltdw9m+iD4rHSfb1KJYEoNO+WwBJLO2Y4d6G1CR66tVeWsZspb
|
23
|
-
zneOVC+sDuil7hOm+6a7Y2yrrRyT6IfL/07DywjPAIRUp5+Jn8ZrkWRNo2AOwWBG
|
24
|
-
k5gz7SfJPHuyVnPlxoMA0MTFCUnnnbyHu882TGoJGgMCAwEAAaN9MHswCQYDVR0T
|
25
|
-
BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFIQfNa4E889ZE334cwU7eNu2hScH
|
26
|
-
MCAGA1UdEQQZMBeBFW1zZmRldkBtZXRhc3Bsb2l0LmNvbTAgBgNVHRIEGTAXgRVt
|
27
|
-
c2ZkZXZAbWV0YXNwbG9pdC5jb20wDQYJKoZIhvcNAQELBQADggGBAMfzvKcV27p7
|
28
|
-
pctmpW2JmIXLMrjNLyGJAxELH/t9pJueXdga7uj2fJkYQDbwGw5x4MGyFqhqJLH4
|
29
|
-
l/qsUF3PyAXDTSWLVaqXQVWO+IIHxecG0XjPXTNudzMU0hzqbqiBKvsW7/a3V5BP
|
30
|
-
SWlFzrFkoXWlPouFpoakyYMJjpW4SGdPzRv7pM4OhXtkXpHiRvx5985FrHgHlI89
|
31
|
-
NSIuIUbp8zqk4hP1i9MV0Lc/vTf2gOmo+RHnjqG1NiYfMCYyY/Mcd4W36kGOl468
|
32
|
-
I8VDTwgCufkAzFu7BJ5yCOueqtDcuq+d3YhAyU7NI4+Ja8EwazOnB+07sWhKpg7z
|
33
|
-
yuQ1mWYPmZfVQpoSVv1CvXsoqJYXVPBBLOacKKSj8ArVG6pPn9Bej7IOQdblaFjl
|
34
|
-
DgscAao7wB3xW2BWEp1KnaDWkf1x9ttgoBEYyuYwU7uatB67kBQG1PKvLt79wHvz
|
35
|
-
Dxs+KOjGbBRfMnPgVGYkORKVrZIwlaboHbDKxcVW5xv+oZc7KYXWGg==
|
36
|
-
-----END CERTIFICATE-----
|
37
|
-
date: 2025-02-06 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-04-02 00:00:00.000000000 Z
|
38
12
|
dependencies:
|
39
13
|
- !ruby/object:Gem::Dependency
|
40
14
|
name: metasploit-concern
|
@@ -231,6 +205,7 @@ files:
|
|
231
205
|
- db/migrate/20161107153145_recreate_index_on_private_data_and_type.rb
|
232
206
|
- db/migrate/20161107203710_create_index_on_private_data_and_type_for_ssh_key.rb
|
233
207
|
- db/migrate/20221209005658_create_index_on_private_data_and_type_for_pkcs12.rb
|
208
|
+
- db/migrate/20250204172657_add_metadata_to_metasploit_credential_privates.rb
|
234
209
|
- lib/metasploit/credential.rb
|
235
210
|
- lib/metasploit/credential/case_insensitive_serializer.rb
|
236
211
|
- lib/metasploit/credential/core_validations.rb
|
@@ -367,7 +342,7 @@ homepage: https://github.com/rapid7/metasploit-credential
|
|
367
342
|
licenses:
|
368
343
|
- BSD-3-clause
|
369
344
|
metadata: {}
|
370
|
-
post_install_message:
|
345
|
+
post_install_message:
|
371
346
|
rdoc_options: []
|
372
347
|
require_paths:
|
373
348
|
- app/models
|
@@ -384,8 +359,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
384
359
|
- !ruby/object:Gem::Version
|
385
360
|
version: '0'
|
386
361
|
requirements: []
|
387
|
-
rubygems_version: 3.4.
|
388
|
-
signing_key:
|
362
|
+
rubygems_version: 3.4.19
|
363
|
+
signing_key:
|
389
364
|
specification_version: 4
|
390
365
|
summary: Credential models for metasploit-framework and Metasploit Pro
|
391
366
|
test_files:
|
checksums.yaml.gz.sig
DELETED
Binary file
|
data.tar.gz.sig
DELETED
Binary file
|
metadata.gz.sig
DELETED
Binary file
|