示例#1
0
        private SPNEGONegTokenInit Decode(byte[] data)
        {
            SPNEGONegTokenInit spnegoNegTokenInit = new SPNEGONegTokenInit
            {
                MechTypes = ASN1.GetTagBytes(6, data),
                MechToken = ASN1.GetTagBytes(4, data)
            };

            return(spnegoNegTokenInit);
        }
示例#2
0
 public NTLMNegotiate(byte[] data, bool decode)
 {
     if (decode)
     {
         SPNEGONegTokenInit token = this.Decode(data);
         this.ReadBytes(token.MechToken, 0);
     }
     else
     {
         ReadBytes(data, 0);
     }
 }
示例#3
0
        public NTLMHelper(byte[] data)
        {
            string signature = Encoding.UTF8.GetString(data);

            if (signature.StartsWith("NTLMSSP"))
            {
                ReadBytes(data, 0);
            }
            else
            {
                SPNEGONegTokenInit token = this.Decode(data);
                this.ReadBytes(token.MechToken, 0);
            }
        }
        public void EncodeBuffer()
        {
            GSSAPIInitSecContext gssapi = new GSSAPIInitSecContext();
            SPNEGONegTokenInit   spnego = new SPNEGONegTokenInit();

            spnego.MechTypes = new byte[24] {
                0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x02, 0x1e, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x02, 0x0a
            };
            spnego.MechToken = new byte[264] {
                0x4e, 0x45, 0x47, 0x4f, 0x45, 0x58, 0x54, 0x53, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x45, 0x42, 0x37, 0xe2, 0x9c, 0xec, 0xed, 0x6a, 0x73, 0x8a, 0x3e, 0x19, 0x27, 0xdc, 0xa0, 0xb0, 0x64, 0x56, 0x91, 0x92, 0xb4, 0x5c, 0x3d, 0x8d, 0xba, 0x32, 0xd3, 0xb1, 0x31, 0xbc, 0xab, 0x29, 0xfa, 0x47, 0x3d, 0xeb, 0x87, 0x6e, 0x53, 0xd7, 0x0c, 0x91, 0x91, 0xb1, 0xae, 0x9e, 0x6b, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x33, 0x53, 0x0d, 0xea, 0xf9, 0x0d, 0x4d, 0xb2, 0xec, 0x4a, 0xe3, 0x78, 0x6e, 0xc3, 0x08, 0x4e, 0x45, 0x47, 0x4f, 0x45, 0x58, 0x54, 0x53, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x45, 0x42, 0x37, 0xe2, 0x9c, 0xec, 0xed, 0x6a, 0x73, 0x8a, 0x3e, 0x19, 0x27, 0xdc, 0xa0, 0xb0, 0x5c, 0x33, 0x53, 0x0d, 0xea, 0xf9, 0x0d, 0x4d, 0xb2, 0xec, 0x4a, 0xe3, 0x78, 0x6e, 0xc3, 0x08, 0x40, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x30, 0x56, 0xa0, 0x54, 0x30, 0x52, 0x30, 0x27, 0x80, 0x25, 0x30, 0x23, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x18, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x4b, 0x65, 0x79, 0x30, 0x27, 0x80, 0x25, 0x30, 0x23, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x18, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x4b, 0x65, 0x79
            };
            byte[] mechTokenSegment = ASN1.Encode(4, spnego.MechToken);
            mechTokenSegment = ASN1.Encode(162, mechTokenSegment);
            byte[] mechTypesSegment = ASN1.Encode(48, spnego.MechTypes);
            mechTypesSegment = ASN1.Encode(160, mechTypesSegment);
            byte[] negTokenInitSegment = Utilities.BlockCopy(mechTypesSegment, mechTokenSegment);
            negTokenInitSegment = ASN1.Encode(48, negTokenInitSegment);
            negTokenInitSegment = ASN1.Encode(160, negTokenInitSegment);
            byte[] gssapiData = Utilities.BlockCopy(gssapi.OID, negTokenInitSegment);
            this.Buffer = ASN1.Encode(96, gssapiData);
        }