2014-12-20 00:41:27 +00:00
|
|
|
# -*- coding: binary -*-
|
|
|
|
require 'rex/proto/kerberos'
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
module Kerberos
|
|
|
|
module Client
|
|
|
|
module AsResponse
|
|
|
|
|
2014-12-21 00:57:49 +00:00
|
|
|
# Extracts the session key from a Kerberos AS Response
|
|
|
|
#
|
2014-12-20 00:41:27 +00:00
|
|
|
# @param res [Rex::Proto::Kerberos::Model::KdcResponse]
|
|
|
|
# @param key [String]
|
|
|
|
# @return [Rex::Proto::Kerberos::Model::EncryptionKey]
|
2014-12-21 07:12:00 +00:00
|
|
|
# @see Rex::Proto::Kerberos::Model::KdcResponse
|
|
|
|
# @see Rex::Proto::Kerberos::Model::EncryptedData.decrypt
|
|
|
|
# @see Rex::Proto::Kerberos::Model::EncKdcResponse
|
|
|
|
# @see Rex::Proto::Kerberos::Model::EncKdcResponse.decode
|
|
|
|
# @see Rex::Proto::Kerberos::Model::EncryptionKey
|
2014-12-20 00:41:27 +00:00
|
|
|
def extract_session_key(res, key)
|
|
|
|
decrypt_res = res.enc_part.decrypt(key, 8)
|
|
|
|
enc_kdc_res = Rex::Proto::Kerberos::Model::EncKdcResponse.decode(decrypt_res)
|
|
|
|
|
|
|
|
enc_kdc_res.key
|
|
|
|
end
|
|
|
|
|
2014-12-21 00:57:49 +00:00
|
|
|
# Extracts the logon time from a Kerberos AS Response
|
|
|
|
#
|
2014-12-20 00:41:27 +00:00
|
|
|
# @param res [Rex::Proto::Kerberos::Model::KdcResponse]
|
|
|
|
# @param key [String]
|
|
|
|
# @return [Fixnum]
|
2014-12-21 07:12:00 +00:00
|
|
|
# @see Rex::Proto::Kerberos::Model::KdcResponse
|
|
|
|
# @see Rex::Proto::Kerberos::Model::EncryptedData.decrypt
|
|
|
|
# @see Rex::Proto::Kerberos::Model::EncKdcResponse
|
|
|
|
# @see Rex::Proto::Kerberos::Model::EncKdcResponse.decode
|
2014-12-20 00:41:27 +00:00
|
|
|
def extract_logon_time(res, key)
|
|
|
|
decrypt_res = res.enc_part.decrypt(key, 8)
|
|
|
|
enc_kdc_res = Rex::Proto::Kerberos::Model::EncKdcResponse.decode(decrypt_res)
|
|
|
|
|
|
|
|
auth_time = enc_kdc_res.auth_time
|
|
|
|
|
|
|
|
auth_time.to_i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|