Skip to content

Commit

Permalink
Show errors on inaccessible payload files
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanusz-r7 committed Sep 27, 2023
1 parent aa2a843 commit db8e8aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/msf/core/payload/stager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ def handle_connection(conn, opts={})
end
end

p = generate_stage(opts)
begin
p = generate_stage(opts)
rescue ::MetasploitPayloads::NotFoundError, ::MetasploitPayloads::NotReadableError => e
print_error(e.message)
raise e
end

# Encode the stage if stage encoding is enabled
begin
Expand Down
13 changes: 12 additions & 1 deletion lib/msf/ui/console/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,18 @@ def on_startup(opts = {})

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

av_warning_message if framework.eicar_corrupted?
payloads_file_warnings = ::MetasploitPayloads.file_warnings

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

if payloads_file_warnings.any?
reasons = { not_found: 'File not found', not_readable: 'No read permissions', hash_mismatch: 'Hash mismatch' }
warn_msg = "Metasploit Payloads file warnings:\n"
payloads_file_warnings.each do |file|
warn_msg << "\t#{file[:path]} : #{reasons[file[:reason]]}\n"
end
warn(warn_msg)
end

opts["Plugins"].each do |plug|
run_single("load '#{plug}'")
Expand Down

0 comments on commit db8e8aa

Please sign in to comment.