Make KdcResponse decoding better

bug/bundler_fix
jvazquez-r7 2014-12-14 21:01:09 -06:00
parent 442adb080f
commit c3a2bcf956
4 changed files with 34 additions and 18 deletions

View File

@ -9,13 +9,13 @@ module Rex
# @return [Fixnum] The ticket flags
attr_accessor :options
# @!attribute cname
# @return [Rex::Proto::Kerberos::Type::PrincipalName] The name part of the client's principal identifier
# @return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the client's principal identifier
attr_accessor :cname
# @!attribute realm
# @return [String] The realm part of the server's principal identifier
attr_accessor :realm
# @!attribute sname
# @return [Rex::Proto::Kerberos::Type::PrincipalName] The name part of the server's identity
# @return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the server's identity
attr_accessor :sname
# @!attribute from
# @return [Time] Start time when the ticket is to be postdated
@ -33,7 +33,7 @@ module Rex
# @return [Array<Fixnum>] The desired encryption algorithm to be used in the response
attr_accessor :etype
# @!attribute enc_auth_data
# @return [Rex::Proto::Kerberos::Type::EncryptedData] An encoding of the desired authorization-data encrypted
# @return [Rex::Proto::Kerberos::Model::EncryptedData] An encoding of the desired authorization-data encrypted
attr_accessor :enc_auth_data
# Decodes the Rex::Proto::Kerberos::Model::KdcRequestBody attributes from input

View File

@ -15,16 +15,16 @@ module Rex
# @return [String] The realm part of the client's principal identifier
attr_accessor :crealm
# @!attribute cname
# @return [Rex::Proto::Kerberos::Type::PrincipalName] The name part of the client's principal identifier
# @return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the client's principal identifier
attr_accessor :cname
# @!attribute ticket
# @return [Rex::Proto::Kerberos::Type::PrincipalName] The name part of the client's principal identifier
# @return [Rex::Proto::Kerberos::Model::Ticket] The issued ticket
attr_accessor :ticket
# @!attribute enc_auth_data
# @return [Rex::Proto::Kerberos::Type::EncryptedData] The newly issued ticket
# @!attribute enc_part
# @return [Rex::Proto::Kerberos::Model::EncryptedData] The encrypted part of the response
attr_accessor :enc_part
# Decodes the Rex::Proto::Kerberos::Model::KrbError from an input
# Decodes the Rex::Proto::Kerberos::Model::KdcResponse from an input
#
# @param input [String, OpenSSL::ASN1::ASN1Data] the input to decode from
# @return [self] if decoding succeeds
@ -36,19 +36,19 @@ module Rex
when OpenSSL::ASN1::ASN1Data
decode_asn1(input)
else
raise ::RuntimeError, 'Failed to decode KRB Error, invalid input'
raise ::RuntimeError, 'Failed to decode KdcResponse, invalid input'
end
self
end
def encode
raise ::RuntimeError, 'KrbError encoding not supported'
raise ::RuntimeError, 'KdcResponse encoding not supported'
end
private
# Decodes a Rex::Proto::Kerberos::Model::KrbError from an String
# Decodes a Rex::Proto::Kerberos::Model::KdcResponse from an String
#
# @param input [String] the input to decode from
def decode_string(input)
@ -57,7 +57,7 @@ module Rex
decode_asn1(asn1)
end
# Decodes a Rex::Proto::Kerberos::Model::KrbError
# Decodes a Rex::Proto::Kerberos::Model::KdcResponse
#
# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from
# @raise [RuntimeError] if decoding doesn't succeed
@ -113,6 +113,22 @@ module Rex
def decode_cname(input)
Rex::Proto::Kerberos::Model::PrincipalName.decode(input.value[0])
end
# Decodes the ticket field
#
# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from
# @return [Rex::Proto::Kerberos::Type::Ticket]
def decode_ticket(input)
Rex::Proto::Kerberos::Model::Ticket.decode(input.value[0])
end
# Decodes the enc_part
#
# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from
# @return [Rex::Proto::Kerberos::Model::EncryptedData]
def decode_enc_part(input)
Rex::Proto::Kerberos::Model::EncryptedData.decode(input.value[0])
end
end
end
end

View File

@ -30,13 +30,13 @@ module Rex
# @return [String] The realm part of the client's principal identifier
attr_accessor :crealm
# @!attribute cname
# @return [Rex::Proto::Kerberos::Type::PrincipalName] The name part of the client's principal identifier
# @return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the client's principal identifier
attr_accessor :cname
# @!attribute realm
# @return [String] The realm part of the server's principal identifier
attr_accessor :realm
# @!attribute sname
# @return [Rex::Proto::Kerberos::Type::PrincipalName] The name part of the server's identity
# @return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the server's identity
attr_accessor :sname
# @!attribute e_data
# @return [String] additional data about the error (ASN.1 encoded data)
@ -179,7 +179,7 @@ module Rex
# Decodes the cname field
#
# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from
# @return [Rex::Proto::Kerberos::Type::PrincipalName]
# @return [Rex::Proto::Kerberos::Model::PrincipalName]
def decode_cname(input)
Rex::Proto::Kerberos::Model::PrincipalName.decode(input.value[0])
end
@ -195,7 +195,7 @@ module Rex
# Decodes the sname field
#
# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from
# @return [Rex::Proto::Kerberos::Type::PrincipalName]
# @return [Rex::Proto::Kerberos::Model::PrincipalName]
def decode_sname(input)
Rex::Proto::Kerberos::Model::PrincipalName.decode(input.value[0])
end

View File

@ -12,10 +12,10 @@ module Rex
# @return [String] The realm that issued the ticket
attr_accessor :realm
# @!attribute sname
# @return [Rex::Proto::Kerberos::Type::PrincipalName] The name part of the server's identity
# @return [Rex::Proto::Kerberos::Model::PrincipalName] The name part of the server's identity
attr_accessor :sname
# @!attribute enc_part
# @return [Rex::Proto::Kerberos::Type::EncryptedData] An encrypted part of the ticket
# @return [Rex::Proto::Kerberos::Model::EncryptedData] The encrypted part of the ticket
attr_accessor :enc_part
# Decodes the Rex::Proto::Kerberos::Model::KrbError from an input