Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue due to updating ruby_ntlm to 0.6.5 #271

Merged

Conversation

zeroSteiner
Copy link
Contributor

@zeroSteiner zeroSteiner commented Sep 4, 2024

There was a PR that changed how strings were being encoded that was added to ruby_ntlm 0.6.5 that is causing tests to break.

Tested that ruby examples/tree_connect.rb --username юзер --password 123456 192.168.159.10 IPC$ continues to work. Things also still work with rubyntlm==0.6.4.

There was a PR that changed how strings were being encoded that was
added to ruby_ntlm 0.6.5 that is causing tests to break.
@cdelafuente-r7
Copy link
Contributor

It looks good to me. I tested using with the RubySMB server and an username containing a non-ASCII character (connecting from Windows Explorer on Windows Server 2019):

  • Without the fix
➜  ruby_smb git:(6beae57) ✗ bundle exec ruby examples/file_server.rb --username .\\юзер --password 123456
D, [2024-09-09T11:33:35.575672 #67067] DEBUG -- : Adding disk share: home
server is running
received connection
I, [2024-09-09T11:33:35.841755 #67067]  INFO -- : Negotiated dialect: SMB v3.1.1
D, [2024-09-09T11:33:35.844533 #67067] DEBUG -- : Dispatching request to do_session_setup_smb2 (session: nil)
D, [2024-09-09T11:33:35.848456 #67067] DEBUG -- : Dispatching request to do_session_setup_smb2 (session: #<Session id: 3492493677, user_id: nil, state: :in_progress>)
D, [2024-09-09T11:33:35.848861 #67067] DEBUG -- : NTLM authentication request received for .\юзер
#<Thread:0x00007f91c718da98 /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server.rb:77 run> terminated with exception (report_on_exception is true):
/Users/cdelafuente/.rvm/gems/ruby-3.0.2@ruby_smb/gems/rubyntlm-0.6.5/lib/net/ntlm.rb:179:in `+': incompatible character encodings: ASCII-8BIT and UTF-16LE (Encoding::CompatibilityError)
	from /Users/cdelafuente/.rvm/gems/ruby-3.0.2@ruby_smb/gems/rubyntlm-0.6.5/lib/net/ntlm.rb:179:in `ntlmv2_hash'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/gss/provider/ntlm.rb:157:in `process_ntlm_type3'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/gss/provider/ntlm.rb:229:in `process_gss_type3'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/gss/provider/ntlm.rb:62:in `process'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client.rb:154:in `process_gss'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client/session_setup.rb:71:in `do_session_setup_smb2'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client.rb:405:in `handle_smb2'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client.rb:424:in `_handle_smb2'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client.rb:119:in `handle_smb'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client.rb:173:in `block in run'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client.rb:162:in `loop'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server/server_client.rb:162:in `run'
	from /Users/cdelafuente/dev/src/ruby_smb/lib/ruby_smb/server.rb:77:in `block (2 levels) in run'
- With the fix
➜  ruby_smb git:(6beae57) ✗ bundle exec ruby examples/file_server.rb --username .\\юзер --password 123456
D, [2024-09-09T11:34:55.596773 #67159] DEBUG -- : Adding disk share: home
server is running
received connection
I, [2024-09-09T11:35:03.148495 #67159]  INFO -- : Negotiated dialect: SMB v3.1.1
D, [2024-09-09T11:35:03.151928 #67159] DEBUG -- : Dispatching request to do_session_setup_smb2 (session: nil)
D, [2024-09-09T11:35:03.155826 #67159] DEBUG -- : Dispatching request to do_session_setup_smb2 (session: #<Session id: 3683369126, user_id: nil, state: :in_progress>)
D, [2024-09-09T11:35:03.156254 #67159] DEBUG -- : NTLM authentication request received for .\юзер
I, [2024-09-09T11:35:03.157568 #67159]  INFO -- : NTLM authentication request succeeded for .\юзер
D, [2024-09-09T11:35:03.162375 #67159] DEBUG -- : Dispatching request to do_tree_connect_smb2 (session: #<Session id: 3683369126, user_id: ".\u0000\\юзер", state: :valid>)
D, [2024-09-09T11:35:03.162678 #67159] DEBUG -- : Received TREE_CONNECT request for share: home
D, [2024-09-09T11:35:03.168377 #67159] DEBUG -- : Dispatching request to do_create_smb2 (session: #<Session id: 3683369126, user_id: ".\u0000\\юзер", state: :valid>)
D, [2024-09-09T11:35:03.168518 #67159] DEBUG -- : Received CREATE request for share: home
D, [2024-09-09T11:35:03.182978 #67159] DEBUG -- : Dispatching request to do_query_directory_smb2 (session: #<Session id: 3683369126, user_id: ".\u0000\\юзер", state: :valid>)
D, [2024-09-09T11:35:03.183095 #67159] DEBUG -- : Received QUERY_DIRECTORY request for share: home
D, [2024-09-09T11:35:03.228793 #67159] DEBUG -- : Dispatching request to do_query_directory_smb2 (session: #<Session id: 3683369126, user_id: ".\u0000\\юзер", state: :valid>)
D, [2024-09-09T11:35:03.228933 #67159] DEBUG -- : Received QUERY_DIRECTORY request for share: home
D, [2024-09-09T11:35:03.232747 #67159] DEBUG -- : Dispatching request to do_close_smb2 (session: #<Session id: 3683369126, user_id: ".\u0000\\юзер", state: :valid>)
D, [2024-09-09T11:35:03.232857 #67159] DEBUG -- : Received CLOSE request for share: home
D, [2024-09-09T11:35:03.286650 #67159] DEBUG -- : Dispatching request to do_create_smb2 (session: #<Session id: 3683369126, user_id: ".\u0000\\юзер", state: :valid>)
D, [2024-09-09T11:35:03.286768 #67159] DEBUG -- : Received CREATE request for share: home
D, [2024-09-09T11:35:03.296134 #67159] DEBUG -- : Dispatching request to do_close_smb2 (session: #<Session id: 3683369126, user_id: ".\u0000\\юзер", state: :valid>)
D, [2024-09-09T11:35:03.296236 #67159] DEBUG -- : Received CLOSE request for share: home

@cdelafuente-r7 cdelafuente-r7 self-assigned this Sep 9, 2024
@cdelafuente-r7 cdelafuente-r7 merged commit 682271e into rapid7:master Sep 9, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants