Class: Msf::Modules::Metadata::Cache

Inherits:
Object
  • Object
show all
Includes:
Maps, Search, Store, Singleton
Defined in:
lib/msf/core/modules/metadata/cache.rb

Constant Summary

Constants included from Store

Store::BaseMetaDataFile, Store::UserMetaDataFile

Constants included from Search

Search::MODULE_TYPE_SHORTHANDS, Search::VALID_PARAMS

Instance Method Summary collapse

Methods included from Maps

#all_remote_exploit_maps

Methods included from Store

#init_store

Methods included from Search

#find, parse_search_string

Instance Method Details

#get_metadataObject

Returns the module data cache, but first ensures all the metadata is loaded


39
40
41
42
43
44
# File 'lib/msf/core/modules/metadata/cache.rb', line 39

def 
  @mutex.synchronize {
    wait_for_load
    @module_metadata_cache.values
  }
end

#refresh_metadata(module_sets) ⇒ Object

Checks for modules loaded that are not a part of the cache and updates the underlying store if there are changes.


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/msf/core/modules/metadata/cache.rb', line 50

def (module_sets)
  @mutex.synchronize {
    unchanged_module_references = get_unchanged_module_references
    has_changes = false
    module_sets.each do |mt|
      unchanged_reference_name_set = unchanged_module_references[mt[0]]

      mt[1].keys.sort.each do |mn|
        next if unchanged_reference_name_set.include? mn

        begin
          module_instance = mt[1].create(mn)
        rescue Exception => e
          elog "Unable to create module: #{mn}. #{e.message}"
        end

        unless module_instance
          wlog "Removing invalid module reference from cache: #{mn}"
          existed = remove_from_cache(mn)
          if existed
            has_changes = true
          end
          next
        end

        begin
          (module_instance)
          has_changes = true
        rescue Exception => e
          elog("Error updating module details for #{module_instance.fullname}", error: e)
        end
      end
    end

    if has_changes
      update_store
      clear_maps
    end
  }
end

#refresh_metadata_instance(module_instance) ⇒ Object

Refreshes cached module metadata as well as updating the store


28
29
30
31
32
33
34
# File 'lib/msf/core/modules/metadata/cache.rb', line 28

def (module_instance)
  @mutex.synchronize {
    dlog "Refreshing #{module_instance.refname} of type: #{module_instance.type}"
    (module_instance)
    update_store
  }
end