From adcb5769760588c897c6b064042d1f60b5bde01b Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 1 Sep 2017 18:53:42 +0300 Subject: [PATCH] NTLM: CHALLENGE_MESSAGE: Do not include TargetName and TargetInfo if the appropriate flags are not set --- .../NTLM/Structures/ChallengeMessage.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/SMBLibrary/Authentication/NTLM/Structures/ChallengeMessage.cs b/SMBLibrary/Authentication/NTLM/Structures/ChallengeMessage.cs index 979a238..dd615b1 100644 --- a/SMBLibrary/Authentication/NTLM/Structures/ChallengeMessage.cs +++ b/SMBLibrary/Authentication/NTLM/Structures/ChallengeMessage.cs @@ -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);