Class: Ronin::PostEx::Resource
- Inherits:
-
Object
- Object
- Ronin::PostEx::Resource
- Defined in:
- lib/ronin/post_ex/resource.rb
Overview
A base-class for all post-exploitation resources.
Direct Known Subclasses
RemoteFile, RemoteProcess, System, System::FS, System::Process, System::Shell
Instance Attribute Summary collapse
-
#session ⇒ Sessions::Session
readonly
The object providing control of the resource.
Instance Method Summary collapse
-
#initialize(session) ⇒ Resource
constructor
Creates a new Resource.
-
#interact ⇒ Object
abstract
Allows resources to spawn interactive consoles.
-
#supports ⇒ Array<Symbol>
Determines which Resource methods are supported by the controlling object.
-
#supports?(*method_names) ⇒ Boolean
Determines whether the #session object supports the resource's method(s).
Constructor Details
#initialize(session) ⇒ Resource
Creates a new Resource.
39 40 41 |
# File 'lib/ronin/post_ex/resource.rb', line 39 def initialize(session) @session = session end |
Instance Attribute Details
#session ⇒ Sessions::Session (readonly)
The object providing control of the resource.
31 32 33 |
# File 'lib/ronin/post_ex/resource.rb', line 31 def session @session end |
Instance Method Details
#interact ⇒ Object
This method is abstract.
Allows resources to spawn interactive consoles.
88 89 90 |
# File 'lib/ronin/post_ex/resource.rb', line 88 def interact raise(NotImplementedError,"#{self.class} does not provide a console") end |
#supports ⇒ Array<Symbol>
Determines which Resource methods are supported by the controlling object.
77 78 79 80 81 |
# File 'lib/ronin/post_ex/resource.rb', line 77 def supports self.class.resource_methods.keys.select do |method_name| supports?(method_name) end end |
#supports?(*method_names) ⇒ Boolean
Determines whether the #session object supports the resource's method(s).
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ronin/post_ex/resource.rb', line 59 def supports?(*method_names) method_names.all? do |method_name| method_name = method_name.to_sym session_methods = self.class.resource_methods[method_name] session_methods && session_methods.all? { |session_method| @session.respond_to?(session_method) } end end |