Skip to content

Commit

Permalink
Add more safe navigation to exploit suggester
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanusz-r7 committed Dec 10, 2024
1 parent eb11cb6 commit 9644bee
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/post/multi/recon/local_exploit_suggester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def session_arch
end

def is_module_arch?(mod)
mod_arch = mod.target.arch || mod.arch
return false if mod.target.nil? || mod.target.arch.nil? || mod.arch.nil?

mod_arch = mod.target&.arch || mod.arch
mod_arch.include?(session_arch)
end

Expand All @@ -70,10 +72,10 @@ def is_session_type?(mod)
end

def is_module_platform?(mod)
platform_obj = Msf::Module::Platform.find_platform session.platform
return false if mod.target.nil?
return false if mod.target&.nil? || session.platform&.nil?

module_platforms = mod.target.platform ? mod.target.platform.platforms : mod.platform.platforms
platform_obj = Msf::Module::Platform.find_platform session.platform
module_platforms = mod.target&.platform ? mod.target.platform.platforms : mod.platform.platforms
module_platforms.include? platform_obj
rescue ArgumentError => e
# When not found, find_platform raises an ArgumentError
Expand Down Expand Up @@ -308,9 +310,9 @@ def unwanted_modules_table(unwanted_modules)
session_type_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new

rows = unwanted_modules.map.with_index do |mod, index|
platforms = mod[:module].target.platform&.platforms&.any? ? mod[:module].target.platform.platforms : mod[:module].platform.platforms
platforms = mod[:module].target&.platform&.platforms&.any? ? mod[:module].target.platform.platforms : mod[:module].platform.platforms
platforms ||= []
arch = mod[:module].target.arch&.any? ? mod[:module].target.arch : mod[:module].arch
arch = mod[:module].target&.arch&.any? ? mod[:module].target.arch : mod[:module].arch
arch ||= []

arch.each do |a|
Expand Down

0 comments on commit 9644bee

Please sign in to comment.