Module: Rex::Post::File

Included in:
Meterpreter::Extensions::Stdapi::Fs::File
Defined in:
lib/rex/post/file.rb

Overview

This module simulates the behavior that one would expect from the Ruby File class against a remote entity. Refer to the ruby documentation for expected behavior.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.atime(name) ⇒ Object

autogen’d stat passthroughs



96
97
98
# File 'lib/rex/post/file.rb', line 96

def File.atime(name)
  stat(name).atime
end

.basename(*a) ⇒ Object

proxy these methods



41
42
43
# File 'lib/rex/post/file.rb', line 41

def File.basename(*a)
  ::File.basename(*a)
end

.blockdev?(name) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/rex/post/file.rb', line 99

def File.blockdev?(name)
  stat(name).blockdev?
end

.chardev?(name) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/rex/post/file.rb', line 102

def File.chardev?(name)
  stat(name).chardev?
end

.chmodObject



56
57
58
# File 'lib/rex/post/file.rb', line 56

def File.chmod
  raise NotImplementedError
end

.chownObject



59
60
61
# File 'lib/rex/post/file.rb', line 59

def File.chown
  raise NotImplementedError
end

.ctime(name) ⇒ Object



105
106
107
# File 'lib/rex/post/file.rb', line 105

def File.ctime(name)
  stat(name).ctime
end

.delete(*a) ⇒ Object



62
63
64
# File 'lib/rex/post/file.rb', line 62

def File.delete(*a)
  unlink(*a)
end

.directory?(name) ⇒ Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/rex/post/file.rb', line 108

def File.directory?(name)
  stat(name).directory?
end

.dirname(*a) ⇒ Object



44
45
46
# File 'lib/rex/post/file.rb', line 44

def File.dirname(*a)
  ::File.dirname(*a)
end

.executable?(name) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/rex/post/file.rb', line 111

def File.executable?(name)
  stat(name).executable?
end

.executable_real?(name) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/rex/post/file.rb', line 114

def File.executable_real?(name)
  stat(name).executable_real?
end

.expand_pathObject

this, along with all the other globbing/search stuff, probably won’t get implemented, atleast for a bit…



83
84
85
# File 'lib/rex/post/file.rb', line 83

def File.expand_path
  raise NotImplementedError
end

.extname(*a) ⇒ Object



47
48
49
# File 'lib/rex/post/file.rb', line 47

def File.extname(*a)
  ::File.extname(*a)
end

.file?(name) ⇒ Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/rex/post/file.rb', line 117

def File.file?(name)
  stat(name).file?
end

.fnmatch(*a) ⇒ Object



86
87
88
# File 'lib/rex/post/file.rb', line 86

def File.fnmatch(*a)
  fnmatch?(*a)
end

.fnmatch?Boolean

Returns:

  • (Boolean)

Raises:



89
90
91
# File 'lib/rex/post/file.rb', line 89

def File.fnmatch?
  raise NotImplementedError
end

.ftype(name) ⇒ Object



120
121
122
# File 'lib/rex/post/file.rb', line 120

def File.ftype(name)
  stat(name).ftype
end

.grpowned?(name) ⇒ Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/rex/post/file.rb', line 123

def File.grpowned?(name)
  stat(name).grpowned?
end

.join(*a) ⇒ Object

!!! we might actually want to handle this File::SEPERATOR stuff for win32 support, etc.



52
53
54
# File 'lib/rex/post/file.rb', line 52

def File.join(*a)
  ::File.join(*a)
end

.lchmodObject



68
69
70
# File 'lib/rex/post/file.rb', line 68

def File.lchmod
  raise NotImplementedError
end

.lchownObject



71
72
73
# File 'lib/rex/post/file.rb', line 71

def File.lchown
  raise NotImplementedError
end


74
75
76
# File 'lib/rex/post/file.rb', line 74

def File.link
  raise NotImplementedError
end

.lstatObject



77
78
79
# File 'lib/rex/post/file.rb', line 77

def File.lstat
  raise NotImplementedError
end

.mtime(name) ⇒ Object



126
127
128
# File 'lib/rex/post/file.rb', line 126

def File.mtime(name)
  stat(name).mtime
end

.owned?(name) ⇒ Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/rex/post/file.rb', line 129

def File.owned?(name)
  stat(name).owned?
end

.pipe?(name) ⇒ Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/rex/post/file.rb', line 132

def File.pipe?(name)
  stat(name).pipe?
end

.readable?(name) ⇒ Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/rex/post/file.rb', line 135

def File.readable?(name)
  stat(name).readable?
end

.readable_real?(name) ⇒ Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/rex/post/file.rb', line 138

def File.readable_real?(name)
  stat(name).readable_real?
end

.setgid?(name) ⇒ Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/rex/post/file.rb', line 144

def File.setgid?(name)
  stat(name).setgid?
end

.setuid?(name) ⇒ Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/rex/post/file.rb', line 141

def File.setuid?(name)
  stat(name).setuid?
end

.size(name) ⇒ Object



147
148
149
# File 'lib/rex/post/file.rb', line 147

def File.size(name)
  stat(name).size
end

.socket?(name) ⇒ Boolean

Returns:

  • (Boolean)


150
151
152
# File 'lib/rex/post/file.rb', line 150

def File.socket?(name)
  stat(name).socket?
end

.sticky?(name) ⇒ Boolean

Returns:

  • (Boolean)


153
154
155
# File 'lib/rex/post/file.rb', line 153

def File.sticky?(name)
  stat(name).sticky?
end

.symlink?(name) ⇒ Boolean

Returns:

  • (Boolean)


156
157
158
# File 'lib/rex/post/file.rb', line 156

def File.symlink?(name)
  stat(name).symlink?
end


65
66
67
# File 'lib/rex/post/file.rb', line 65

def File.unlink
  raise NotImplementedError
end

.writeable?(name) ⇒ Boolean

Returns:

  • (Boolean)


159
160
161
# File 'lib/rex/post/file.rb', line 159

def File.writeable?(name)
  stat(name).writeable?
end

.writeable_real?(name) ⇒ Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/rex/post/file.rb', line 162

def File.writeable_real?(name)
  stat(name).writeable_real?
end

.zero?(name) ⇒ Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/rex/post/file.rb', line 165

def File.zero?(name)
  stat(name).zero?
end

Instance Method Details

#initialize(name, mode = 'r', perm = 0) ⇒ Object

f = File.new(“testfile”, “r”) f = File.new(“newfile”, “w+”) f = File.new(“newfile”, File::CREAT|File::TRUNC|File::RDWR, 0644) !!! I suppose I should figure out the correct default for perm..



30
31
# File 'lib/rex/post/file.rb', line 30

def initialize(name, mode='r', perm=0)
end

#pathObject



33
34
35
# File 'lib/rex/post/file.rb', line 33

def path
  filename
end