NTLM: CHALLENGE_MESSAGE: Do not include TargetName and TargetInfo if the appropriate flags are not set

This commit is contained in:
Tal Aloni 2017-09-01 18:53:42 +03:00
parent 06a30bc92d
commit adcb576976

View file

@ -48,12 +48,21 @@ namespace SMBLibrary.Authentication.NTLM
public byte[] GetBytes()
{
if ((NegotiateFlags & NegotiateFlags.TargetNameSupplied) == 0)
{
TargetName = String.Empty;
}
if ((NegotiateFlags & NegotiateFlags.TargetInfo) == 0)
{
TargetInfo = new byte[0];
}
int fixedLength = 48;
if ((NegotiateFlags & NegotiateFlags.Version) > 0)
{
fixedLength += 8;
}
int payloadLength = TargetName.Length * 2 + TargetInfo.Length;
byte[] buffer = new byte[fixedLength + payloadLength];
ByteWriter.WriteAnsiString(buffer, 0, AuthenticateMessage.ValidSignature, 8);