Skip to content

Commit

Permalink
reduce nesting in the check routine
Browse files Browse the repository at this point in the history
  • Loading branch information
sfewer-r7 committed Nov 6, 2023
1 parent 4272678 commit ea21036
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions modules/exploits/multi/misc/apache_activemq_rce_cve_2023_46604.rb
Expand Up @@ -92,27 +92,24 @@ def check

return CheckCode::Unknown unless magic == 'ActiveMQ'

if res =~ /ProviderVersion...(\d+\.\d+\.\d+)/
return CheckCode::Detected unless res =~ /ProviderVersion...(\d+\.\d+\.\d+)/

version = Rex::Version.new(::Regexp.last_match(1))
version = Rex::Version.new(::Regexp.last_match(1))

ranges = [
['5.18.0', '5.18.2'],
['5.17.0', '5.17.5'],
['5.16.0', '5.16.6'],
['0.0.0', '5.15.15']
]
ranges = [
['5.18.0', '5.18.2'],
['5.17.0', '5.17.5'],
['5.16.0', '5.16.6'],
['0.0.0', '5.15.15']
]

ranges.each do |min, max|
if version.between?(Rex::Version.new(min), Rex::Version.new(max))
return Exploit::CheckCode::Appears("Apache ActiveMQ #{version}")
end
ranges.each do |min, max|
if version.between?(Rex::Version.new(min), Rex::Version.new(max))
return Exploit::CheckCode::Appears("Apache ActiveMQ #{version}")
end

return Exploit::CheckCode::Safe("Apache ActiveMQ #{version}")
end

CheckCode::Detected
Exploit::CheckCode::Safe("Apache ActiveMQ #{version}")
end

def exploit
Expand Down

0 comments on commit ea21036

Please sign in to comment.