【技术原创】Java利用技巧——Jetty Servlet型内存马

admin 2023年4月15日12:43:22评论47 views字数 769阅读2分33秒阅读模式

【技术原创】Java利用技巧——Jetty Servlet型内存马

【技术原创】Java利用技巧——Jetty Servlet型内存马        0x00 前言

在上篇文章介绍了Jetty Filter型内存马的实现思路和细节,本文介绍Jetty Servlet型内存马的实现思路和细节

【技术原创】Java利用技巧——Jetty Servlet型内存马        0x01 简介

本文将要介绍以下内容:

实现思路

实现代码

Zimbra环境下的Servlet型内存马

【技术原创】Java利用技巧——Jetty Servlet型内存马        0x02 实现思路

同样是使用Thread获得webappclassloaer,进而通过反射调用相关方法添加Servlet型内存马。

【技术原创】Java利用技巧——Jetty Servlet型内存马        0x03 实现代码

1.添加Servlet

Jetty下可用的完整代码如下:

【技术原创】Java利用技巧——Jetty Servlet型内存马
【技术原创】Java利用技巧——Jetty Servlet型内存马
【技术原创】Java利用技巧——Jetty Servlet型内存马
【技术原创】Java利用技巧——Jetty Servlet型内存马

2.枚举Servlet

(1)通过request对象调用getServletRegistrations枚举Servlet

Jetty下可用的完整代码如下:

【技术原创】Java利用技巧——Jetty Servlet型内存马

(2)通过Thread获得webappclassloaer,通过反射读取_servlets属性来枚举Servlet

Jetty下可用的完整代码如下:

【技术原创】Java利用技巧——Jetty Servlet型内存马
【技术原创】Java利用技巧——Jetty Servlet型内存马

注:

该方法在Zimbra环境下会存在多个重复结果

【技术原创】Java利用技巧——Jetty Servlet型内存马        0x04 Zimbra环境下的Servlet型内存马

Zimbra存在多个名为WebAppClassLoader的线程,所以在添加Servlet时需要修改判断条件,避免提前退出,在实例代码的基础上直接修改即可。

【技术原创】Java利用技巧——Jetty Servlet型内存马

当然,我
们可以通过反射删除内存马对应的jsp实例,测试代码如下:

【技术原创】Java利用技巧——Jetty Servlet型内存马

无论是Filter型内存马还是Servlet型内存马,删除内存马对应的jsp实例不影响内存马的正常使用。

【技术原创】Java利用技巧——Jetty Servlet型内存马        0x05 利用思路

同Filter型内存马一样,Servlet型内存马的优点是不需要写入文件,但是会在服务重启时失效。

【技术原创】Java利用技巧——Jetty Servlet型内存马        0x06 小结

本文介绍了Jetty Servlet型内存马的实现思路和细节,给出了可供测试的代码,分享了Zimbra环境的利用方法。

【技术原创】Java利用技巧——Jetty Servlet型内存马【技术原创】Java利用技巧——Jetty Servlet型内存马

原文始发于微信公众号(嘶吼专业版):【技术原创】Java利用技巧——Jetty Servlet型内存马

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年4月15日12:43:22
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【技术原创】Java利用技巧——Jetty Servlet型内存马https://cn-sec.com/archives/1668796.html

发表评论

匿名网友 填写信息