Module: Rex::Post::File

Included in:
Meterpreter::Extensions::Stdapi::Fs::File
Defined in:
lib/rex/post/file.rb

Overview

This module simulates the behavior that one would expect from the Ruby File class against a remote entity. Refer to the ruby documentation for expected behavior.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filename ⇒ Object (protected)

inherits fd and mode from IO



23
24
25
# File 'lib/rex/post/file.rb', line 23

def filename
  @filename
end

Class Method Details

.open(client, name, mode = "r", perm = 0) ⇒ Object

This method returns an instance of a file pool channel that can be read from, written to, seeked on, and other interacted with.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rex/post/meterpreter/channels/pools/file.rb', line 33

def File.open(client, name, mode = "r", perm = 0)
  Channel.create(client, 'stdapi_fs_file',
    self, CHANNEL_FLAG_SYNCHRONOUS,
    [
      {
        'type'  => Rex::Post::Meterpreter::Extensions::Stdapi::TLV_TYPE_FILE_PATH,
        'value' => client.unicode_filter_decode( name )
      },
      {
        'type'  => Rex::Post::Meterpreter::Extensions::Stdapi::TLV_TYPE_FILE_MODE,
        'value' => mode + "b"
      },
    ])
end

Instance Method Details

#initialize(name, mode = 'r', perm = 0) ⇒ Object

f = File.new("testfile", "r") f = File.new("newfile", "w+") f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644) !!! I suppose I should figure out the correct default for perm..



30
31
# File 'lib/rex/post/file.rb', line 30

def initialize(name, mode='r', perm=0)
end

#path ⇒ Object



33
34
35
# File 'lib/rex/post/file.rb', line 33

def path
  filename
end