CVE-2017-8046(Spring Data Rest RCE)

环境搭建参考第一个链接,springboot启动文件如下,不同的启类,将Application.class修改一下就可以了,直接debug。注意:默认版本是2.0.3版本,修改成低版本,看一下mvn下载的jar包版本
Alt text
漏洞利用:
第一次请求:
Alt text
第二次请求:
Alt text
注意的点:
需要用PATCH方法,而且请求格式为JSON。根据RFC 6902,发送JSON文档结构需要注意以下两点:
1、请求头为Content-Type: application/json-patch+json
2、需要参数op、路径path,其中op所支持的方法很多,如test,add,replace等,path参数则必须使用斜杠分割
下断调试一下,跟入applyPatch
Alt text
跟入getPatchOperations
Alt text
跟入convert函数,来到这里,path是传入的EL表达式
Alt text
Alt text
Alt text
命令执行的地方
Alt text
string转bytes[]脚本

public class Test
{
    public static void main(String[] args)
    {
        //Original String
        String string = "calc";
        //Convert to byte[]
        byte[] bytes = string.getBytes();
        int i;
        for (i=0;i<bytes.length;i++)
        {
            if (i==0)
            {
                System.out.print("[");
            }
            System.out.print(bytes[i]+",");
            if (i==bytes.length-1)
            {
                System.out.print("]");
            }
        }
    }
}

参考链接:https://www.cnblogs.com/co10rway/p/9380441.html
https://github.com/spring-guides/gs-accessing-data-rest.git
https://github.com/vulhub/vulhub/tree/master/spring/CVE-2017-8046

猜你喜欢

转载自www.cnblogs.com/afanti/p/10682316.html