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

ruby_smb error when reading empty files #172

Open
cgranleese-r7 opened this issue May 13, 2021 · 0 comments
Open

ruby_smb error when reading empty files #172

cgranleese-r7 opened this issue May 13, 2021 · 0 comments
Assignees
Labels

Comments

@cgranleese-r7
Copy link
Contributor

Ran into this error when testing some ascii/utf-8 issues.

If I ran examples/read_file.rb against an empty file, it would return the following errors:

➜  examples git:(master) ruby read_file.rb 192.168.215.190 <redacted> <redacted> Share 抽.txt 2
SMB2 : (0x00000000) STATUS_SUCCESS: The operation completed successfully.
Connected to \\192.168.215.190\Share successfully!

/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:88:in `rescue in recv_packet': An error occurred reading from the Socket Connection reset by peer (RubySMB::Error::CommunicationError)
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:63:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
	from read_file.rb:41:in `<main>'
/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `read': Connection reset by peer (Errno::ECONNRESET)
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
	from read_file.rb:41:in `<main>'
➜  examples git:(master)

This was tested against a Windows 8 & Windows 10 VM.

Found while attempting tor replicate this issue.

Steps to reproduce

How'd you do it?

  1. Run examples/read_file.rb against an SMB share. e.g.
ruby examples/read_file.rb 192.168.2.5 <redacted> <redacted> share_test "Мой файл.txt" 2) 

Were you following a specific guide/tutorial or reading documentation?

Found while attempting tor replicate this issue.

Expected behavior

Should return no errors and just a blank output, e.g.

➜  examples git:(master) ruby read_file.rb 192.168.215.190 <redacted> <redacted> Share 抽.txt 2
SMB2 : (0x00000000) STATUS_SUCCESS: The operation completed successfully.
Connected to \\192.168.215.190\Share successfully!

➜  examples git:(master)

Current behavior

Returns two errors:
RubySMB::Error::CommunicationError
Errno::ECONNRESET

➜  examples git:(master) ruby read_file.rb 192.168.215.190 <redacted> <redacted> Share 抽.txt 2
SMB2 : (0x00000000) STATUS_SUCCESS: The operation completed successfully.
Connected to \\192.168.215.190\Share successfully!

/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:88:in `rescue in recv_packet': An error occurred reading from the Socket Connection reset by peer (RubySMB::Error::CommunicationError)
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:63:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
	from read_file.rb:41:in `<main>'
/Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `read': Connection reset by peer (Errno::ECONNRESET)
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/dispatcher/socket.rb:70:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:540:in `recv_packet'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/client.rb:467:in `send_recv'
	from /Users/cgranleese/rapid7/ruby_smb/lib/ruby_smb/smb2/file.rb:92:in `close'
	from read_file.rb:41:in `<main>'
➜  examples git:(master)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants