Reorganize the Crypto mixin

bug/bundler_fix
jvazquez-r7 2014-12-22 11:57:35 -06:00
parent 277ec92358
commit ff208002d7
15 changed files with 22 additions and 36 deletions

View File

@ -43,7 +43,7 @@ module Msf
def build_as_pa_time_stamp(opts = {})
time_stamp = opts[:time_stamp] || Time.now
pausec = opts[:pausec] || 0
etype = opts[:etype] || Rex::Proto::Kerberos::Model::KERB_ETYPE_RC4_HMAC
etype = opts[:etype] || Rex::Proto::Kerberos::Crypto::RC4_HMAC
key = opts[:key] || ''
pa_time_stamp = Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp.new(
@ -86,7 +86,7 @@ module Msf
till = opts[:till] || Time.utc('1970-01-01-01 00:00:00')
rtime = opts[:rtime] || Time.utc('1970-01-01-01 00:00:00')
nonce = opts[:nonce] || Rex::Text.rand_text_numeric(6).to_i
etype = opts[:etype] || [Rex::Proto::Kerberos::Model::KERB_ETYPE_RC4_HMAC]
etype = opts[:etype] || [Rex::Proto::Kerberos::Crypto::RC4_HMAC]
cname = opts[:cname] || build_client_name(opts)
realm = opts[:realm] || ''
sname = opts[:sname] || build_server_name(opts)

View File

@ -48,7 +48,7 @@ module Msf
domain_name = opts[:realm] || ''
domain_id = opts[:domain_id] || 'S-1-1'
logon_time = opts[:logon_time] || Time.now
checksum_type = opts[:checksum_type] || Rex::Proto::Kerberos::Crypto::RsaMd5::RSA_MD5
checksum_type = opts[:checksum_type] || Rex::Proto::Kerberos::Crypto::RSA_MD5
logon_info = Rex::Proto::Kerberos::Pac::LogonInfo.new(
logon_time: logon_time,

View File

@ -228,7 +228,7 @@ module Msf
till = opts[:till] || Time.utc('1970-01-01-01 00:00:00')
rtime = opts[:rtime] || Time.utc('1970-01-01-01 00:00:00')
nonce = opts[:nonce] || Rex::Text.rand_text_numeric(6).to_i
etype = opts[:etype] || [Rex::Proto::Kerberos::Model::KERB_ETYPE_RC4_HMAC]
etype = opts[:etype] || [Rex::Proto::Kerberos::Crypto::RC4_HMAC]
cname = opts[:cname] || build_client_name(opts)
realm = opts[:realm] || ''
sname = opts[:sname] || build_server_name(opts)

View File

@ -1,13 +1,18 @@
# -*- coding: binary -*-
require 'rex/proto/kerberos/crypto/rc4_hmac'
require 'rex/proto/kerberos/crypto/rsa_md5'
module Rex
module Proto
module Kerberos
module Crypto
include Rex::Proto::Kerberos::Crypto::Rc4Hmac
include Rex::Proto::Kerberos::Crypto::RsaMd5
RSA_MD5 = 7
RC4_HMAC = 23
end
end
end
end
require 'rex/proto/kerberos/crypto/rc4_hmac'
require 'rex/proto/kerberos/crypto/rsa_md5'
end

View File

@ -5,9 +5,6 @@ module Rex
module Kerberos
module Crypto
module RsaMd5
# Checksum identifier
RSA_MD5 = 7
def checksum_rsa_md5(data)
md5 = OpenSSL::Digest::MD5.new
md5 << data

View File

@ -62,9 +62,6 @@ module Rex
PA_PW_SALT = 3
PA_PAC_REQUEST = 128
# From RFC-4757: The RC4-HMAC Kerberos Encryption Types Used by Microsoft Windows
KERB_ETYPE_RC4_HMAC = 23
AD_IF_RELEVANT = 1
end
end

View File

@ -8,8 +8,6 @@ module Rex
# ticket to the server to certify the client's knowledge of the encryption
# key in the ticket.
class Authenticator < Element
include Rex::Proto::Kerberos::Crypto::Rc4Hmac
# @!attribute vno
# @return [Fixnum] The authenticator version number
attr_accessor :vno
@ -71,7 +69,7 @@ module Rex
res = ''
case etype
when KERB_ETYPE_RC4_HMAC
when RC4_HMAC
res = encrypt_rc4_hmac(data, key, 7)
else
raise ::RuntimeError, 'EncryptedData schema is not supported'

View File

@ -7,9 +7,6 @@ module Rex
# This class provides a representation of a Kerberos AuthorizationData data
# definition.
class AuthorizationData < Element
include Rex::Proto::Kerberos::Crypto::Rc4Hmac
# @!attribute elements
# @return [Hash{Symbol => <Fixnum, String>}] The type of the authorization data
# @option [Fixnum] :type
@ -52,7 +49,7 @@ module Rex
res = ''
case etype
when KERB_ETYPE_RC4_HMAC
when RC4_HMAC
res = encrypt_rc4_hmac(data, key, 5)
else
raise ::RuntimeError, 'EncryptedData schema is not supported'

View File

@ -8,6 +8,7 @@ module Rex
# workstation user or a network server) on a network.
class Element
include Rex::Proto::Kerberos::Crypto
include Rex::Proto::Kerberos::Model
def self.attr_accessor(*vars)

View File

@ -6,9 +6,6 @@ module Rex
module Model
# This class provides a representation of an encrypted message.
class EncryptedData < Element
include Rex::Proto::Kerberos::Crypto::Rc4Hmac
# @!attribute name_type
# @return [Fixnum] The encryption algorithm
attr_accessor :etype
@ -71,7 +68,7 @@ module Rex
res = ''
case etype
when KERB_ETYPE_RC4_HMAC
when RC4_HMAC
res = decrypt_rc4_hmac(cipher, key, msg_type)
raise ::RuntimeError, 'EncryptedData failed to decrypt' if res.length < 8
res = res[8, res.length - 1]

View File

@ -7,9 +7,6 @@ module Rex
# This class provides a representation of a Kerberos KDC-REQ-BODY (request body) data
# definition
class KdcRequestBody < Element
include Rex::Proto::Kerberos::Crypto::RsaMd5
# @!attribute options
# @return [Fixnum] The ticket flags
attr_accessor :options

View File

@ -8,8 +8,6 @@ module Rex
# as pre authenticated data
class PreAuthEncTimeStamp < Element
include Rex::Proto::Kerberos::Crypto::Rc4Hmac
CRYPTO_MSG_TYPE = 1
# @!attribute pa_time_stamp
@ -59,7 +57,7 @@ module Rex
res = ''
case etype
when KERB_ETYPE_RC4_HMAC
when RC4_HMAC
res = encrypt_rc4_hmac(data, key, CRYPTO_MSG_TYPE)
else
raise ::RuntimeError, 'EncryptedData schema is not supported'

View File

@ -6,6 +6,7 @@ module Rex
module Pac
class Element
include Rex::Proto::Kerberos::Crypto
include Rex::Proto::Kerberos::Pac
def self.attr_accessor(*vars)

View File

@ -8,8 +8,6 @@ module Rex
# of the PAC.
class Type < Element
include Rex::Proto::Kerberos::Crypto::RsaMd5
# @!attribute buffers
# @return [Array<Rex::Text::Proto::Kerberos::Pac::Element>] The array of PAC_INFO_BUFFER structures
attr_accessor :buffers

View File

@ -21,7 +21,7 @@ describe Msf::Kerberos::Client::Pac do
:realm => 'DOMAIN',
:domain_id => 'S-1-5-21-1755879683-3641577184-3486455962',
:logon_time => Time.utc(2014),
:checksum_type => Rex::Proto::Kerberos::Crypto::RsaMd5::RSA_MD5
:checksum_type => Rex::Proto::Kerberos::Crypto::RSA_MD5
}
end
@ -33,7 +33,7 @@ describe Msf::Kerberos::Client::Pac do
it "creates a PAC-TYPE with default checksum type" do
pac = subject.build_pac
expect(pac.checksum).to eq(Rex::Proto::Kerberos::Crypto::RsaMd5::RSA_MD5)
expect(pac.checksum).to eq(Rex::Proto::Kerberos::Crypto::RSA_MD5)
end
it "creates a PAC-TYPE with default data in buffers" do
@ -49,7 +49,7 @@ describe Msf::Kerberos::Client::Pac do
it "creates a PAC-TYPE with provided checksum type" do
pac = subject.build_pac(pac_opts)
expect(pac.checksum).to eq(Rex::Proto::Kerberos::Crypto::RsaMd5::RSA_MD5)
expect(pac.checksum).to eq(Rex::Proto::Kerberos::Crypto::RSA_MD5)
end
it "creates a PAC-TYPE with provided data in buffers" do