Skip to content

Commit 99f60e6

Browse files
committed
增加判断是否最新版本
1 parent 87f61b6 commit 99f60e6

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

cmd/commons/core/banner.go

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

33
import (
4-
log "github.com/sirupsen/logrus"
4+
"fmt"
55
)
66

77
const banner = `
@@ -18,7 +18,7 @@ const banner = `
1818
const version = "0.0.9"
1919

2020
func ShowBanner(Version string) {
21-
log.Println(banner)
22-
log.Println("\t\t\tAuthor: SummerSec Version:", Version+" Github: https://Github.com/SummerSec\n")
21+
fmt.Println(banner)
22+
fmt.Println("\t\t\tAuthor: SummerSec Version:", Version+" Github: https://Github.com/SummerSec\n")
2323

2424
}

cmd/commons/core/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func ParseOptions() *Options {
7878
flag.Parse()
7979

8080
// TODO 修改版本号
81-
ShowBanner(version)
8281
logs.SaveLogs(options.LogFile)
82+
ShowBanner(version)
8383
showVerbose(options)
8484

8585
if options.Version {

cmd/commons/core/runner.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ func NewRunner(options *Options) (*Runner, error) {
1919

2020
mops := structs.Map(&r.options)
2121
data, _ := json.Marshal(mops)
22-
log.Info("Runner created")
22+
log.Debug("Runner created")
2323
log.Debug(mops)
2424
log.Debug("Runner options: ", string(data))
2525
return &r, nil
2626

2727
}
2828

2929
func (r *Runner) Run() {
30-
log.Debugln("github.com/SummerSec/SpringExploit/cmd/commons/core/runner.go: Run()")
31-
log.Info("Runner Running")
30+
log.Info("Starting SpringExploit")
31+
log.Debug("Runner Running")
3232
//ip := r.options.IP
3333
var urls []string
3434
// TODO: check if options are valid
@@ -42,6 +42,9 @@ func (r *Runner) Run() {
4242
urls = utils.GetIPToUrlsLinks(r.options.IP, urls)
4343
} else if r.options.Update {
4444
selfUpdate()
45+
} else if r.options.Version {
46+
getLatestVersion()
47+
return
4548
} else {
4649
log.Error("No file or url or ips specified")
4750
return

cmd/commons/core/update.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,28 @@ func selfUpdate() {
6464
log.Infof("Successfully Updated to %s Version %s", Repo, latest.Version)
6565

6666
}
67+
68+
// 获取最新版本
69+
func getLatestVersion() {
70+
log.Info("Crrunent Version: ", version)
71+
log.Infof("Latest Version: %s", getLatestVersionFromGithub())
72+
73+
}
74+
75+
// 获取最新版本从github
76+
func getLatestVersionFromGithub() string {
77+
m := &update.Manager{
78+
Store: &githubUpdateStore.Store{
79+
Owner: Owner,
80+
Repo: Repo,
81+
Version: version,
82+
},
83+
}
84+
releases, err := m.LatestReleases()
85+
if err != nil {
86+
log.Error("Failed to get releases", err)
87+
return ""
88+
}
89+
latest := releases[0]
90+
return latest.Version
91+
}

cmd/main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ import (
88
func main() {
99
options := core.ParseOptions()
1010

11-
if options.Url != "" {
11+
//if options.Url != "" {
12+
//
13+
//} else if options.File != "" {
14+
//} else if options.IP != "" {
15+
//} else if options.SP {
16+
// return
17+
//} else {
18+
// log.Info("No url, file or ip specified")
19+
// return
20+
//}
1221

13-
} else if options.File != "" {
14-
} else if options.IP != "" {
15-
} else if options.SP {
16-
return
17-
} else {
18-
log.Info("No url, file or ip specified")
19-
return
20-
}
21-
log.Info("Starting SpringExploit")
2222
r, _ := core.NewRunner(options)
2323
//log.Errorf("Error: %s", err)
2424

0 commit comments

Comments
 (0)