Class: Rex::Post::IO
- Inherits:
-
Object
- Object
- Rex::Post::IO
- Defined in:
- lib/rex/post/io.rb
Overview
Base IO class that is modeled after the ruby IO class.
This is an abstract base class that defines the interface for post-exploitation I/O operations. Subclasses must implement the actual I/O functionality.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filed ⇒ Object
protected
Returns the value of attribute filed.
-
#mode ⇒ Object
protected
Returns the value of attribute mode.
Instance Method Summary collapse
-
#binmode ⇒ IO
Sets the stream to binary mode.
-
#close ⇒ nil
Closes the I/O stream.
-
#close_read ⇒ nil
Closes the read end of a duplex I/O stream.
-
#close_write ⇒ nil
Closes the write end of a duplex I/O stream.
-
#closed? ⇒ Boolean
Checks if the I/O stream is closed.
-
#each(sep = $/) {|String| ... } ⇒ void
Iterates over each line in the stream.
-
#each_byte {|Integer| ... } ⇒ void
Iterates over each byte in the stream.
-
#each_line(sep = $/) {|String| ... } ⇒ void
Alias for #each.
-
#eof ⇒ Boolean
Checks if end of file has been reached.
-
#eof? ⇒ Boolean
Checks if the end of file has been reached.
-
#fcntl(cmd, arg) ⇒ Integer
Performs low-level file control operation.
-
#flush ⇒ IO
Flushes buffered data to the underlying I/O stream.
-
#fsync ⇒ 0
Synchronizes all buffered data with the storage device.
-
#getc ⇒ Integer?
Reads a single character from the stream.
-
#gets(sep = $/) ⇒ String?
Reads the next line from the stream.
-
#ioctl(cmd, arg) ⇒ Integer
Performs low-level I/O control operation.
-
#isatty ⇒ Boolean
Checks if the stream is associated with a terminal device.
-
#lineno ⇒ Integer
Gets the current line number.
-
#pos ⇒ Integer
Gets the current file position.
-
#print ⇒ Integer
Writes a string to the stream.
-
#printf(fmt, *args) ⇒ nil
Writes a formatted string to the stream.
-
#putc(obj) ⇒ Integer
Writes a character to the stream.
-
#puts(obj) ⇒ nil
Writes a string followed by newline to the stream.
-
#read(length = nil, buffer = nil) ⇒ String?
Reads data from the stream.
-
#readchar ⇒ String?
Reads a single character as a string.
-
#readline(sep = $/) ⇒ String
Reads the next line from the stream.
-
#readlines(sep = $/) ⇒ Array<String>
Reads all lines from the stream into an array.
-
#rewind ⇒ 0
Repositions the stream to the beginning.
-
#seek(offset, whence = SEEK_SET) ⇒ 0
Repositions the file pointer.
-
#stat ⇒ File::Stat
Gets file status information.
-
#sync ⇒ IO
Synchronizes the stream with the underlying storage.
-
#sysread(length) ⇒ String
Reads data at the system level.
-
#sysseek(offset, whence = SEEK_SET) ⇒ Integer
Repositions the file pointer at the system level.
-
#syswrite(buf) ⇒ Integer
Writes data to the stream at the OS level.
-
#tell ⇒ Integer
Gets the current file position (alias for #pos).
-
#tty? ⇒ Boolean
Checks if the I/O stream is a terminal device.
-
#ungetc(val) ⇒ nil
Pushes a character back onto the stream.
-
#write(buf) ⇒ Integer
Writes data to the stream.
Instance Attribute Details
#filed ⇒ Object (protected)
Returns the value of attribute filed.
14 15 16 |
# File 'lib/rex/post/io.rb', line 14 def filed @filed end |
#mode ⇒ Object (protected)
Returns the value of attribute mode.
14 15 16 |
# File 'lib/rex/post/io.rb', line 14 def mode @mode end |
Instance Method Details
#binmode ⇒ IO
Sets the stream to binary mode.
53 54 55 |
# File 'lib/rex/post/io.rb', line 53 def binmode raise NotImplementedError end |
#close ⇒ nil
Closes the I/O stream.
62 63 64 |
# File 'lib/rex/post/io.rb', line 62 def close raise NotImplementedError end |
#close_read ⇒ nil
Closes the read end of a duplex I/O stream.
71 72 73 |
# File 'lib/rex/post/io.rb', line 71 def close_read raise NotImplementedError end |
#close_write ⇒ nil
Closes the write end of a duplex I/O stream.
80 81 82 |
# File 'lib/rex/post/io.rb', line 80 def close_write raise NotImplementedError end |
#closed? ⇒ Boolean
Checks if the I/O stream is closed.
33 34 35 |
# File 'lib/rex/post/io.rb', line 33 def closed? raise NotImplementedError end |
#each(sep = $/) {|String| ... } ⇒ void
This method returns an undefined value.
Iterates over each line in the stream.
92 93 94 |
# File 'lib/rex/post/io.rb', line 92 def each(sep = $/, &block) raise NotImplementedError end |
#each_byte {|Integer| ... } ⇒ void
This method returns an undefined value.
Iterates over each byte in the stream.
115 116 117 |
# File 'lib/rex/post/io.rb', line 115 def each_byte(&block) raise NotImplementedError end |
#each_line(sep = $/) {|String| ... } ⇒ void
This method returns an undefined value.
Alias for #each.
104 105 106 |
# File 'lib/rex/post/io.rb', line 104 def each_line(sep = $/, &block) raise NotImplementedError end |
#eof ⇒ Boolean
Checks if end of file has been reached.
124 125 126 |
# File 'lib/rex/post/io.rb', line 124 def eof raise NotImplementedError end |
#eof? ⇒ Boolean
Checks if the end of file has been reached.
24 25 26 |
# File 'lib/rex/post/io.rb', line 24 def eof? return eof end |
#fcntl(cmd, arg) ⇒ Integer
Performs low-level file control operation.
136 137 138 |
# File 'lib/rex/post/io.rb', line 136 def fcntl(cmd, arg) raise NotImplementedError end |
#flush ⇒ IO
Flushes buffered data to the underlying I/O stream.
145 146 147 |
# File 'lib/rex/post/io.rb', line 145 def flush raise NotImplementedError end |
#fsync ⇒ 0
Synchronizes all buffered data with the storage device.
154 155 156 |
# File 'lib/rex/post/io.rb', line 154 def fsync raise NotImplementedError end |
#getc ⇒ Integer?
Reads a single character from the stream.
163 164 165 |
# File 'lib/rex/post/io.rb', line 163 def getc raise NotImplementedError end |
#gets(sep = $/) ⇒ String?
Reads the next line from the stream.
174 175 176 |
# File 'lib/rex/post/io.rb', line 174 def gets(sep = $/) raise NotImplementedError end |
#ioctl(cmd, arg) ⇒ Integer
Performs low-level I/O control operation.
186 187 188 |
# File 'lib/rex/post/io.rb', line 186 def ioctl(cmd, arg) raise NotImplementedError end |
#isatty ⇒ Boolean
Checks if the stream is associated with a terminal device.
195 196 197 |
# File 'lib/rex/post/io.rb', line 195 def isatty raise NotImplementedError end |
#lineno ⇒ Integer
Gets the current line number.
204 205 206 |
# File 'lib/rex/post/io.rb', line 204 def lineno raise NotImplementedError end |
#pos ⇒ Integer
Gets the current file position.
213 214 215 |
# File 'lib/rex/post/io.rb', line 213 def pos raise NotImplementedError end |
#print ⇒ Integer
Writes a string to the stream.
222 223 224 |
# File 'lib/rex/post/io.rb', line 222 def print raise NotImplementedError end |
#printf(fmt, *args) ⇒ nil
Writes a formatted string to the stream.
234 235 236 |
# File 'lib/rex/post/io.rb', line 234 def printf(fmt, *args) raise NotImplementedError end |
#putc(obj) ⇒ Integer
Writes a character to the stream.
245 246 247 |
# File 'lib/rex/post/io.rb', line 245 def putc(obj) raise NotImplementedError end |
#puts(obj) ⇒ nil
Writes a string followed by newline to the stream.
256 257 258 |
# File 'lib/rex/post/io.rb', line 256 def puts(obj) raise NotImplementedError end |
#read(length = nil, buffer = nil) ⇒ String?
Reads data from the stream.
268 269 270 |
# File 'lib/rex/post/io.rb', line 268 def read(length = nil, buffer = nil) raise NotImplementedError end |
#readchar ⇒ String?
Reads a single character as a string.
277 278 279 |
# File 'lib/rex/post/io.rb', line 277 def readchar raise NotImplementedError end |
#readline(sep = $/) ⇒ String
Reads the next line from the stream.
289 290 291 |
# File 'lib/rex/post/io.rb', line 289 def readline(sep = $/) raise NotImplementedError end |
#readlines(sep = $/) ⇒ Array<String>
Reads all lines from the stream into an array.
300 301 302 |
# File 'lib/rex/post/io.rb', line 300 def readlines(sep = $/) raise NotImplementedError end |
#rewind ⇒ 0
Repositions the stream to the beginning.
309 310 311 |
# File 'lib/rex/post/io.rb', line 309 def rewind raise NotImplementedError end |
#seek(offset, whence = SEEK_SET) ⇒ 0
Repositions the file pointer.
321 322 323 |
# File 'lib/rex/post/io.rb', line 321 def seek(offset, whence = SEEK_SET) raise NotImplementedError end |
#stat ⇒ File::Stat
Gets file status information.
330 331 332 |
# File 'lib/rex/post/io.rb', line 330 def stat raise NotImplementedError end |
#sync ⇒ IO
Synchronizes the stream with the underlying storage.
339 340 341 |
# File 'lib/rex/post/io.rb', line 339 def sync raise NotImplementedError end |
#sysread(length) ⇒ String
Reads data at the system level.
350 351 352 |
# File 'lib/rex/post/io.rb', line 350 def sysread(length) raise NotImplementedError end |
#sysseek(offset, whence = SEEK_SET) ⇒ Integer
Repositions the file pointer at the system level.
362 363 364 |
# File 'lib/rex/post/io.rb', line 362 def sysseek(offset, whence = SEEK_SET) raise NotImplementedError end |
#syswrite(buf) ⇒ Integer
Writes data to the stream at the OS level.
373 374 375 |
# File 'lib/rex/post/io.rb', line 373 def syswrite(buf) raise NotImplementedError end |
#tell ⇒ Integer
Gets the current file position (alias for #pos).
380 381 382 |
# File 'lib/rex/post/io.rb', line 380 def tell return pos end |
#tty? ⇒ Boolean
Checks if the I/O stream is a terminal device.
40 41 42 |
# File 'lib/rex/post/io.rb', line 40 def tty? return isatty end |
#ungetc(val) ⇒ nil
Pushes a character back onto the stream.
391 392 393 |
# File 'lib/rex/post/io.rb', line 391 def ungetc(val) raise NotImplementedError end |
#write(buf) ⇒ Integer
Writes data to the stream.
402 403 404 |
# File 'lib/rex/post/io.rb', line 402 def write(buf) raise NotImplementedError end |