Skip to content

Commit 820501b

Browse files
committedJan 3, 2021
🔨 Add -retries flag (close #10)
1 parent 0489388 commit 820501b

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed
 

‎README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen)](https://github.com/kitabisa/ssb/blob/master/LICENSE)
55
[![contributions](https://img.shields.io/badge/contributions-welcome-magenta.svg?style=flat)](https://github.com/kitabisa/ssb/issues)
66
[![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org)
7-
[![Version](https://img.shields.io/badge/version-0.0.2-blueviolet)](https://github.com/kitabisa/ssb/releases)
7+
[![Version](https://img.shields.io/badge/version-0.1.0-blueviolet)](https://github.com/kitabisa/ssb/releases)
88

99
**S**_ecure_ **S**_hell_ **B**_ruteforcer_ — A faster & simpler way to bruteforce SSH server.
1010

@@ -30,7 +30,7 @@ Need [go1.14+](https://golang.org/doc/install#download) compiler installed and c
3030

3131
```bash
3232
▶ ssb [-p port] [-w wordlist.txt] [-t timeout]
33-
[-c concurrent] [-o output] [user@]hostname
33+
[-c concurrent] [-r retries] [-o output] [user@]hostname
3434
```
3535

3636
### Options:
@@ -44,6 +44,8 @@ Need [go1.14+](https://golang.org/doc/install#download) compiler installed and c
4444
Connection timeout (default 30s).
4545
-c concurrent
4646
Concurrency/threads level (default 100).
47+
-r retries
48+
Specify the connection retries (default 1).
4749
-o output
4850
Save valid password to file.
4951
-v

‎internal/runner/constant.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import "time"
55
var (
66
opt *Options
77
uhost []string
8+
vld bool
89
)
910

1011
const (
11-
version = "v0.0.2"
12+
version = "v0.1.0"
1213
banner = `
1314
_
1415
` + version + ` | |
@@ -34,6 +35,8 @@ Options:
3435
Connection timeout (default 30s).
3536
-c concurrent
3637
Concurrency/threads level (default 100).
38+
-r retries
39+
Specify the connection retries (default 1).
3740
-o output
3841
Save valid password to file.
3942
-v

‎internal/runner/parser.go

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
type Options struct {
1616
concurrent int
1717
wordlist string
18+
retries int
1819
verbose bool
1920
timeout time.Duration
2021
output string
@@ -32,6 +33,7 @@ func Parse() *Options {
3233
opt.timeout = timeout
3334

3435
flag.IntVar(&opt.port, "p", 22, "")
36+
flag.IntVar(&opt.retries, "r", 1, "")
3537
flag.IntVar(&opt.concurrent, "c", 100, "")
3638
flag.BoolVar(&opt.verbose, "v", false, "")
3739
flag.StringVar(&opt.output, "o", "", "")

‎internal/runner/runner.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ func New(opt *Options) {
2525
go func() {
2626
defer swg.Done()
2727
for pass := range job {
28-
opt.run(pass)
28+
for i := 0; i < opt.retries; i++ {
29+
if opt.run(pass) {
30+
break
31+
}
32+
}
2933
}
3034
}()
3135
}
@@ -39,7 +43,7 @@ func New(opt *Options) {
3943
gologger.Infof("Done!")
4044
}
4145

42-
func (opt *Options) run(password string) {
46+
func (opt *Options) run(password string) bool {
4347
cfg := ssb.New(opt.user, password, opt.timeout)
4448

4549
con, err := ssb.Connect(opt.host, opt.port, cfg)
@@ -55,7 +59,11 @@ func (opt *Options) run(password string) {
5559
if opt.file != nil {
5660
fmt.Fprintf(opt.file, "%s\n", password)
5761
}
62+
63+
vld = true
5864
}
65+
66+
return vld
5967
}
6068

6169
func (opt *Options) showInfo() {

0 commit comments

Comments
 (0)
Please sign in to comment.