Class: Ronin::PostEx::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/post_ex/resource.rb

Overview

A base-class for all post-exploitation resources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Resource

Creates a new Resource.

Parameters:

  • session (Object)

    The object controlling the Resource.



39
40
41
# File 'lib/ronin/post_ex/resource.rb', line 39

def initialize(session)
  @session = session
end

Instance Attribute Details

#sessionSessions::Session (readonly)

The object providing control of the resource.

Returns:



31
32
33
# File 'lib/ronin/post_ex/resource.rb', line 31

def session
  @session
end

Instance Method Details

#interactObject

This method is abstract.

Allows resources to spawn interactive consoles.

Raises:

  • (NotImplementedError)


88
89
90
# File 'lib/ronin/post_ex/resource.rb', line 88

def interact
  raise(NotImplementedError,"#{self.class} does not provide a console")
end

#supportsArray<Symbol>

Determines which Resource methods are supported by the controlling object.

Returns:

  • (Array<Symbol>)

    The names of the supported Resource methods.



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).

Examples:

fs.supports?(:read, :write)
# => true

Parameters:

  • method_names (Array<Symbol>)

    The name of the Resource method.

Returns:

  • (Boolean)

    Specifies whether the #session object supports the method.



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