Skip to content

Commit

Permalink
Wrap Payloads manifest errors in a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanusz-r7 committed Sep 29, 2023
1 parent b61cd79 commit fdeb15e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 7 additions & 0 deletions lib/msf/core/feature_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class FeatureManager
DATASTORE_FALLBACKS = 'datastore_fallbacks'
FULLY_INTERACTIVE_SHELLS = 'fully_interactive_shells'
MANAGER_COMMANDS = 'manager_commands'
METASPLOIT_PAYLOAD_WARNINGS = 'metasploit_payload_warnings'
DEFAULTS = [
{
name: WRAPPED_TABLES,
Expand All @@ -39,6 +40,12 @@ class FeatureManager
description: 'When enabled you can consistently set username across modules, instead of setting SMBUser/FTPUser/BIND_DN/etc',
requires_restart: true,
default_value: true
}.freeze,
{
name: METASPLOIT_PAYLOAD_WARNINGS,
description: 'When enabled Metasploit will output warnings about missing Metasploit payloads, for instance if they were removed by antivirus etc',
requires_restart: true,
default_value: false
}.freeze
].freeze

Expand Down
14 changes: 8 additions & 6 deletions lib/msf/ui/console/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,18 @@ def on_startup(opts = {})

run_single("banner") unless opts['DisableBanner']

payloads_manifest_errors = ::MetasploitPayloads.manifest_errors
payloads_manifest_errors = framework.features.enabled?(::Msf::FeatureManager::METASPLOIT_PAYLOAD_WARNINGS) ? ::MetasploitPayloads.manifest_errors : []

av_warning_message if (framework.eicar_corrupted? || payloads_manifest_errors.any?)

if payloads_manifest_errors.any?
warn_msg = "Metasploit Payloads manifest errors:\n"
payloads_manifest_errors.each do |file|
warn_msg << "\t#{file[:path]} : #{file[:error]}\n"
if framework.features.enabled?(::Msf::FeatureManager::METASPLOIT_PAYLOAD_WARNINGS)
if payloads_manifest_errors.any?
warn_msg = "Metasploit Payloads manifest errors:\n"
payloads_manifest_errors.each do |file|
warn_msg << "\t#{file[:path]} : #{file[:error]}\n"
end
$stderr.print(warn_msg)
end
$stderr.print(warn_msg)
end

opts["Plugins"].each do |plug|
Expand Down

0 comments on commit fdeb15e

Please sign in to comment.