From f2cf4fd1dc286f3dbae506f2854f2645a6d8c4fe Mon Sep 17 00:00:00 2001 From: dmohanty-r7 Date: Wed, 28 Feb 2018 15:44:07 -0600 Subject: [PATCH] remove case for open smb file packet field --- Gemfile | 4 ---- lib/rex/proto/smb/simpleclient.rb | 4 +--- lib/rex/proto/smb/simpleclient/open_file.rb | 18 ++++-------------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/Gemfile b/Gemfile index 510a2db034..6619c1441a 100755 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,6 @@ group :development do gem 'yard' # for development and testing purposes gem 'pry' - gem 'pry-byebug' # module documentation gem 'octokit' # Metasploit::Aggregator external session proxy @@ -41,6 +40,3 @@ group :test do # Manipulate Time.now in specs gem 'timecop' end - -gem 'ruby_smb', git: 'https://github.com/rapid7/ruby_smb', branch: 'master' - diff --git a/lib/rex/proto/smb/simpleclient.rb b/lib/rex/proto/smb/simpleclient.rb index 7c69a76e21..839573b49f 100644 --- a/lib/rex/proto/smb/simpleclient.rb +++ b/lib/rex/proto/smb/simpleclient.rb @@ -70,7 +70,7 @@ attr_accessor :socket, :client, :direct, :shares, :last_share self.client.send_ntlm = send_ntlm ok = self.client.negotiate - self.server_max_buffer_size = ok['Payload'].v['MaxBuff'] + self.server_max_buffer_size = self.client.server_max_buffer_size # Disable NTLMv2 Session for Windows 2000 (breaks authentication on some systems) # XXX: This in turn breaks SMB auth for Windows 2000 configured to enforce NTLMv2 @@ -191,8 +191,6 @@ attr_accessor :socket, :client, :direct, :shares, :last_share ok.guid.to_binary_s elsif ok.respond_to? :fid ok.fid.to_binary_s - else - ok['Payload'].v['FileID'] end fh = OpenPipe.new(self.client, path, self.client.last_tree_id, file_id) end diff --git a/lib/rex/proto/smb/simpleclient/open_file.rb b/lib/rex/proto/smb/simpleclient/open_file.rb index 8ef696714b..df407bccb9 100644 --- a/lib/rex/proto/smb/simpleclient/open_file.rb +++ b/lib/rex/proto/smb/simpleclient/open_file.rb @@ -61,14 +61,7 @@ class OpenFile return data else ok = self.client.read(self.file_id, offset, length) - data = if ok.is_a? Array - ok.pack('C*') - else - ok.to_s.slice( - ok['Payload'].v['DataOffset'] + 4, - ok['Payload'].v['DataLenLow'] - ) - end + data = ok.pack('C*') return data end end @@ -91,12 +84,9 @@ class OpenFile # Keep writing data until we run out while (chunk.length > 0) ok = self.client.write(self.file_id, fptr, chunk) - - if ok.is_a? BinData::Uint32le - cl = ok - else - cl = ok['Payload'].v['CountLow'] - end + + + cl = ok # Partial write, push the failed data back into the queue if (cl != chunk.length)