Engine_XalanJ
Xalan-J is a Java based XSLT engine by the Apache Project.
Supported version
1.0
Command line
$> java org.apache.xalan.xslt.Process -in foo.xml -xsl foo.xsl
Note : xml-apis.jar, xercesImpl.jar and xalan*.jar must be in the $CLASSPATH
Identification strings
xsl:vendor-url | http://xml.apache.org/xalan-j |
---|---|
xsl:vendor | Apache Software Foundation |
xsl:version | 1.0 |
Special features
- Java properties disclosure
- Java environment disclosure
- Java code execution
- OS command execution
- File creation
- JDBC connectivity
Java properties disclosure
The xsl:system-property() standard function can be called with non standard arguments, mapped to Java properties. In this example, the name of the Java properties is stored in a separate XML file (
). The XSLT code will, for each property, display its name and its value.Namespace | Function | PoC | Sample output |
---|---|---|---|
http://www.w3.org/1999/XSL/Transform | system-property() |
Java environment disclosure
The checkEnvironment() extension function (documented here) will display some information about the execution context (including available packages, paths, versions, ...).
Namespace | Extension function | PoC | Sample output |
---|---|---|---|
http://xml.apache.org/xalan | checkEnvironment() |
Java code execution
The attached code will display the current date using a newly created "java.util.Date" object. This should be enough to demonstrate Java code execution.
Namespace | Extension function | PoC | Sample output |
---|---|---|---|
http://xml.apache.org/xalan/java/java.util.Date | new() | Current date: Wed Jan 11 22:45:07 CET 2012 |
OS command execution
Once Java code execution is possible, it is trivial to execute arbitrary OS commands using the java.lang.Runtime class. The attached PoC will not read the output of the executed command (because loops are hard in XSLT). But this is not a problem if a reverse-shell have already been started, isn't it ;-)
Namespace | Extension functions | PoC |
---|---|---|
http://xml.apache.org/xalan/java | split(), getRuntime(), exec() and toString() |
Note : as arrays are not a native type in XSLT, we create one in Java via split() before passing it as an argument to exec(String[] cmdarray).
File creation
The "write" extension element allows to create files on the engine side. The content written to the file must be valid UTF-8 (so plain ASCII works too). Existing files can be overwritten.
Namespace | Extension element | Parameter | PoC |
---|---|---|---|
http://xml.apache.org/xalan/redirect | write | file |
JDBC connectivity
It is possible to use XSLT to connect to any database having a corresponding installed JDBC driver. The
PoC simply connects to a local MySQL database using some hard-coded credentials, executes a query and displays the result.Namespace | Extension function | PoC |
---|---|---|
org.apache.xalan.lib.sql.XConnection | new(), query() and close() |
Brute-force
The
file will read some tuples (JDBC driver, database URL, username, passsword) from a XML file ( ) and try to login with each one, effectively brute-forcing credentials from the engine side (usually on the backend ;-).Here's the output when launched from the CLI :
$> java org.apache.xalan.xslt.Process -in xalanj-jdbc-bruteforce.xml -xsl xalanj-jdbc-bruteforce.xsl 2> /dev/null
Username : [root] / Password : [] :
Username : [root] / Password : [uberpasswd] :
Username : [root] / Password : [cnam] : OK !!
Username : [pma] / Password : [pma] :