Changes for page Engine_XalanJ

Last modified by Nicolas Gregoire on 2012/01/31 17:35

From version Icon 63.1 Icon
edited by Nicolas Gregoire
on 2012/01/12 22:14
Change comment: There is no comment for this version
To version Icon 64.1 Icon
edited by Nicolas Gregoire
on 2012/01/12 22:35
Change comment: There is no comment for this version

Summary

Details

Icon Page properties
Content
... ... @@ -50,13 +50,23 @@
50 50  
51 51  == OS command execution ==
52 52  
53 -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 ;-)
53 +Once Java code execution is possible, it is trivial to execute arbitrary OS commands using the java.lang.Runtime class.
54 54  
55 +=== Command without output ===
56 +
57 +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 ;-)
58 +
55 55  |=Namespace|=Extension functions|=PoC
56 56  |http:~/~/xml.apache.org/xalan/java|split(), getRuntime(), exec() and toString()|[[xalanj-reverse-bash.xsl>>attach:xalanj-reverse-bash.xsl]]
57 57  
58 58  __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)>>http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String[])||rel="__blank"]].
59 59  
64 +=== Reading stdout ===
65 +
66 +As the output have an unknown number of lines, we must use a loop construct like "while" ... which is not available in XSLT. This limitation is due to the functional programming paradigm but can be circumvented using templates and recursion. This way, we can also __update__ some variables (yeah !), but the syntax is awful and error prone. It's far better to directly write loops using non standard constructs and then convert them in templates + recursion using a dedicated tool like the [[XSLT Loop Compiler>>http://www2.informatik.hu-berlin.de/~~obecker/XSLT/loop-compiler/||rel="__blank"]].
67 +
68 +
69 +
60 60  == File creation ==
61 61  
62 62  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.