class MetasploitDataModels::ModuleRun
{MetasploitDataModels::ModuleRun} holds the record of having launched a piece of Metasploit content. It has associations to {Mdm::User} for audit purposes, and makes polymorphic associations to things like {Mdm::Vuln} and {Mdm::Host} for flexible record keeping about activity attacking either specific vulns or just making mischief on specific remote targets w/out the context of a vuln or even a remote IP service.
There are also associations to {Mdm::Session} for two use cases: a `spawned_session` is a session created by the ModuleRun. A `target_session` is a session that the ModuleRun is acting upon (e.g.) for running a post module.
Constants
- ERROR
Marks the module as having had a runtime error
- FAIL
Marks the run as having not run successfully
- SUCCEED
Marks the module as having successfully run
- VALID_STATUSES
{ModuleRun} objects will be validated against these statuses
Public Instance Methods
Splits strings formatted like Msf::Module#fullname into components
@example
module_name = "exploit/windows/multi/mah-rad-exploit" module_name_components # => ["exploit","windows","multi","mah-rad-exploit"]
@return [Array]
# File app/models/metasploit_data_models/module_run.rb, line 174 def module_name_components module_fullname.split('/') end
Private Instance Methods
Mark the object as invalid if there is no associated module_name or {Mdm::ModuleDetail} @return [void]
# File app/models/metasploit_data_models/module_run.rb, line 182 def module_information_is_present if module_fullname.blank? errors.add(:base, "module_fullname cannot be blank") end end
Mark the object as invalid if there is a spawned_session but the module is not an exploit and not an aux module with the word “login” in the final portion of `module_fullname`
@return [void]
# File app/models/metasploit_data_models/module_run.rb, line 192 def no_spawned_session_for_non_exploits_except_logins return true unless spawned_session.present? return true if module_name_components.last.include?("login") if module_name_components.first != 'exploit' errors.add(:base, 'spawned_session cannot be set for non-exploit modules. Use target_session.') end end
Mark the object as invalid if there is a target_session but the module is an exploit @return [void]
# File app/models/metasploit_data_models/module_run.rb, line 203 def no_target_session_for_exploits return true unless target_session.present? # nothing to do unless target_session is set if module_name_components.first == 'exploit' return true if module_name_components[2] == 'local' errors.add(:base, 'target_session cannot be set for exploit modules. Use spawned_session.') end end