Esempio n. 1
0
        /// <summary>
        /// Decode the KRB_ERROR token got from application.
        /// </summary>
        /// <param name="errorToken">The token got from an application message. This argument cannot be null.</param>
        /// <returns>The decoded AP response.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when the input parameter is null.</exception>
        /// <exception cref="System.FormatException">Thrown when the errorToken is not valid.</exception>
        public KileKrbError ParseKrbError(byte[] errorToken)
        {
            if (errorToken == null)
            {
                throw new ArgumentNullException(nameof(errorToken));
            }

            byte[] errorBody = KerberosUtility.VerifyGssApiTokenHeader(errorToken);

            // Check if it has a two-byte tok_id
            if (errorBody == null || errorBody.Length <= sizeof(TOK_ID))
            {
                throw new FormatException("Not a valid KRB_ERROR token!");
            }

            TOK_ID id = (TOK_ID)KerberosUtility.ConvertEndian(BitConverter.ToUInt16(errorBody, 0));

            if (id != TOK_ID.KRB_ERROR)
            {
                throw new FormatException("Not a valid KRB_ERROR token!");
            }

            errorBody = ArrayUtility.SubArray(errorBody, sizeof(TOK_ID));
            var error = new KileKrbError();

            error.FromBytes(errorBody);
            return(error);
        }
Esempio n. 2
0
        /// <summary>
        /// Create and send malformed Kpassword Request
        /// </summary>
        /// <param name="newPwd">The new password to change</param>
        public void SendMalformedKpasswordRequest(string newPwd)
        {
            KpasswordRequest pwdRequest = this.CreateKpasswordRequest(newPwd);

            //Change the protocol version number(hex constant 0x0001) to be 0xff80
            pwdRequest.version = KerberosUtility.ConvertEndian(0xff80);
            this.SendPdu(pwdRequest);
            this.testSite.Log.Add(LogEntryKind.Comment, "Send malformed Kpassword request.");
        }