ruby_smb 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8937795d135978de5a71c04da91bdd44ac2d44ce
4
- data.tar.gz: 37563d2e539ae97ae98a9fc5df32eeb4d51a408e
3
+ metadata.gz: b4dff3ea0843193837a2e7ca9f8f0ab4a7fd2eea
4
+ data.tar.gz: 7b8e7321255ff7da69f8aba3658c3f5f6769325e
5
5
  SHA512:
6
- metadata.gz: 106b8d06d0d2a269d18cb1c92234cc8f885d4c869cb2893fa4ec945045a95decb6b8a1b597c3c20341dac3e22c649d6da06480e75413cdea10988ec4b8c7a481
7
- data.tar.gz: 74c2e0a872f71a60b297c42b34c1abf3c15d33377f23b86ba4491c91251970d7b21febb93003ecfbb0a931313610207e8b389f2f5b21c37344399cb6e346171c
6
+ metadata.gz: 129e91974e7487ed551eb69506ecd7c7adb92a1b528b135a3bece8387fcb45acde5abde401475c03d469732a94dfd38aaa1f30b810acf641796e7860797b0b3c
7
+ data.tar.gz: 1233ed26721566ce8f86ea7e8eea3572b959251ae9db1faa6d1f84b324fc9c06a392c823b2551d2161972aaebb190920b465869e6bd97046ca67ec6dc4fb96db
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -8,10 +8,9 @@ A native Ruby implementation of the SMB Protocol Family. It currently supports
8
8
  1. [[MS-SMB]](https://msdn.microsoft.com/en-us/library/cc246231.aspx)
9
9
  1. [[MS-SMB2]](http://msdn.microsoft.com/en-us/library/cc246482.aspx)
10
10
 
11
- This library currently include both a Client level, and Packet level support. A user can aprse and manipulate raw
12
- SMB packets, or simply use the simple client to perform SMB operations.
11
+ This library currently include both a client level, and packet level support. A user can parse and manipulate raw SMB packets, or use the simple client to perform SMB operations.
13
12
 
14
- See the Wiki for more information on this porject's long-term goals, style guide, and developer tips.
13
+ See the Wiki for more information on this project's long-term goals, style guide, and developer tips.
15
14
 
16
15
  ## Installation
17
16
 
@@ -33,20 +32,21 @@ Or install it yourself as:
33
32
 
34
33
  ### Defining a packet
35
34
 
36
- All packets are done in a declarative style with BinData. Nested data structures are used where appropriate to give users
37
- the easiest method of adjusting data, all the way down to the bit level in case of bit masks.
35
+ All packets are implemented in a declarative style with BinData. Nested data
36
+ structures are used where appropriate to give users an easy method of adjusting
37
+ data.
38
38
 
39
39
  #### SMB1
40
40
  SMB1 Packets are made up of three basic components:
41
41
  1. **The SMB Header** - This is a standard SMB Header. All SMB1 packets use the same SMB header.
42
- 1. **The Parameter Block** - This is where function parameters are passed across the wire in the packet. Parameter Blocks will always
42
+ 1. **The Parameter Block** - This is where function parameters are passed across the wire in the packet. Parameter Blocks will always
43
43
  have a 'Word Count' field that gives the size of the Parameter Block in words(2-bytes)
44
44
  1. **The Data Block** - This is the data section of the packet. the Data Block will always have a 'byte count' field that gives the size of
45
45
  the Data block in bytes.
46
-
46
+
47
47
  The SMB Header can always just be declared as a field in the BinData DSL for the packet class, because its structure never changes.
48
48
  For the ParameterBlock and DataBlocks, we always define subclasses for this particular packet. They inherit the 'Word Count' and
49
- 'Byte Count' fields, along with the auto-calculation routines for those fields, from their ancestors. Any other fields are then
49
+ 'Byte Count' fields, along with the auto-calculation routines for those fields, from their ancestors. Any other fields are then
50
50
  defined in our subclass before we start the DSL declarations for the packet.
51
51
 
52
52
  Example:
@@ -165,7 +165,7 @@ Example:
165
165
 
166
166
  #### Reading from a Binary Blob
167
167
 
168
- Sometimes you need to read a binary blob and apply one of the packet structures to it.
168
+ Sometimes you need to read a binary blob and apply one of the packet structures to it.
169
169
  For example, when you are reading a response packet off of the wire, you will need to read the raw response
170
170
  string into an actual packet class. This is done using the #read class method.
171
171
 
@@ -230,7 +230,7 @@ Anonymous Example:
230
230
  ```ruby
231
231
  sock = TCPSocket.new address, 445
232
232
  dispatcher = RubySMB::Dispatcher::Socket.new(sock)
233
-
233
+
234
234
  client = RubySMB::Client.new(dispatcher, smb1: true, smb2: false, username: '', password: '')
235
235
  client.negotiate
236
236
  client.authenticate
@@ -238,7 +238,7 @@ Anonymous Example:
238
238
 
239
239
  #### Connecting to a Tree
240
240
 
241
- While there is one Client, that has branching code-paths for SMB1 and SMB2, once you connect to a
241
+ While there is one Client, that has branching code-paths for SMB1 and SMB2, once you connect to a
242
242
  Tree you will be given a protocol specific Tree object. This Tree object will be responsible for all file operations
243
243
  that are to be conducted on that Tree.
244
244
 
@@ -247,26 +247,26 @@ Example:
247
247
  ```ruby
248
248
  sock = TCPSocket.new address, 445
249
249
  dispatcher = RubySMB::Dispatcher::Socket.new(sock)
250
-
250
+
251
251
  client = RubySMB::Client.new(dispatcher, smb1: true, smb2: false, username: 'msfadmin', password: 'msfadmin')
252
252
  client.negotiate
253
253
  client.authenticate
254
-
254
+
255
255
  begin
256
256
  tree = client.tree_connect('TEST_SHARE')
257
257
  puts "Connected to #{path} successfully!"
258
258
  rescue StandardError => e
259
259
  puts "Failed to connect to #{path}: #{e.message}"
260
260
  end
261
-
261
+
262
262
  files = tree.list(directory: 'subdir1')
263
-
263
+
264
264
  files.each do |file|
265
265
  create_time = file.create_time.to_datetime.to_s
266
266
  access_time = file.last_access.to_datetime.to_s
267
267
  change_time = file.last_change.to_datetime.to_s
268
268
  file_name = file.file_name.encode("UTF-8")
269
-
269
+
270
270
  puts "FILE: #{file_name}\n\tSIZE(BYTES):#{file.end_of_file}\n\tSIZE_ON_DISK(BYTES):#{file.allocation_size}\n\tCREATED:#{create_time}\n\tACCESSED:#{access_time}\n\tCHANGED:#{change_time}\n\n"
271
271
  end
272
272
  ```
@@ -146,12 +146,18 @@ module RubySMB
146
146
  # @return [String]
147
147
  attr_accessor :user_id
148
148
 
149
- # The maximum size of a SMB message that the Client accepts (in bytes)
150
- # Its default value is equal to {MAX_BUFFER_SIZE}.
149
+ # The maximum size SMB message that the Client accepts (in bytes)
150
+ # The default value is equal to {MAX_BUFFER_SIZE}.
151
151
  # @!attribute [rw] max_buffer_size
152
152
  # @return [Integer]
153
153
  attr_accessor :max_buffer_size
154
154
 
155
+ # The maximum size SMB message that the Server accepts (in bytes)
156
+ # The default value is small by default
157
+ # @!attribute [rw] max_buffer_size
158
+ # @return [Integer]
159
+ attr_accessor :server_max_buffer_size
160
+
155
161
  # @param dispatcher [RubySMB::Dispacther::Socket] the packet dispatcher to use
156
162
  # @param smb1 [Boolean] whether or not to enable SMB1 support
157
163
  # @param smb2 [Boolean] whether or not to enable SMB2 support
@@ -172,6 +178,7 @@ module RubySMB
172
178
  @smb2 = smb2
173
179
  @username = username.encode('utf-8') || ''.encode('utf-8')
174
180
  @max_buffer_size = MAX_BUFFER_SIZE
181
+ @server_max_buffer_size = MAX_BUFFER_SIZE
175
182
 
176
183
  negotiate_version_flag = 0x02000000
177
184
  flags = Net::NTLM::Client::DEFAULT_FLAGS |
@@ -185,7 +192,7 @@ module RubySMB
185
192
  domain: @domain,
186
193
  flags: flags
187
194
  )
188
-
195
+
189
196
  @tree_connects = []
190
197
  @open_files = {}
191
198
 
@@ -253,7 +260,7 @@ module RubySMB
253
260
  flags = Net::NTLM::Client::DEFAULT_FLAGS |
254
261
  Net::NTLM::FLAGS[:TARGET_INFO] |
255
262
  negotiate_version_flag
256
-
263
+
257
264
  @ntlm_client = Net::NTLM::Client.new(
258
265
  @username,
259
266
  @password,
@@ -334,7 +341,7 @@ module RubySMB
334
341
  smb1_net_share_enum_all(host)
335
342
  end
336
343
  end
337
-
344
+
338
345
  #
339
346
  # SMB2 Methods
340
347
  #
@@ -80,24 +80,19 @@ module RubySMB
80
80
  when RubySMB::SMB1::Packet::NegotiateResponseExtended
81
81
  self.smb1 = true
82
82
  self.smb2 = false
83
- if packet.parameter_block.security_mode.security_signatures_required == 1
84
- self.signing_required = true
85
- else
86
- self.signing_required = false
87
- end
83
+ self.signing_required = packet.parameter_block.security_mode.security_signatures_required == 1
88
84
  self.dialect = packet.negotiated_dialect.to_s
85
+ self.server_max_buffer_size = packet.parameter_block.max_buffer_size
89
86
  'SMB1'
90
87
  when RubySMB::SMB2::Packet::NegotiateResponse
91
88
  self.smb1 = false
92
89
  self.smb2 = true
93
- self.signing_required = if packet.security_mode.signing_required == 1
94
- true
95
- else
96
- false
97
- end
90
+ self.signing_required = packet.security_mode.signing_required == 1
98
91
  self.dialect = "0x%04x" % packet.dialect_revision
92
+ self.server_max_buffer_size = 16644
99
93
  'SMB2'
100
94
  end
95
+
101
96
  end
102
97
 
103
98
  # Create a {RubySMB::SMB1::Packet::NegotiateRequest} packet with the
@@ -38,8 +38,15 @@ module RubySMB
38
38
  bytes_written = 0
39
39
  begin
40
40
  while bytes_written < data.size
41
- bytes_written += @tcp_socket.write(data[bytes_written..-1])
41
+ retval = @tcp_socket.write(data[bytes_written..-1])
42
+
43
+ if retval == nil
44
+ raise RubySMB::Error::CommunicationError
45
+ else
46
+ bytes_written += retval
47
+ end
42
48
  end
49
+
43
50
  rescue IOError, Errno::ECONNABORTED, Errno::ECONNRESET => e
44
51
  raise RubySMB::Error::CommunicationError, "An error occured writing to the Socket: #{e.message}"
45
52
  end
@@ -1,3 +1,3 @@
1
1
  module RubySMB
2
- VERSION = '0.0.19'.freeze
2
+ VERSION = '0.0.20'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_smb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Maloney
@@ -89,7 +89,7 @@ cert_chain:
89
89
  G+Hmcg1v810agasPdoydE0RTVZgEOOMoQ07qu7JFXVWZ9ZQpHT7qJATWL/b2csFG
90
90
  8mVuTXnyJOKRJA==
91
91
  -----END CERTIFICATE-----
92
- date: 2018-02-21 00:00:00.000000000 Z
92
+ date: 2018-02-22 00:00:00.000000000 Z
93
93
  dependencies:
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: redcarpet
metadata.gz.sig CHANGED
Binary file