public static NtChallengeResponseFields CreateNtChallengeResponseFields(ChallengeMessage challengeMessage, string strUserName, byte[] passwordNTHash, ref uint payloadPointer) { var np = NTLMV2Response.CreateNTLMV2Response(challengeMessage, strUserName, passwordNTHash); var t = new NtChallengeResponseFields(payloadPointer, np); payloadPointer += t.NtChallengeResponseLen; return(t); }
public AuthenticateMessage( MetaDataPayloadHex lmChallengeResponseField, NtChallengeResponseFields ntChallengeResponseField, MetaDataPayloadString domainNameField, MetaDataPayloadString userNameField, MetaDataPayloadString workstationField, MetaDataPayloadString encryptedRandomSessionKeyField, NegotiateFlags negotiateFlag, Versions version ) { LmChallengeResponseField = lmChallengeResponseField; NtChallengeResponseField = ntChallengeResponseField; DomainNameField = domainNameField; UserNameField = userNameField; WorkstationField = workstationField; EncryptedRandomSessionKeyField = encryptedRandomSessionKeyField; NegotiateFlag = negotiateFlag; Version = version; }
static public AuthenticateMessage CreateAuthenticateMessage(ChallengeMessage challengeMessage, string strUserName, byte[] passwordNTHash) { uint payloadPointer = 88 - 16; MetaDataPayloadHex lcrf = new MetaDataPayloadHex(payloadPointer, new byte[24]); payloadPointer += lcrf.Len; NtChallengeResponseFields ncrf = NtChallengeResponseFields.CreateNtChallengeResponseFields(challengeMessage, strUserName, passwordNTHash, ref payloadPointer); MetaDataPayloadString domainNameField = new MetaDataPayloadString(payloadPointer, challengeMessage.TargetNameField.Buffer); payloadPointer += domainNameField.Len; var userNames = Encoding.Unicode.GetBytes(strUserName); var len = (ushort)userNames.Length; MetaDataPayloadString userNameField = new MetaDataPayloadString(payloadPointer, userNames); payloadPointer += userNameField.Len; MetaDataPayloadString workstationField = new MetaDataPayloadString(payloadPointer, challengeMessage.TargetNameField.Buffer); payloadPointer += workstationField.Len; byte[] t = new byte[16]; if (challengeMessage.NegotiateFlag.HasFlag(NegotiateFlags.NEGOTIATE_KEY_EXCH)) { // EncryptedRandomSessionKey=MasterKey RC4-encrypts SecondaryMasterKey throw new NotImplementedException(); } MetaDataPayloadString EncryptedRandomSessionKeyField = new MetaDataPayloadString(payloadPointer, t); payloadPointer += EncryptedRandomSessionKeyField.Len; return(new AuthenticateMessage(lcrf, ncrf, domainNameField, userNameField, workstationField, EncryptedRandomSessionKeyField, challengeMessage.NegotiateFlag, new Versions() )); }