Skip to content

Commit 0c3f8b4

Browse files
committed
Refactor the all code to add an orchestrator and be more scalable
Fix few bugs Add debugs and verbose logs
1 parent 5a30dba commit 0c3f8b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+706
-744
lines changed

src/adfs/brute.go

-69
This file was deleted.

src/azure/userEnum.go

-152
This file was deleted.

src/cmd/brute/adfs.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package brute
22

33
import (
4-
"GoMapEnum/src/adfs"
54
"GoMapEnum/src/logger"
5+
"GoMapEnum/src/modules/adfs"
6+
"GoMapEnum/src/orchestrator"
67
"errors"
78

89
"github.com/spf13/cobra"
@@ -34,7 +35,11 @@ go run main.go bruteSpray adfs -t adfs.contoso.com -u [email protected] -p A
3435
adfsOptions.NoBruteforce = noBruteforce
3536
adfsOptions.Sleep = sleep
3637
adfsOptions.Proxy = proxy
37-
adfsOptions.Brute()
38+
39+
orchestratorOptions := orchestrator.Orchestrator{}
40+
orchestratorOptions.PreActionBruteforce = adfs.CheckTarget
41+
orchestratorOptions.AuthenticationFunc = adfs.Authenticate
42+
validUsers = orchestratorOptions.Bruteforce(&o365Options)
3843
},
3944
}
4045

src/cmd/brute/bruteSpray.go

+11
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,34 @@ import (
66
"net/http"
77
"net/url"
88
"os"
9+
"strings"
910

1011
"github.com/spf13/cobra"
1112
)
1213

1314
var level logger.Level
1415
var verbose bool
1516
var debug bool
17+
var output string
1618
var noBruteforce bool
1719
var sleep int
1820
var proxy func(*http.Request) (*url.URL, error)
1921

2022
var proxyString string
23+
var validUsers []string
2124

2225
// BruteSprayCmd represents the bruteSpray command
2326
var BruteSprayCmd = &cobra.Command{
2427
Use: "bruteSpray",
2528
Short: "Spray a password or bruteforce a user's password",
2629
Long: `Different services are supported. The authentication could be on an ADFS instance, an o365 or an OWA.`,
30+
PersistentPostRun: func(cmd *cobra.Command, args []string) {
31+
if output != "" {
32+
if err := os.WriteFile(output, []byte(strings.Join(validUsers, "\n")), 0666); err != nil {
33+
fmt.Println(err)
34+
}
35+
}
36+
},
2737
}
2838

2939
func init() {
@@ -32,6 +42,7 @@ func init() {
3242
cobra.OnInitialize(initProxy)
3343
BruteSprayCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose")
3444
BruteSprayCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Debug")
45+
BruteSprayCmd.PersistentFlags().StringVarP(&output, "output-file", "o", "", "The out file for valid emails")
3546
BruteSprayCmd.PersistentFlags().BoolVarP(&noBruteforce, "no-bruteforce", "n", false, "No spray when using file for username and password (user1 => password1, user2 => password2)")
3647
BruteSprayCmd.PersistentFlags().IntVarP(&sleep, "sleep", "s", 0, "Sleep in seconds before sending an authentication request")
3748
BruteSprayCmd.PersistentFlags().StringVar(&proxyString, "proxy", "", "Sleep in seconds before sending an authentication request")

src/cmd/brute/o365.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package brute
22

33
import (
44
"GoMapEnum/src/logger"
5-
"GoMapEnum/src/o365"
5+
"GoMapEnum/src/modules/o365"
6+
"GoMapEnum/src/orchestrator"
67
"errors"
78
"strings"
89

@@ -35,7 +36,15 @@ By default, if one account is being lock, the all attack will be stopped.
3536
o365Options.Proxy = proxy
3637
o365Options.NoBruteforce = noBruteforce
3738
o365Options.Sleep = sleep
38-
o365Options.Brute()
39+
40+
orchestratorOptions := orchestrator.Orchestrator{}
41+
orchestratorOptions.CustomOptionsForCheckIfValid = o365.PrepareOptions
42+
orchestratorOptions.AuthenticationFunc = o365.Authenticate
43+
orchestratorOptions.UserEnumFunc = o365.UserEnum
44+
// To check if the user is valid
45+
orchestratorOptions.CheckBeforeEnumFunc = o365.CheckTenant
46+
orchestratorOptions.AuthenticationFunc = o365.Authenticate
47+
validUsers = orchestratorOptions.Bruteforce(&o365Options)
3948
},
4049
}
4150

src/cmd/brute/owa.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package brute
22

33
import (
44
"GoMapEnum/src/logger"
5-
"GoMapEnum/src/owa"
5+
"GoMapEnum/src/modules/owa"
6+
"GoMapEnum/src/orchestrator"
67

78
"github.com/spf13/cobra"
89
)
@@ -26,17 +27,23 @@ go run main.go bruteSpray owa -u [email protected] -p Automn2021! -t mail.con
2627
owaOptions.Proxy = proxy
2728
owaOptions.NoBruteforce = noBruteforce
2829
owaOptions.Sleep = sleep
29-
owaOptions.Brute()
30+
31+
orchestratorOptions := orchestrator.Orchestrator{}
32+
orchestratorOptions.PreActionBruteforce = owa.PrepareBruteforce
33+
orchestratorOptions.CustomOptionsForCheckIfValid = owa.PrepareOptions
34+
validUsers = orchestratorOptions.Bruteforce(&owaOptions)
3035

3136
},
3237
}
3338

3439
func init() {
3540

41+
owaCmd.Flags().BoolVarP(&o365Options.CheckIfValid, "check", "c", true, "Check if the user is valid before trying password")
3642
owaCmd.Flags().StringVarP(&owaOptions.Users, "user", "u", "", "User or file containing the emails")
3743
owaCmd.Flags().StringVarP(&owaOptions.Passwords, "password", "p", "", "Password or file containing the passwords")
3844
owaCmd.Flags().StringVarP(&owaOptions.Target, "target", "t", "", "Host pointing to the OWA service")
39-
owaCmd.Flags().IntVar(&owaOptions.Thread, "thread", 2, "Number of threads ")
45+
owaCmd.Flags().IntVar(&owaOptions.Thread, "thread", 2, "Number of threads")
46+
owaCmd.Flags().BoolVar(&owaOptions.Basic, "basic", false, "Basic authentication instead of NTLM")
4047
owaCmd.MarkFlagRequired("user")
4148
owaCmd.MarkFlagRequired("password")
4249
owaCmd.MarkFlagRequired("target")

src/cmd/enum/azure.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package enum
22

33
import (
4-
"GoMapEnum/src/azure"
54
"GoMapEnum/src/logger"
5+
"GoMapEnum/src/modules/azure"
6+
"GoMapEnum/src/orchestrator"
67

78
"github.com/spf13/cobra"
89
)
@@ -23,7 +24,10 @@ var azureCmd = &cobra.Command{
2324
log.Info("Starting the module Azure")
2425
azureOptions.Log = log
2526
azureOptions.Proxy = proxy
26-
validUsers = azureOptions.UserEnum()
27+
28+
orchestratorOptions := orchestrator.Orchestrator{}
29+
orchestratorOptions.UserEnumFunc = azure.UserEnum
30+
validUsers = orchestratorOptions.UserEnum(&azureOptions)
2731
},
2832
}
2933

src/cmd/enum/o365.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package enum
22

33
import (
44
"GoMapEnum/src/logger"
5-
"GoMapEnum/src/o365"
5+
"GoMapEnum/src/modules/o365"
6+
"GoMapEnum/src/orchestrator"
67
"errors"
78
"strings"
89

@@ -31,7 +32,10 @@ var o365Cmd = &cobra.Command{
3132
log.Info("Starting the module O365")
3233
o365Options.Log = log
3334
o365Options.Proxy = proxy
34-
validUsers = o365Options.UserEnum()
35+
orchestratorOptions := orchestrator.Orchestrator{}
36+
orchestratorOptions.CheckBeforeEnumFunc = o365.CheckTenant
37+
orchestratorOptions.UserEnumFunc = o365.UserEnum
38+
validUsers = orchestratorOptions.UserEnum(&o365Options)
3539
},
3640
}
3741

0 commit comments

Comments
 (0)