Path: blob/master/lib/rex/proto/gss/channel_binding.rb
19812 views
require 'rubyntlm'12module Rex::Proto::Gss3class ChannelBinding < Net::NTLM::ChannelBinding4attr_reader :digest_algorithm5def initialize(channel_data, unique_prefix: 'tls-server-end-point', digest_algorithm: 'SHA256')6super(channel_data)7@unique_prefix = unique_prefix8@digest_algorithm = digest_algorithm9end1011def channel_hash12@channel_hash ||= OpenSSL::Digest.new(@digest_algorithm, channel)13end1415def self.create(peer_cert)16super(peer_cert.to_der)17end1819def self.from_tls_cert(peer_cert)20digest_algorithm = 'SHA256'21if peer_cert.signature_algorithm22# see: https://learn.microsoft.com/en-us/archive/blogs/openspecification/ntlm-and-channel-binding-hash-aka-extended-protection-for-authentication23normalized_name = OpenSSL::Digest.new(peer_cert.signature_algorithm).name.upcase24unless %[ MD5 SHA1 ].include?(normalized_name)25digest_algorithm = normalized_name26end27end2829new(peer_cert.to_der, unique_prefix: 'tls-server-end-point', digest_algorithm: digest_algorithm)30end31end32end333435