Module: Ronin::Controls::Behaviors
- Included in:
- Exploits::Exploit, Payloads::Payload
- Defined in:
- lib/ronin/controls/behaviors.rb
Instance Method Summary collapse
-
#behaviors ⇒ Array<Symbol>
Lists the behaviors to be controlled.
-
#control(*behaviors) ⇒ Object
Adds new behaviors to the model which are to be controlled.
-
#control_helper(name) ⇒ Boolean
Attempts to load and extend the control module defined in Ronin::Controls::Helpers.
-
#control_model ⇒ Model
The model used by the
controls
relationship. -
#load_original! ⇒ Object
Load the code from the cached file for the object.
Instance Method Details
#behaviors ⇒ Array<Symbol>
Lists the behaviors to be controlled.
113 114 115 |
# File 'lib/ronin/controls/behaviors.rb', line 113 def behaviors self.controls.map { |control| control.behavior.name.to_sym } end |
#control(*behaviors) ⇒ Object
Adds new behaviors to the model which are to be controlled.
93 94 95 96 97 98 99 100 101 |
# File 'lib/ronin/controls/behaviors.rb', line 93 def control(*behaviors) behaviors.each do |behavior| self.controls << control_model.new( :behavior => Vuln::Behavior[behavior] ) control_helper(behavior) end end |
#control_helper(name) ⇒ Boolean
Attempts to load and extend the control module defined in Ronin::Controls::Helpers.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ronin/controls/behaviors.rb', line 43 def control_helper(name) name = name.to_s module_name = name.to_const_string begin require_within File.join('ronin','controls','helpers'), name rescue Gem::LoadError => e raise(e) rescue ::LoadError return false end unless Ronin::Controls::Helpers.const_defined?(module_name) return false end control_module = Ronin::Controls::Helpers.const_get(module_name) unless control_module.kind_of?(Module) return false end extend control_module return true end |
#control_model ⇒ Model
Returns The model used by the controls
relationship.
75 76 77 |
# File 'lib/ronin/controls/behaviors.rb', line 75 def control_model self.class.relationships[:controls].child_model end |
#load_original! ⇒ Object
Load the code from the cached file for the object. Will also attempt to load and extend any control modules for the controlled behaviors.
124 125 126 127 128 129 130 |
# File 'lib/ronin/controls/behaviors.rb', line 124 def load_original! unless original_loaded? self.behaviors.each { |name| control_helper name } end super end |