Sha256: 668ae0fc572f97e7b5dd974721327524eef0de0220b886f2cdce3acdd50b9164

Contents?: true

Size: 978 Bytes

Versions: 15

Compression:

Stored size: 978 Bytes

Contents

# -*- coding: binary -*-

module Rex
module Proto
module SMB
class SimpleClient

class OpenPipe < OpenFile

  # Valid modes are: 'trans' and 'rw'
  attr_accessor :mode

  def initialize(*args)
    super(*args)
    self.mode = 'rw'
    @buff = ''
  end

  def read_buffer(length, offset=0)
    length ||= @buff.length
    @buff.slice!(0, length)
  end

  def read(length = nil, offset = 0)
    case self.mode
    when 'trans'
      read_buffer(length, offset)
    when 'rw'
      super(length, offset)
    else
      raise ArgumentError
    end
  end

  def write(data, offset = 0)
    case self.mode

    when 'trans'
      write_trans(data, offset)
    when 'rw'
      super(data, offset)
    else
      raise ArgumentError
    end
  end

  def write_trans(data, offset=0)
    ack = self.client.trans_named_pipe(self.file_id, data)
    doff = ack['Payload'].v['DataOffset']
    dlen = ack['Payload'].v['DataCount']
    @buff << ack.to_s[4+doff, dlen]
  end
end
end
end
end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.12 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.11 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.10 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.9 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.8 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.7 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.5 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.4 lib/rex/proto/smb/simpleclient/open_pipe.rb
dstruct-0.0.1 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.3 lib/rex/proto/smb/simpleclient/open_pipe.rb
librex-0.0.999 lib/rex/proto/smb/simpleclient/open_pipe.rb
rex-2.0.2 lib/rex/proto/smb/simpleclient/open_pipe.rb
librex-0.0.71 lib/rex/proto/smb/simpleclient/open_pipe.rb
librex-0.0.70 lib/rex/proto/smb/simpleclient/open_pipe.rb