Skip to content

Commit 846611e

Browse files
committed
增加异常处理
1 parent 99f60e6 commit 846611e

File tree

7 files changed

+21
-22
lines changed

7 files changed

+21
-22
lines changed

cmd/commons/attack/attack.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
)
1010

1111
func Sevice(url string, hashmap map[string]interface{}) {
12-
log.Debugln("github.com/SummerSec/SpringExploit/cmd/commons/attack/attack.go")
1312
log.Debugf("[*] Start attack %s", url)
1413
pocs := make(map[string]interface{})
1514
a := addPoc(pocs)

cmd/commons/core/runner.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ func Start(u string, hashmap map[string]interface{}, i int, c chan int) {
9999
} else {
100100
target = r.Scheme + "://" + r.Host + r.Path
101101
}
102-
102+
defer func() {
103+
if err := recover(); err != nil {
104+
log.Error(" Runner panic: ", err)
105+
}
106+
}()
103107
attack.Sevice(target, hashmap)
104108

105109
// 放到最后,不然无法生效

cmd/commons/core/update.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/tj/go-update/progress"
77
githubUpdateStore "github.com/tj/go-update/stores/github"
88
"runtime"
9+
"strings"
910
)
1011

1112
const (
@@ -68,7 +69,11 @@ func selfUpdate() {
6869
// 获取最新版本
6970
func getLatestVersion() {
7071
log.Info("Crrunent Version: ", version)
71-
log.Infof("Latest Version: %s", getLatestVersionFromGithub())
72+
latestverion := getLatestVersionFromGithub()
73+
log.Infof("Latest Version: %s", latestverion)
74+
if strings.Compare(latestverion, version) > 0 {
75+
log.Info("Use Command SpringExploit -update to update to latest version ")
76+
}
7277

7378
}
7479

@@ -87,5 +92,6 @@ func getLatestVersionFromGithub() string {
8792
return ""
8893
}
8994
latest := releases[0]
95+
9096
return latest.Version
9197
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ func (CVE20221388) CheckExp(resp *req.Response, randstr string, hashmap map[stri
114114
return true
115115
}
116116
return false
117-
return false
118117
}
119118

120119
func completer(d prompt.Document) []prompt.Suggest {

cmd/commons/utils/httpclient.go

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

5555
reqt := client.R().EnableDump()
5656
reqs := SetRequest(reqt, headers, body.(string))
57-
resp, err := reqs.Send(method, url)
58-
if err != nil {
59-
log.Error("send request error: " + err.Error())
60-
return nil
61-
}
57+
defer func() {
58+
if err := recover(); err != nil {
59+
log.Error("send request error: " + err.(string))
60+
}
61+
}()
62+
resp, _ = reqs.Send(method, url)
63+
log.Trace(resp.String())
6264
log.Debugln("send request success")
63-
//res := resp.Dump()
64-
//log.Debugln("response: " + res)
65-
6665
return resp
6766
}

cmd/commons/utils/os.go

Lines changed: 0 additions & 9 deletions
This file was deleted.

cmd/test/emun.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
func main() {
1111
u := "https://api.github.com/repos/SummerSec/SpringExploit/releases/latest"
1212
fmt.Println(u)
13-
resp, _ := req.R().Get(u)
13+
resp, _ := req.C().DevMode().R().Head(u)
14+
fmt.Println(resp.Result())
1415
body, _ := resp.ToString()
1516
// body to map
1617
fmt.Println(body)

0 commit comments

Comments
 (0)