Path: blob/master/lib/rex/proto/gss/asn1.rb
19813 views
module Rex::Proto::Gss::Asn11#2# GSS has some "pseudo-asn1" to wrap up tokens. This function parses that wrapping, extracts3# the mechanism specified, and returns it and the token following it4def unwrap_pseudo_asn1(token)5start_of_token = nil6mech_id = nil7# This bit is pseudo-ASN1 - we parse up until the OID, then take note of where we got up8# to, and continue parsing from there.9OpenSSL::ASN1.traverse(token) do | depth, offset, header_len, length, constructed, tag_class, tag|10component = token[offset, header_len+length]11if depth == 1 && tag_class == :UNIVERSAL && tag == 612mech_id = OpenSSL::ASN1.decode(component)13start_of_token = offset+header_len+length14break15end16end1718[mech_id, token[start_of_token, token.length - start_of_token]]19end2021def wrap_pseudo_asn1(mech_id, token)22OpenSSL::ASN1::ASN1Data.new(23[24mech_id,25token26],270,28:APPLICATION29).to_der30end31end323334