Old versions of Samba does not respect the SMB extension protocol for TreeConnectResponse packets (https://msdn.microsoft.com/en-us/library/cc246331.aspx). Comparing to CIFS (https://msdn.microsoft.com/en-us/library/ee441613.aspx), SMB specifies two new fields in the SMBParameter block: MaximalShareAccessRights and GuestMaximalShareAccessRights. However, old versions of Samba are not sending these fields, which breaks RubySMB (tested with Samba 3.0.22). Newer versions correctly include these two fields (tested with Samba 3.4.7).
This PR adds conditional statements for these fields to avoid breaking when these packets are parsed.
Verification Steps
[x] bundle install
[x] Verify you can connect to a remote share with SMB1 and SMB2on an old Samba version (3.0.22): ruby examples/tree_connect.rb <ip-address> <username> <password> <share>
Coverage remained the same at 95.023% when pulling 0165c063a8f63b7a0836a0181e5bc244d7849454 on chrisdlf:fix_tree_connect_response_for_old_samba into 0804cbf298ede3eea2702b33807572de8a111ec0 on rapid7:master.
Description
Old versions of Samba does not respect the SMB extension protocol for TreeConnectResponse packets (https://msdn.microsoft.com/en-us/library/cc246331.aspx). Comparing to CIFS (https://msdn.microsoft.com/en-us/library/ee441613.aspx), SMB specifies two new fields in the SMBParameter block:
MaximalShareAccessRights
andGuestMaximalShareAccessRights
. However, old versions of Samba are not sending these fields, which breaks RubySMB (tested with Samba 3.0.22). Newer versions correctly include these two fields (tested with Samba 3.4.7).This PR adds conditional statements for these fields to avoid breaking when these packets are parsed.
Verification Steps
bundle install
ruby examples/tree_connect.rb <ip-address> <username> <password> <share>
rake spec
rake spec