Skip to content

Commit 4c709ab

Browse files
authored
Merge pull request #149 from x90skysn3k/dev
v2.3.1 merge to main
2 parents e1cbab8 + c87a211 commit 4c709ab

29 files changed

Lines changed: 792 additions & 220 deletions

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
go-version: "stable"
2727

2828
- name: Run GoReleaser
29-
uses: goreleaser/goreleaser-action@v6.0.0
29+
uses: goreleaser/goreleaser-action@v6.1.0
3030
with:
3131
distribution: goreleaser
3232
version: latest

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# BruteSpray
1+
# Brutespray
22

3-
![Version](https://img.shields.io/badge/Version-2.2.4-red)[![goreleaser](https://github.com/x90skysn3k/brutespray/actions/workflows/release.yml/badge.svg)](https://github.com/x90skysn3k/brutespray/actions/workflows/release.yml)[![Go Report Card](https://goreportcard.com/badge/github.com/x90skysn3k/brutespray)](https://goreportcard.com/report/github.com/x90skysn3k/brutespray)
3+
![Version](https://img.shields.io/badge/Version-2.3.1-red)[![goreleaser](https://github.com/x90skysn3k/brutespray/actions/workflows/release.yml/badge.svg)](https://github.com/x90skysn3k/brutespray/actions/workflows/release.yml)[![Go Report Card](https://goreportcard.com/badge/github.com/x90skysn3k/brutespray)](https://goreportcard.com/report/github.com/x90skysn3k/brutespray)
44

55
Created by: Shane Young/@t1d3nio && Jacob Robles/@shellfail
66

@@ -11,13 +11,19 @@ Brutespray has been re-written in Golang, eliminating the requirement for additi
1111

1212
<img src="https://i.imgur.com/6fQI6Qs.png" width="500">
1313

14-
# Installation
14+
# Install
15+
16+
```
17+
go install github.com/x90skysn3k/brutespray@latest
18+
```
1519

1620
[Release Binaries](https://github.com/x90skysn3k/brutespray/releases)
1721

1822
To Build:
1923

20-
```go build -o brutespray main.go```
24+
```
25+
go build -o brutespray main.go
26+
```
2127

2228
# Usage
2329

@@ -64,6 +70,14 @@ Command: ```brutespray -H ssh://127.0.0.1 -C root:root```
6470

6571
```brutespray -H ssh://10.1.1.0/24:22 -t 1000```
6672

73+
#### Socks5 Proxy Support
74+
75+
```brutespray -H ssh://10.1.1.0/24:22 -socks5 localhost:1080```
76+
77+
#### Network Interface Support
78+
79+
```brutespray -H ssh://10.1.1.0/24:22 -iface tun0```
80+
6781
#### Print Found Services
6882

6983
```brutespray -f nessus.nessus -P -q```
@@ -102,10 +116,6 @@ Command: ```brutespray -H ssh://127.0.0.1 -C root:root```
102116

103117
Feel free to open an issue if these work, or if you have any issues
104118

105-
# Services in Progress
106-
107-
* rdp - the issue is no one has written a good library for NLA
108-
109119
# Data Specs
110120
```json
111121
{"host":"127.0.0.1","port":"3306","service":"mysql"}
@@ -134,10 +144,10 @@ user4:pass1
134144
# Planned Features
135145

136146
* Add domain option for RDP, SMB
137-
* Ability to set proxy
138-
* Ability to select interface
147+
* ~~Ability to set proxy~~
148+
* ~~Ability to select interface~~
139149
* More modules
140-
* Better connection handling
150+
* ~~Better connection handling~~
141151

142152
# Star History
143153

brute/asterisk.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,27 @@ package brute
22

33
import (
44
"fmt"
5-
"net"
65
"strings"
76
"time"
87

98
"github.com/wenerme/astgo/ami"
9+
"github.com/x90skysn3k/brutespray/modules"
1010
)
1111

1212
// this is very alpha and I have no idea if it even works
13-
func BruteAsterisk(host string, port int, user, password string, timeout time.Duration) (bool, bool) {
13+
func BruteAsterisk(host string, port int, user, password string, timeout time.Duration, socks5 string, netInterface string) (bool, bool) {
1414
target := fmt.Sprintf("%s:%d", host, port)
15-
conn, err := net.DialTimeout("tcp", target, timeout)
15+
connManager, err := modules.NewConnectionManager(socks5, timeout, netInterface)
1616
if err != nil {
1717
return false, false
1818
}
19+
20+
service := "asterisk"
21+
conn, err := connManager.Dial("tcp", target)
22+
if err != nil {
23+
modules.PrintSocksError(service, fmt.Sprintf("%v", err))
24+
return false, false
25+
}
1926
defer conn.Close()
2027

2128
boot := make(chan *ami.Message, 1)

brute/ftp.go

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,59 @@
11
package brute
22

33
import (
4-
"strconv"
4+
"fmt"
5+
"net"
56
"time"
67

78
"github.com/jlaffaye/ftp"
9+
"github.com/x90skysn3k/brutespray/modules"
810
)
911

10-
func BruteFTP(host string, port int, user, password string, timeout time.Duration) (bool, bool) {
11-
conn, err := ftp.Dial(host+":"+strconv.Itoa(port), ftp.DialWithTimeout(timeout))
12+
func BruteFTP(host string, port int, user, password string, timeout time.Duration, socks5 string, netInterface string) (bool, bool) {
13+
timer := time.NewTimer(timeout)
14+
defer timer.Stop()
15+
16+
type result struct {
17+
client *ftp.ServerConn
18+
err error
19+
}
20+
done := make(chan result)
21+
22+
cm, err := modules.NewConnectionManager(socks5, timeout, netInterface)
1223
if err != nil {
1324
return false, false
1425
}
15-
defer func() {
16-
if err := conn.Quit(); err != nil {
17-
_ = err
18-
//fmt.Printf("Failed to send QUIT command: %v\n", err)
26+
27+
go func() {
28+
conn, err := cm.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
29+
if err != nil {
30+
done <- result{nil, err}
31+
return
32+
}
33+
defer conn.Close()
34+
35+
client, err := ftp.Dial(conn.RemoteAddr().String(), ftp.DialWithDialFunc(func(network, addr string) (net.Conn, error) { return conn, nil }))
36+
if err != nil {
37+
done <- result{nil, err}
38+
return
1939
}
40+
err = client.Login(user, password)
41+
done <- result{client, err}
2042
}()
2143

22-
err = conn.Login(user, password)
23-
if err != nil {
24-
return false, true
44+
select {
45+
case <-timer.C:
46+
return false, false
47+
case result := <-done:
48+
if result.client != nil {
49+
err := result.client.Quit()
50+
if err != nil {
51+
_ = err
52+
}
53+
}
54+
if result.err != nil {
55+
return false, true
56+
}
57+
return true, true
2558
}
26-
27-
return true, true
2859
}

brute/imap.go

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
11
package brute
22

33
import (
4-
"crypto/tls"
54
"fmt"
6-
"net"
75
"time"
86

97
"github.com/emersion/go-imap/client"
8+
"github.com/x90skysn3k/brutespray/modules"
109
)
1110

12-
func BruteIMAP(host string, port int, user, password string, timeout time.Duration) (bool, bool) {
13-
var (
14-
conn net.Conn
15-
err error
16-
)
17-
18-
conn, err = net.DialTimeout("tcp", fmt.Sprintf("%s:%d", host, port), timeout)
19-
11+
func BruteIMAP(host string, port int, user, password string, timeout time.Duration, socks5 string, netInterface string) (bool, bool) {
12+
var service = "imap"
13+
cm, err := modules.NewConnectionManager(socks5, timeout, netInterface)
2014
if err != nil {
21-
tlsDialer := &tls.Dialer{
22-
NetDialer: &net.Dialer{
23-
Timeout: timeout,
24-
},
25-
Config: &tls.Config{
26-
InsecureSkipVerify: true,
27-
},
28-
}
29-
30-
_, err = tlsDialer.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
15+
modules.PrintSocksError(service, fmt.Sprintf("%v", err))
16+
return false, false
17+
}
3118

32-
if err != nil {
33-
return false, false
34-
} else {
35-
return false, true
36-
}
19+
conn, err := cm.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
20+
if err != nil {
21+
modules.PrintSocksError(service, fmt.Sprintf("%v", err))
22+
return false, false
3723
}
3824

3925
c, err := client.New(conn)

brute/mongodb.go

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,87 @@ package brute
33
import (
44
"context"
55
"fmt"
6+
"net"
67
"time"
78

89
"go.mongodb.org/mongo-driver/mongo"
910
"go.mongodb.org/mongo-driver/mongo/options"
10-
"go.mongodb.org/mongo-driver/mongo/readpref"
11+
12+
"github.com/x90skysn3k/brutespray/modules"
1113
)
1214

13-
func BruteMongoDB(host string, port int, user, password string, timeout time.Duration) (bool, bool) {
15+
type ContextDialerWrapper struct {
16+
CM *modules.ConnectionManager
17+
}
18+
19+
func (cdw *ContextDialerWrapper) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
20+
if _, ok := ctx.Deadline(); ok {
21+
22+
return cdw.CM.DialFunc(network, address)
23+
}
24+
return cdw.CM.DialFunc(network, address)
25+
}
26+
27+
func BruteMongoDB(host string, port int, user, password string, timeout time.Duration, socks5 string, netInterface string) (bool, bool) {
28+
cm, err := modules.NewConnectionManager(socks5, timeout, netInterface)
29+
if err != nil {
30+
//fmt.Printf("Failed to create connection manager: %v\n", err)
31+
return false, false
32+
}
33+
1434
ctx, cancel := context.WithTimeout(context.Background(), timeout)
1535
defer cancel()
1636

17-
clientOptions := options.Client().ApplyURI(fmt.Sprintf("mongodb://%s:%s@%s:%d", user, password, host, port))
37+
dialer := &ContextDialerWrapper{CM: cm}
38+
39+
clientOptions := options.Client().
40+
ApplyURI(fmt.Sprintf("mongodb://%s:%s@%s:%d", user, password, host, port)).
41+
SetDialer(dialer)
1842
client, err := mongo.Connect(ctx, clientOptions)
1943
if err != nil {
44+
//fmt.Printf("Failed to connect: %v\n", err)
2045
return false, false
2146
}
2247
defer func() {
2348
if err := client.Disconnect(ctx); err != nil {
2449
_ = err
50+
//fmt.Printf("Failed to disconnect: %v\n", err)
2551
}
2652
}()
2753

28-
err = client.Ping(ctx, readpref.Primary())
54+
err = client.Database("admin").RunCommand(ctx, map[string]interface{}{"ping": 1}).Err()
2955
if err != nil {
56+
if mongo.IsTimeout(err) {
57+
//fmt.Printf("Connection timeout: %v\n", err)
58+
return false, false
59+
}
60+
if isAuthError(err) {
61+
//fmt.Printf("Authentication failed: %v\n", err)
62+
return false, true
63+
}
64+
//fmt.Printf("Other error during ping: %v\n", err)
3065
return false, true
3166
}
67+
68+
//fmt.Println("Authentication successful.")
3269
return true, true
3370
}
71+
72+
func isAuthError(err error) bool {
73+
if commandError, ok := err.(mongo.CommandError); ok {
74+
authErrorCodes := map[int32]bool{
75+
18: true, // Authentication failed
76+
13: true, // Unauthorized
77+
8000: true, // SaslAuthenticationFailed
78+
}
79+
return authErrorCodes[commandError.Code]
80+
}
81+
if writeException, ok := err.(mongo.WriteException); ok {
82+
for _, we := range writeException.WriteErrors {
83+
if we.Code == 18 || we.Code == 13 || we.Code == 8000 {
84+
return true
85+
}
86+
}
87+
}
88+
return false
89+
}

brute/mssql.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,41 @@ import (
44
"context"
55
"database/sql"
66
"fmt"
7-
"net"
87
"time"
8+
9+
_ "github.com/denisenkom/go-mssqldb"
10+
"github.com/x90skysn3k/brutespray/modules"
911
)
1012

11-
func BruteMSSQL(host string, port int, user, password string, timeout time.Duration) (bool, bool) {
12-
connString := fmt.Sprintf("server=%s:%d;user id=%s;password=%s;database=master", host, port, user, password)
13+
func BruteMSSQL(host string, port int, user, password string, timeout time.Duration, socks5 string, netInterface string) (bool, bool) {
14+
connString := fmt.Sprintf("server=%s;port=%d;user id=%s;password=%s", host, port, user, password)
15+
16+
cm, err := modules.NewConnectionManager(socks5, timeout, netInterface)
17+
if err != nil {
18+
return false, false
19+
}
1320

1421
ctx, cancel := context.WithTimeout(context.Background(), timeout)
1522
defer cancel()
1623

17-
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", host, port), timeout)
24+
conn, err := cm.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
1825
if err != nil {
1926
return false, false
2027
}
2128
_ = conn.Close()
2229

2330
db, err := sql.Open("mssql", connString)
2431
if err != nil {
32+
//fmt.Println(err)
2533
return false, true
2634
}
2735
defer db.Close()
2836

2937
err = db.PingContext(ctx)
3038
if err != nil {
39+
//fmt.Println(err)
3140
return false, true
3241
}
42+
3343
return true, true
3444
}

brute/mysql.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import (
44
"context"
55
"database/sql"
66
"fmt"
7-
"net"
87
"time"
98

9+
"github.com/x90skysn3k/brutespray/modules"
10+
1011
_ "github.com/go-sql-driver/mysql"
1112
)
1213

13-
func BruteMYSQL(host string, port int, user, password string, timeout time.Duration) (bool, bool) {
14-
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", host, port), timeout)
14+
func BruteMYSQL(host string, port int, user, password string, timeout time.Duration, socks5 string, netInterface string) (bool, bool) {
15+
cm, err := modules.NewConnectionManager(socks5, timeout, netInterface)
16+
if err != nil {
17+
return false, false
18+
}
19+
20+
conn, err := cm.Dial("tcp", fmt.Sprintf("%s:%d", host, port))
1521
if err != nil {
1622
return false, false
1723
}

0 commit comments

Comments
 (0)