rapid7 / ruby_smb

A native Ruby implementation of the SMB Protocol Family
Other
79 stars 82 forks source link

Fix negotiation for SMB v2.0.2 #212

Closed zeroSteiner closed 2 years ago

zeroSteiner commented 2 years ago

Some older Windows servers will respond back to an SMB 1 negotiate request with a dialect of 2.0.2 instead of the wildcard dialect. When that occurs, the client doesn't increment the message ID correctly which causes the subsequent session negotiation request to be rejected.

This issue can be reproduced with older versions of Server 2008. Once the issue is patched, the session setup should proceed correctly.

I opted to update the logic from doing an explicit check for the wildcard dialect (which was failing) to checking if an SMB2/3 response was received to an SMB1 request. This is a bit more flexible. I then tested it with servers running 2.0.2 (fixed), 2.1 and 3.1.1.