#!/usr/bin/ruby # # This is just a container class basically, that acts like File::Struct # # You must supply an initialize method that somehow populates the stathash.. # module Rex module Post class FileStat @@ftypes = [ 'fifo', 'characterSpecial', 'directory', 'blockSpecial', 'file', 'link', 'socket' ] # class <> 13].dup end # # S_ISUID 0004000 set UID bit # S_ISGID 0002000 set GID bit (see below) # S_ISVTX 0001000 sticky bit (see below) # S_IRWXU 00700 mask for file owner permissions # S_IRUSR 00400 owner has read permission # S_IWUSR 00200 owner has write permission # S_IXUSR 00100 owner has execute permission # S_IRWXG 00070 mask for group permissions # S_IRGRP 00040 group has read permission # S_IWGRP 00020 group has write permission # S_IXGRP 00010 group has execute permission # S_IRWXO 00007 mask for permissions for others (not in group) # S_IROTH 00004 others have read permission # S_IWOTH 00002 others have write permisson # S_IXOTH 00001 others have execute permission # def perm?(mask) return true if mode & mask == mask return false end def setgid? perm?(02000) end def setuid? perm?(04000) end def sticky? perm?(01000) end def executable? raise NotImplementedError end def executable_real? raise NotImplementedError end def grpowned? raise NotImplementedError end def owned? raise NotImplementedError end def readable? raise NotImplementedError end def readable_real? raise NotImplementedError end def writeable? raise NotImplementedError end def writeable_real? raise NotImplementedError end def prettymode m = mode om = '%04o' % m perms = '' 3.times { perms = ((m & 01) == 01 ? 'x' : '-') + perms perms = ((m & 02) == 02 ? 'w' : '-') + perms perms = ((m & 04) == 04 ? 'r' : '-') + perms m >>= 3 } return "#{om}/#{perms}" end def pretty " Size: #{size} Blocks: #{blocks} IO Block: #{blksize} Type: #{rdev}\n"\ "Device: #{dev} Inode: #{ino} Links: #{nlink}\n"\ " Mode: #{prettymode}\n"\ " Uid: #{uid} Gid: #{gid}\n"\ "Access: #{atime}\n"\ "Modify: #{mtime}\n"\ "Change: #{ctime}\n" end end end; end # Post/Rex