Class: Msf::Post::File::FileStat
- Inherits:
-
Rex::Post::FileStat
- Object
- Rex::Post::FileStat
- Msf::Post::File::FileStat
- Defined in:
- lib/msf/core/post/file.rb
Instance Attribute Summary collapse
-
#stathash ⇒ Object
Returns the value of attribute stathash.
Instance Method Summary collapse
-
#initialize(filename, session) ⇒ FileStat
constructor
A new instance of FileStat.
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.
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 |
# File 'lib/msf/core/post/file.rb', line 1159 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 unless data =~ /(\d+,){12}\w+/ data = session.shell_command_token( "stat -f '%d,%i,%l,%u,%g,%r,%z,%k,%b,%a,%m,%c,%p' '#{filename}'" ).to_s.chomp end raise "stat command returned an unexpected result: #{data}" unless data =~ /(\d+,){12}\w+/ data = data.split(',') @stathash = {} @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) end |
Instance Attribute Details
#stathash ⇒ Object
Returns the value of attribute stathash.
1157 1158 1159 |
# File 'lib/msf/core/post/file.rb', line 1157 def stathash @stathash end |