Class: Msf::Analyze

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/core/analyze.rb

Instance Method Summary collapse

Constructor Details

#initialize(framework) ⇒ Analyze

Returns a new instance of Analyze.


3
4
5
# File 'lib/msf/core/analyze.rb', line 3

def initialize(framework)
  @framework = framework
end

Instance Method Details

#host(eval_host) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/msf/core/analyze.rb', line 7

def host(eval_host)
  suggested_modules = {}

  mrefs, _mports, _mservs = Msf::Modules::Metadata::Cache.instance.all_remote_exploit_maps

  unless eval_host.vulns
    return {}
  end

  vuln_refs = []
  eval_host.vulns.each do |vuln|
    next if vuln.service.nil?
    vuln_refs.push(*vuln.refs)
  end

  # finds all modules that have references matching those found on host vulns with service data
  found_modules = mrefs.values_at(*(vuln_refs.map { |x| x.name.upcase } & mrefs.keys)).map { |x| x.values }.flatten.uniq
  found_modules.each do |fnd_mod|
    # next if exploit_filter_by_service(fnd_mod, vuln.service)
    next unless exploit_matches_host_os(fnd_mod, eval_host)
  end

  suggested_modules[:modules] = found_modules

  suggested_modules
end