Class: Rex::Post::Meterpreter::Extensions::Stdapi::Fs::FileStat

Inherits:
FileStat
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb

Overview

This class wrappers gathering information about a given file and implements the Rex::Post::FileStat interface in terms of data acquisition.

Class Attribute Summary collapse

Attributes inherited from FileStat

#stathash

Instance Method Summary collapse

Methods inherited from FileStat

#atime, #blksize, #blockdev?, #blocks, #chardev?, #ctime, #dev, #directory?, #executable?, #executable_real?, #file?, #filetype?, #ftype, #gid, #grpowned?, #ino, #mode, #mtime, #nlink, #owned?, #perm?, #pipe?, #pretty, #prettymode, #rdev, #readable?, #readable_real?, #setgid?, #setuid?, #size, #socket?, #sticky?, #symlink?, #uid, #update, #update32, #writeable?, #writeable_real?

Constructor Details

#initialize(file) ⇒ FileStat

Returns an instance of a FileStat object.



34
35
36
37
# File 'lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb', line 34

def initialize(file)
  super
  stat(file) if (file)
end

Class Attribute Details

.clientObject

Returns the value of attribute client.



22
23
24
# File 'lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb', line 22

def client
  @client
end

Instance Method Details

#stat(file) ⇒ Object (protected)

Gets information about the supplied file and returns a populated hash to the requester.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb', line 44

def stat(file)
  request = Packet.create_request(COMMAND_ID_STDAPI_FS_STAT)

  request.add_tlv(TLV_TYPE_FILE_PATH, self.class.client.unicode_filter_decode( file ))

  response = self.class.client.send_request(request)
  stat_buf = response.get_tlv(TLV_TYPE_STAT_BUF)

  unless stat_buf
    stat_buf = response.get_tlv(TLV_TYPE_STAT_BUF32)
    return update32(stat_buf.value)
  end

  # Next, we go through the returned stat_buf and fix up the values
  # and insert them into a hash
  return update(stat_buf.value)
end