Skip to content

Commit c1dcaeb

Browse files
committed
使用head请求判断url是否alive,如果url失效,默认不会跑所有的pocs,如果需要不判断是否alive请使用-p参数指定poc,如果仅仅需要判断url是否存活可以使用-p ISAlIVEURL
1 parent 5248f4e commit c1dcaeb

File tree

7 files changed

+83
-1
lines changed

7 files changed

+83
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ SpringExploit -u https://www.baidu.com/ -proxy http://127.0.0.1:1080
7474
SpringExploit -i 127.0.0.1/24
7575
SpringExploit -u https://www.baidu.com/ -p CVE202222947,CVE202222963
7676
SpringExploit -u https://www.baidu.com/ -p CVE20221388 -shell
77+
78+
使用head请求判断url是否alive,如果url失效,默认不会跑所有的pocs,如果需要不判断是否alive请使用-p参数指定poc,如果仅仅需要判断url是否存活可以使用-p ISAlIVEURL
7779
SpringExploit -sp
7880
7981
```

cmd/commons/attack/Pocslist.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ package attack
33
import "container/list"
44

55
const (
6+
ISAlIVEURL string = "ISAlIVEURL"
7+
68
// 2022年list
9+
710
CVE202222963 string = "CVE202222963"
811
CVE202222965 string = "CVE202222965"
912
CVE202222947 string = "CVE202222947"
1013
CVE20221388 string = "CVE20221388"
1114

1215
// 2021年list
16+
1317
CVE202126084 string = "CVE202126084"
1418
CVE202122986 string = "CVE202122986"
1519
)
1620

1721
func GetList() *list.List {
1822
l := list.New()
1923

24+
l.PushBack(ISAlIVEURL)
25+
2026
// 2022年漏洞
2127
l.PushBack(CVE202222963)
2228
l.PushBack(CVE202222965)

cmd/commons/attack/attack.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ func init() {
2929

3030
func addPoc(pocs map[string]interface{}) map[string]interface{} {
3131
log.Debug("[*] Add PoC")
32+
// 判断url是否存活
33+
pocs["ISAlIVEURL"] = &poc.IsAliveUrl{}
34+
3235
// TODO 添加 2022 poc
3336
//pocs["demo"] = &poc.Demo{}
3437
pocs["CVE202222947"] = &_022.CVE202222947{}
@@ -58,8 +61,18 @@ func attack(url string, pocs map[string]interface{}, hashmap map[string]interfac
5861
//}
5962
// 如果没有选定字符串 则默认所有pocs
6063
if len(pocsName) == 1 && pocsName[0] == "" {
64+
f := pocs["ISAlIVEURL"].(poc.PoC).CheckExp(nil, url, hashmap)
65+
if f {
66+
log.Infof("[*] %s is alive", url)
67+
} else {
68+
log.Infof("[*] %s is not alive, donot attack all pocs, Please check url is alive ?", url)
69+
return
70+
}
6171
log.Info("[*] attack all pocs")
6272
for k, v := range pocs {
73+
if k == "ISAlIVEURL" {
74+
continue
75+
}
6376
log.Infof("[*] attack %s poc %s", url, k)
6477
t := v.(poc.PoC)
6578
t.SendPoc(url, hashmap)

cmd/commons/core/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func Start2(u string, hashmap map[string]interface{}, i int) {
161161
//}
162162
defer func() {
163163
if errs := recover(); errs != nil {
164-
log.Debug("Runner panic: ", errs)
164+
log.Debug(errs)
165165
}
166166
}()
167167

cmd/commons/poc/IsAliveUrl.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package poc
2+
3+
import (
4+
req2 "github.com/SummerSec/SpringExploit/cmd/commons/req"
5+
"github.com/SummerSec/SpringExploit/cmd/commons/utils"
6+
"github.com/imroc/req/v3"
7+
log "github.com/sirupsen/logrus"
8+
)
9+
10+
type IsAliveUrl struct{}
11+
12+
func (t IsAliveUrl) SendPoc(target string, hashmap map[string]interface{}) {
13+
//reqmap := req2.NewReqInfoToMap(hashmap)
14+
//reqmap["url"] = target
15+
//reqmap["method"] = "HEAD"
16+
//reqmap["timeout"] = "3"
17+
//headers := map[string]string{
18+
// "User-Agent": utils.GetUA(),
19+
//}
20+
//reqmap["headers"] = headers
21+
//resp := utils.Send(reqmap)
22+
//if t.CheckExp(resp,target,hashmap) {
23+
// log.Infof("[+] %s is alive", target)
24+
//}
25+
26+
}
27+
28+
func (t IsAliveUrl) SaveResult(target string, file string) {
29+
// nothing to do
30+
}
31+
32+
func (t IsAliveUrl) CheckExp(resp *req.Response, target string, hashmap map[string]interface{}) bool {
33+
reqmap := req2.NewReqInfoToMap(hashmap)
34+
reqmap["url"] = target
35+
reqmap["method"] = "HEAD"
36+
headers := map[string]string{
37+
"User-Agent": utils.GetUA(),
38+
}
39+
reqmap["headers"] = headers
40+
resp2 := utils.Send(reqmap)
41+
log.Debug(resp2.Dump())
42+
if resp2.Dump() == "" {
43+
return false
44+
}
45+
return true
46+
}

cmd/commons/req/request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func NewReqInfoToMap(hashmap map[string]interface{}) map[string]interface{} {
126126
reqmap["mode"] = hashmap["Mode"].(int)
127127
reqmap["h1"] = hashmap["H1"].(bool)
128128
reqmap["proxy"] = hashmap["Proxy"].(string)
129+
reqmap["body"] = ""
129130

130131
return reqmap
131132
}

cmd/test/headurl.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/imroc/req/v3"
6+
)
7+
8+
func main() {
9+
u := "https://sumsasdasdec.me/"
10+
rsp, _ := req.R().EnableDump().Head(u)
11+
12+
fmt.Println(rsp.Dump())
13+
14+
}

0 commit comments

Comments
 (0)