Class: Msf::Post::File::FileStat

Inherits:
Rex::Post::FileStat show all
Defined in:
lib/msf/core/post/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Rex::Post::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(filename, session) ⇒ FileStat

Returns a new instance of FileStat.



1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
# File 'lib/msf/core/post/file.rb', line 1095

def initialize(filename, session)
  data = session.shell_command_token("stat --format='%d,%i,%h,%u,%g,%t,%s,%B,%o,%X,%Y,%Z,%f' '#{filename}'").to_s.chomp
  raise 'format argument of stat command not behaving as expected' unless data =~ /(\d+,){12}\w+/

  data = data.split(',')
  @stathash = Hash.new
  @stathash['st_dev'] = data[0].to_i
  @stathash['st_ino'] = data[1].to_i
  @stathash['st_nlink'] = data[2].to_i
  @stathash['st_uid'] = data[3].to_i
  @stathash['st_gid'] = data[4].to_i
  @stathash['st_rdev'] = data[5].to_i
  @stathash['st_size'] = data[6].to_i
  @stathash['st_blksize'] = data[7].to_i
  @stathash['st_blocks'] = data[8].to_i
  @stathash['st_atime'] = data[9].to_i
  @stathash['st_mtime'] = data[10].to_i
  @stathash['st_ctime'] = data[11].to_i
  @stathash['st_mode'] = data[12].to_i(16) # stat command returns hex value of mode"
end

Instance Attribute Details

#stathashObject

Returns the value of attribute stathash.



1093
1094
1095
# File 'lib/msf/core/post/file.rb', line 1093

def stathash
  @stathash
end