Class: Ronin::PostExploitation::File::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/post_exploitation/file/stat.rb

Overview

Represents the status information of a remote file. The Stat class using the fs_stat method defined by the controller object to request the remote status information.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, path) ⇒ Stat

Creates a new File Stat object.

Raises:

Since:

  • 1.0.0


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ronin/post_exploitation/file/stat.rb', line 74

def initialize(controller,path)
  unless controller.respond_to?(:fs_stat)
    raise(RuntimeError,"#{controller.inspect} does not define fs_stat")
  end

  @controller = controller
  @path       = path.to_s

  unless (stat = @controller.fs_stat(@path))
    raise(Errno::ENOENT,"No such file or directory #{@path.dump}")
  end

  @size      = stat[:size]
  @blocks    = stat[:blocks]
  @blocksize = stat[:blocksize]
  @inode     = stat[:inode]
  @nlinks    = stat[:nlinks]

  @mode = stat[:mode]
  @uid  = stat[:uid]
  @gid  = stat[:gid]

  @atime = stat[:atime]
  @ctime = stat[:ctime]
  @mtime = stat[:mtime]
end

Instance Attribute Details

#blocksObject (readonly)

The number of native file-system blocks

Since:

  • 1.0.0


44
45
46
# File 'lib/ronin/post_exploitation/file/stat.rb', line 44

def blocks
  @blocks
end

#blocksizeObject (readonly) Also known as: blksize

The native file-system block size.

Since:

  • 1.0.0


47
48
49
# File 'lib/ronin/post_exploitation/file/stat.rb', line 47

def blocksize
  @blocksize
end

#inodeObject (readonly) Also known as: ino

The Inode number

Since:

  • 1.0.0


50
51
52
# File 'lib/ronin/post_exploitation/file/stat.rb', line 50

def inode
  @inode
end

#modeObject (readonly)

The mode of the file

Since:

  • 1.0.0


56
57
58
# File 'lib/ronin/post_exploitation/file/stat.rb', line 56

def mode
  @mode
end

The number of hard links to the file

Since:

  • 1.0.0


53
54
55
# File 'lib/ronin/post_exploitation/file/stat.rb', line 53

def nlinks
  @nlinks
end

#pathObject (readonly)

The path of the file

Since:

  • 1.0.0


38
39
40
# File 'lib/ronin/post_exploitation/file/stat.rb', line 38

def path
  @path
end

#sizeObject (readonly)

The size of the file (in bytes)

Since:

  • 1.0.0


41
42
43
# File 'lib/ronin/post_exploitation/file/stat.rb', line 41

def size
  @size
end

Instance Method Details

#zero?Boolean

Determines whether the file has zero size.

Since:

  • 1.0.0


110
111
112
# File 'lib/ronin/post_exploitation/file/stat.rb', line 110

def zero?
  @size == 0
end