Skip to content
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

Fix error when printing ticket contents from a kirbi file format #17468

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/msf/core/exploit/remote/kerberos/ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def print_contents(path, key: nil)
elsif kirbi?(header)
print_status "Kirbi File:#{path}"
krb_cred = Rex::Proto::Kerberos::Model::KrbCred.decode(File.binread(path))
ccache = kirbi_to_ccache(krb_cred)
ccache = Msf::Exploit::Remote::Kerberos::TicketConverter.kirbi_to_ccache(krb_cred)
print_ccache_contents(ccache, key: key)
else
fail_with(Msf::Module::Failure::BadConfig, 'Unknown file format')
Expand Down
40 changes: 31 additions & 9 deletions modules/auxiliary/admin/kerberos/inspect_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,44 @@ def get_enc_key
end

def validate_key
if datastore['NTHASH'].blank? && datastore['AES_KEY'].blank?
return nil
elsif datastore['NTHASH'].present? && datastore['AES_KEY'].present?
if datastore['NTHASH'].present? && datastore['AES_KEY'].present?
fail_with(Msf::Exploit::Failure::BadConfig, 'NTHASH and AES_KEY may not both be set for inspecting a ticket')
end

if datastore['NTHASH'].present? && datastore['NTHASH'].size != 32
fail_with(Msf::Exploit::Failure::BadConfig, "NTHASH length was #{datastore['NTHASH'].size}. It should be 32")
if datastore['NTHASH'].present?
key_type = :nthash
elsif datastore['AES_KEY'].present?
key_type = :aes_key
else
return datastore['NTHASH']
key_type = nil
end

if datastore['AES_KEY'].present? && (datastore['AES_KEY'].size != 32 && datastore['AES_KEY'].size != 64)
fail_with(Msf::Exploit::Failure::BadConfig, "AES key length was #{datastore['AES_KEY'].size}. It should be 32 or 64")
case key_type
when :nthash
key = validate_nthash(datastore['NTHASH'])
when :aes_key
key = validate_aes_key(datastore['AES_KEY'])
else
return datastore['AES_KEY']
print_status('No decryption key provided proceeding without decryption.')
key = nil
end

key
end

def validate_nthash(nthash)
if nthash.size != 32
fail_with(Msf::Exploit::Failure::BadConfig, "NTHASH length was #{nthash.size}. It should be 32")
else
nthash
end
end

def validate_aes_key(aes_key)
if aes_key.size != 32 && aes_key.size != 64
fail_with(Msf::Exploit::Failure::BadConfig, "AES key length was #{aes_key.size}. It should be 32 or 64")
else
aes_key
end
end
end
Loading