class Rex::Post::Meterpreter::Extensions::Stdapi::Fs::FileStat
This class wrappers gathering information about a given file and implements the Rex::Post::FileStat
interface in terms of data acquisition.
Attributes
client[RW]
Public Class Methods
new(file)
click to toggle source
Returns an instance of a FileStat
object.
# File lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb, line 48 def initialize(file) self.stathash = stat(file) if (file) end
Public Instance Methods
update(stat_buf)
click to toggle source
Swaps in a new stat hash.
# File lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb, line 55 def update(stat_buf) elem = @@struct_stat hash = {} offset = 0 index = 0 while (index < elem.length) size = elem[index + 1] value = stat_buf[offset, size].unpack(size == 2 ? 'v' : 'V')[0] offset += size hash[elem[index]] = value index += 2 end return (self.stathash = hash) end
Protected Instance Methods
stat(file)
click to toggle source
Gets information about the supplied file and returns a populated hash to the requestor.
# File lib/rex/post/meterpreter/extensions/stdapi/fs/file_stat.rb, line 87 def stat(file) request = Packet.create_request('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).value # Next, we go through the returned stat_buf and fix up the values # and insert them into a hash return update(stat_buf) end