Module: LootDataProxy
- Included in:
- DataProxyAutoLoader
- Defined in:
- lib/metasploit/framework/data_service/proxy/loot_data_proxy.rb
Instance Method Summary collapse
- #find_or_create_loot(opts) ⇒ Object
- #loots(opts = {}) ⇒ Object (also: #loot)
- #report_loot(opts) ⇒ Object
- #update_loot(opts) ⇒ Object
Instance Method Details
#find_or_create_loot(opts) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/metasploit/framework/data_service/proxy/loot_data_proxy.rb', line 19 def find_or_create_loot(opts) begin # create separate opts for find operation since the report operation uses slightly different keys # TODO: standardize option keys used for the find and report operations find_opts = opts.clone # convert type to ltype find_opts[:ltype] = find_opts.delete(:type) if find_opts.key?(:type) # convert host to nested hosts address find_opts[:hosts] = {address: find_opts.delete(:host)} if find_opts.key?(:host) loot = loots(find_opts) if loot.nil? || loot.first.nil? loot = report_loot(opts.clone) else loot = loot.first end loot rescue => e self.log_error(e, "Problem finding or creating loot") end end |
#loots(opts = {}) ⇒ Object Also known as: loot
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/metasploit/framework/data_service/proxy/loot_data_proxy.rb', line 41 def loots(opts = {}) begin self.data_service_operation do |data_service| add_opts_workspace(opts) data_service.loot(opts) end # Map remote db error to a local rails database exception for error handling consistency rescue Metasploit::Framework::DataService::Remote::NotFound => _e raise ActiveRecord::RecordNotFound, 'Loot not found' rescue => e self.log_error(e, "Problem retrieving loot") end end |
#report_loot(opts) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/metasploit/framework/data_service/proxy/loot_data_proxy.rb', line 5 def report_loot(opts) begin self.data_service_operation do |data_service| unless data_service.is_a?(Msf::DBManager) opts[:data] = Base64.urlsafe_encode64(opts[:data].to_s) unless opts[:data].nil? end add_opts_workspace(opts) data_service.report_loot(opts) end rescue => e self.log_error(e, "Problem reporting loot") end end |
#update_loot(opts) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/metasploit/framework/data_service/proxy/loot_data_proxy.rb', line 57 def update_loot(opts) begin self.data_service_operation do |data_service| data_service.update_loot(opts) end rescue => e self.log_error(e, "Problem updating loot") end end |