Skip to content

Commit 5c25353

Browse files
committed
1 parent 75d8862 commit 5c25353

File tree

17 files changed

+505
-162
lines changed

17 files changed

+505
-162
lines changed

cmd/commons/attack/attack.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package attack
2+
3+
import (
4+
"github.com/SummerSec/SpringExploit/cmd/commons/poc"
5+
log "github.com/sirupsen/logrus"
6+
)
7+
8+
func Sevice(url string, hashmap map[string]interface{}) {
9+
log.Debugln("github.com/SummerSec/SpringExploit/cmd/commons/attack/attack.go")
10+
log.Debugf("[*] Start attack %s", url)
11+
pocs := make(map[string]interface{})
12+
a := addPoc(pocs)
13+
//for k, v := range hashmap {
14+
// log.Debugln("key: ", k, " value: ", v)
15+
//}
16+
for _, v := range a { // 循环添加poc
17+
t := v.(poc.PoC)
18+
t.SendPoc(url, hashmap)
19+
}
20+
21+
}
22+
23+
func init() {
24+
log.Debug("[*] Init attack")
25+
}
26+
27+
func addPoc(pocs map[string]interface{}) map[string]interface{} {
28+
log.Debugln("github.com/SummerSec/SpringExploit/cmd/commons/attack/attack.go:25")
29+
log.Debug("[*] Add PoC")
30+
//pocs["demo"] = &poc.Demo{}
31+
pocs["CVE202222947"] = &poc.CVE202222947{}
32+
return pocs
33+
34+
}

cmd/commons/core/banner.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
package core
22

3-
import log "github.com/sirupsen/logrus"
3+
import (
4+
"fmt"
5+
)
46

57
const banner = `
6-
7-
8-
8+
_________ .__ ___________ .__ .__ __
9+
/ _____/______ _______ |__| ____ ____ \_ _____/___ _________ | | ____ |__|_/ |_
10+
\_____ \ \____ \\_ __ \| | / \ / ___\ | __)_ \ \/ /\____ \ | | / _ \ | |\ __\
11+
/ \| |_> >| | \/| || | \/ /_/ > | \ > < | |_> >| |__( <_> )| | | |
12+
/_______ /| __/ |__| |__||___| /\___ / /_______ //__/\_ \| __/ |____/ \____/ |__| |__|
13+
\/ |__| \//_____/ \/ \/|__|
14+
915
`
1016

1117
func ShowBanner(Version string) {
12-
log.Println(banner)
13-
log.Println("Version:", Version)
18+
fmt.Println(banner)
19+
fmt.Println("\t\t\tAuthor: SummerSec Version:", Version+" Github: https://Github.com/SummerSec\n")
20+
//log.Println(banner)
21+
//log.Println("Version:", Version)
1422

1523
}

cmd/commons/core/options.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type Options struct {
1313
File string
1414
// 传入的url
1515
Url string
16+
// 设置超时时间
17+
Timeout int
1618

1719
// 代理设置
1820
Proxy string
@@ -26,9 +28,12 @@ type Options struct {
2628
// 日志输出文件
2729
LogFile string
2830
// 重复请求次数
29-
Repeat int
31+
Retry int
3032
// ip 段
3133
IP string
34+
35+
// 保存结果
36+
Out string
3237
}
3338

3439
func (o Options) toString() interface{} {
@@ -38,16 +43,18 @@ func (o Options) toString() interface{} {
3843

3944
func ParseOptions() *Options {
4045
options := &Options{}
41-
flag.IntVar(&options.Mode, "mode", 6, "debug mode off (default Infolevel = 0 PanicLevel = 1 FatalLevel = 2 \n"+"\t\t ErrorLevel = 3 WarnLevel = 4 InfoLevel = 5 DebugLevel = 6 TraceLevel = 7)")
42-
flag.IntVar(&options.Thread, "thread", 1, "thread number (default thread = 1)")
43-
flag.StringVar(&options.File, "file", "", "file to read example: -file=test.txt")
44-
flag.StringVar(&options.Url, "url", "", "url to read example: -url=http://www.baidu.com")
46+
flag.IntVar(&options.Mode, "m", 6, "debug mode off ( Infolevel = 0 PanicLevel = 1 FatalLevel = 2 \n"+"\t ErrorLevel = 3 WarnLevel = 4 InfoLevel = 5 DebugLevel = 6 TraceLevel = 7)")
47+
flag.IntVar(&options.Thread, "t", 1, "threads number ")
48+
flag.StringVar(&options.File, "f", "", "file to read example: -file=test.txt")
49+
flag.StringVar(&options.Url, "u", "", "url to read example: -url=http://www.baidu.com")
4550
flag.StringVar(&options.Proxy, "proxy", "", "proxy example: -proxy=http://127.0.0.1:8080 or -proxy=socks5://127.0.0.1:1080")
4651
flag.BoolVar(&options.Version, "version", false, "show version")
4752
flag.BoolVar(&options.Verbose, "verbose", false, "show verbose")
4853
flag.StringVar(&options.LogFile, "log", "logs.txt", "log file example: -log=/logs/logs.txt")
49-
flag.IntVar(&options.Repeat, "repeat", 3, "repeat request times")
50-
flag.StringVar(&options.IP, "ip", "", "ip segment example: -ip=192.168.0.1/24 ")
54+
flag.IntVar(&options.Retry, "retry", 3, "repeat request times")
55+
flag.StringVar(&options.IP, "i", "", "ip segment example: -ip=192.168.0.1/24 ")
56+
flag.IntVar(&options.Timeout, "timeout", 10, "timeout")
57+
flag.StringVar(&options.Out, "o", "result.txt", "out file example: -o=result.txt default result.txt")
5158
flag.Parse()
5259

5360
v := "0.0.1"
@@ -62,6 +69,7 @@ func ParseOptions() *Options {
6269
options.Url = ""
6370

6471
} else {
72+
ShowBanner(v)
6573
flag.PrintDefaults()
6674
}
6775
showVerbose(options)

cmd/commons/core/request.go

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

cmd/commons/core/runner.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package core
22

33
import (
44
"encoding/json"
5+
"github.com/SummerSec/SpringExploit/cmd/commons/attack"
56
"github.com/SummerSec/SpringExploit/cmd/commons/utils"
67
"github.com/fatih/structs"
78
log "github.com/sirupsen/logrus"
@@ -13,6 +14,7 @@ type Runner struct {
1314

1415
func NewRunner(options *Options) (*Runner, error) {
1516
r := Runner{options: options}
17+
1618
mops := structs.Map(&r.options)
1719
data, _ := json.Marshal(mops)
1820
log.Info("Runner created")
@@ -23,21 +25,33 @@ func NewRunner(options *Options) (*Runner, error) {
2325
}
2426

2527
func (r *Runner) Run() {
28+
log.Debugln("github.com/SummerSec/SpringExploit/cmd/commons/core/runner.go: Run()")
2629
log.Info("Runner Running")
2730
f := r.options.File
2831
var urls []string
32+
// TODO: check if options are valid
33+
//r.options.Url = "http://127.0.0.1:8090/"
34+
2935
if f == "" {
3036
urls = append(urls, r.options.Url)
3137
} else {
3238
urls, _ = utils.ReadFile(r.options.File)
3339
}
40+
log.Debugln("URLs: ", urls)
3441
var i = 0
3542
k := r.options.Thread
43+
hashmap := structs.Map(&r.options)
3644
for i < len(urls) {
3745
for t := 0; t < k; t++ {
46+
if i == len(urls) {
47+
break
48+
}
3849
if urls[i] != "" {
39-
go Start(urls[i]) // Start 3 goroutines
40-
i++
50+
log.Debugln("Running attack on: ", urls[i])
51+
// 通道通信 发送url 并且 i++
52+
c := make(chan int)
53+
go Start(urls[i], hashmap, i, c) // Start 3 goroutines
54+
i = <-c
4155
} else {
4256
break
4357
}
@@ -46,8 +60,17 @@ func (r *Runner) Run() {
4660

4761
}
4862

49-
func Start(url string) {
63+
func Start(url string, hashmap map[string]interface{}, i int, c chan int) {
64+
log.Debugln("github/SummerSec/SpringExploit/cmd/commons/core/runner.go: Start")
65+
5066
log.Info("Runner started")
5167
log.Infoln("testing URL: ", url)
68+
//for k, v := range hashmap {
69+
// log.Debugln("key: ", k, " value: ", v)
70+
//}
71+
attack.Sevice(url, hashmap)
72+
73+
// 放到最后,不然无法生效
74+
c <- i + 1
5275

5376
}

0 commit comments

Comments
 (0)