Add anonymous authentication support #45
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes adjust some things to allow the NTLM session to authenticate anonymously (without a username and password).
For both NTLMv1 an NTLMv2, the docs call out that when the username and password are blank strings, the challenge fields should be special values.
This also adjusts the
Message
class to pad security buffer fields to a two byte boundary when the UNICODE flag is set. Per MS-NLMP Section 2.2.1.3 the user, domain and workstation fields must have offsets that are multiples of 2. A single null byte is used as padding when necessary. When the UNICODE flag is not set, no padding takes place. The padding is necessary because the code path executed when using anonymous authentication sets thelm_response
field to a single null byte and shifts all fields after it.The last change adjusts how the character encoding is determined. Per MS_NLMP Section 2.2.2.5, the UNICODE flag should take priority regardless of the value of the OEM flag. That is to say that when both are set, the "... choice of character set encoding MUST be Unicode".
Lastly some specs that exercise the updated code paths were added.
This was tested in combination with RubySMB and the anonymous_auth example.