-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report CA, ADCS Template and Password along with Pkcs12 in the database #19736
base: master
Are you sure you want to change the base?
Report CA, ADCS Template and Password along with Pkcs12 in the database #19736
Conversation
@@ -414,11 +420,13 @@ def creds_search(*args) | |||
when 'password' | |||
Metasploit::Credential::Password | |||
when 'hash' | |||
Metasploit::Credential::PasswordHash | |||
Metasploit::Credential::NonreplayableHash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently hash
corresponds to a Nonreplayable hash instead of a PasswordHash. This change were required otherwise the specs were failing.
# realm: nil, | ||
# workspace: framework.db.workspace) | ||
# end | ||
let!(:ntlm_core) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are now working properly. I've added them back even if it is not related to the changes in this PR.
gem 'metasploit-credential', git: 'https://github.com/cdelafuente-r7/metasploit-credential', branch: 'enh/MS-9710/add_pkcs12_metadata' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be reverted before landing.
Gemfile.lock
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file will need to be updated to point to the new metasploit-credential
gem is available instead of the this feature branch.
4c5a365
to
c44cad3
Compare
…base - Update the `creds` command to add Pkcs12 private credentials with metadata. - Update `ms_icpr` module to store metadata.
c44cad3
to
3581724
Compare
fddd218
to
91ff4ce
Compare
…a model - a separate field is now used for metadata (`private_metadata`) when creating a new Pkcs12 - the `creds` command now support adding an encrypted Pkcs12 with a password
91ff4ce
to
7df6dbc
Compare
This adds support to the new Pkcs12 data format added in rapid7/metasploit-credential#183. Now, the CA and ADCS template can be added to the Pkcs12 as metadata in the database.
Also, it is now possible to store a Pkcs12 password as a metadata in the database. If the Pkcs12 is encrypted, the password can (and must) be added to the metadata field. It will be used to decrypt the Pkcs12. The
creds
command has been updated to accept a new optionpkcs12-password
. The validation will fail if the Pkcs12 we want to add withcreds
is encrypted and the password is wrong or empty.This PR needs the
metasploit-credentials
counterpart be landed first. I have updated the Gemfile to point to the feature branch to be able to test it. This will need to be reverted before landing.Verification
Testing
auxiliary/admin/dcerpc/icpr_cert
Follow the instructions here to set up an AD CS server for testing purposes.
msfconsole
use auxiliary/admin/dcerpc/icpr_cert
run verbose=true CA=<CA name> RHOSTS=<remote host> username=<username> password=<user password> CERT_TEMPLATE=User
creds
returns the generated Pkcs12irb
inmsfconsole
if the Pkcs12 model contains the metadata filed with the expected values.Testing
creds
commandmsfconsole
creds add user:testuser pkcs12:<pkcs12 filepath> ca:myca adcs-template:OtherTemplate
creds
returns the generated Pkcs12irb
inmsfconsole
if the Pkcs12 model contains the metadata filed with the expected values.Testing
creds
command with an encrypted Pkcs12 and a passwordFirst we need to get an password protected Pkcs12. We can use
openssl
command with an already retrieved pkcs12, with theauxiliary/admin/dcerpc/icpr_cert
module for example, and set a password. Check the certificate files with theloot
command to get the filepath.Hit Enter when asked for the Import Password (there is no password).
2. Extract client certificate's private key:
Hit Enter when asked for the Import Password (there is no password).
Enter a password for the private key export (e.g.
password
)3. Re-create the PKCS#12
Enter the previous password set when asked for the pass phrase for existingpkcs12_key.pem (e.g.
password
)Enter Export Password:
123456
msfconsole
creds add user:testuser pkcs12:newpkcs12.p12 ca:myca adcs-template:OtherTemplate pkcs12-password:123456
creds
returns the generated Pkcs12irb
inmsfconsole
if the Pkcs12 model contains the metadata filed with the expected values.creds add user:testuser pkcs12:newpkcs12.p12 ca:myca adcs-template:OtherTemplate pkcs12-password:wrongpasswd
Data ArgumentError