Skip to content

Commit

Permalink
🔨 Add -retries flag (close #10)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwisiswant0 committed Jan 3, 2021
1 parent 0489388 commit 820501b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen)](https://github.com/kitabisa/ssb/blob/master/LICENSE)
[![contributions](https://img.shields.io/badge/contributions-welcome-magenta.svg?style=flat)](https://github.com/kitabisa/ssb/issues)
[![made with Go](https://img.shields.io/badge/made%20with-Go-brightgreen)](http://golang.org)
[![Version](https://img.shields.io/badge/version-0.0.2-blueviolet)](https://github.com/kitabisa/ssb/releases)
[![Version](https://img.shields.io/badge/version-0.1.0-blueviolet)](https://github.com/kitabisa/ssb/releases)

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

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

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

### Options:
Expand All @@ -44,6 +44,8 @@ Need [go1.14+](https://golang.org/doc/install#download) compiler installed and c
Connection timeout (default 30s).
-c concurrent
Concurrency/threads level (default 100).
-r retries
Specify the connection retries (default 1).
-o output
Save valid password to file.
-v
Expand Down
5 changes: 4 additions & 1 deletion internal/runner/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import "time"
var (
opt *Options
uhost []string
vld bool
)

const (
version = "v0.0.2"
version = "v0.1.0"
banner = `
_
` + version + ` | |
Expand All @@ -34,6 +35,8 @@ Options:
Connection timeout (default 30s).
-c concurrent
Concurrency/threads level (default 100).
-r retries
Specify the connection retries (default 1).
-o output
Save valid password to file.
-v
Expand Down
2 changes: 2 additions & 0 deletions internal/runner/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type Options struct {
concurrent int
wordlist string
retries int
verbose bool
timeout time.Duration
output string
Expand All @@ -32,6 +33,7 @@ func Parse() *Options {
opt.timeout = timeout

flag.IntVar(&opt.port, "p", 22, "")
flag.IntVar(&opt.retries, "r", 1, "")
flag.IntVar(&opt.concurrent, "c", 100, "")
flag.BoolVar(&opt.verbose, "v", false, "")
flag.StringVar(&opt.output, "o", "", "")
Expand Down
12 changes: 10 additions & 2 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ func New(opt *Options) {
go func() {
defer swg.Done()
for pass := range job {
opt.run(pass)
for i := 0; i < opt.retries; i++ {
if opt.run(pass) {
break
}
}
}
}()
}
Expand All @@ -39,7 +43,7 @@ func New(opt *Options) {
gologger.Infof("Done!")
}

func (opt *Options) run(password string) {
func (opt *Options) run(password string) bool {
cfg := ssb.New(opt.user, password, opt.timeout)

con, err := ssb.Connect(opt.host, opt.port, cfg)
Expand All @@ -55,7 +59,11 @@ func (opt *Options) run(password string) {
if opt.file != nil {
fmt.Fprintf(opt.file, "%s\n", password)
}

vld = true
}

return vld
}

func (opt *Options) showInfo() {
Expand Down

0 comments on commit 820501b

Please sign in to comment.