Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/ui/console/command_dispatcher/db/analyze.rb
Views: 11789
module Msf::Ui::Console::CommandDispatcher::Db::Analyze12def cmd_analyze_help3print_line "Usage: analyze [OPTIONS] [addr1 addr2 ...]"4print_line5end67def cmd_analyze(*args)8unless active?9print_error "Not currently connected to a data service for analysis."10return []11end1213host_ranges = []14print_empty = false1516found_vulns = false17reported_module = false1819while (arg = args.shift)20case arg21when '-h','help'22cmd_analyze_help23return24when '-a', '-v'25print_empty = true26when '-p'27wanted_payloads = args.shift.split(',')28else29(arg_host_range(arg, host_ranges))30end31end3233host_ranges.push(nil) if host_ranges.empty?3435host_ids = []36suggested_modules = {}37each_host_range_chunk(host_ranges) do |host_search|38next if host_search && host_search.empty?39eval_hosts_ids = framework.db.hosts(address: host_search).map(&:id)40if eval_hosts_ids41eval_hosts_ids.each do |eval_id|42host_ids.push(eval_id)43end44end45end4647if host_ids.empty?48print_status("No existing hosts stored to analyze.")49else5051host_ids.each do |id|52eval_host = framework.db.hosts(id: id).first53next unless eval_host54unless eval_host.vulns55print_status("No suggestions for #{eval_host.address}.") if print_empty56next57end58found_vulns = true5960host_result = framework.analyze.host(eval_host, payloads: wanted_payloads)61found_modules = host_result[:results]62if found_modules.any?63reported_module = true64print_status("Analysis for #{eval_host.address} ->")65found_modules.each do |res|66print_status(" " + res.mod.fullname + " - " + res.description)67end6869suggested_modules[eval_host.address] = found_modules70elsif print_empty71print_status("No suggestions for #{eval_host.address}.")72end73end7475if !print_empty76if !found_vulns77if host_ranges.any?78print_status("No vulnerabilities found for given hosts.")79else80print_status("No vulnerabilities found for hosts in this workspace.")81end82elsif !reported_module83print_status("No matching modules found.")84end85end86end8788suggested_modules89end9091def cmd_analyze_tabs(_str, words)92return [] unless framework.db.active9394hosts = framework.db.hosts.map(&:address)9596# Limit completion to supplied host if it's the only one97return [] if words.length > 1 && hosts.length == 19899hosts100end101102end103104105