Skip to content

Commit 0181ef6

Browse files
committed
Use all methods if none is specified
1 parent dc75242 commit 0181ef6

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

src/cmd/enum/smtp.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var smtpCmd = &cobra.Command{
3636
func init() {
3737

3838
smtpCmd.Flags().StringVarP(&smtpOptions.Domain, "domain", "d", "", "Targeted domain ")
39-
smtpCmd.Flags().StringVarP(&smtpOptions.Mode, "mode", "m", "", "RCPT, VRFY, EXPN (default: RCPT)")
39+
smtpCmd.Flags().StringVarP(&smtpOptions.Mode, "mode", "m", "", "RCPT, VRFY, EXPN (default: all)")
4040
smtpCmd.Flags().StringVarP(&smtpOptions.Users, "user", "u", "", "Username or file containing the usernames")
4141
smtpCmd.Flags().StringVarP(&smtpOptions.Target, "target", "t", "", "Host pointing to the SMTP service. If not specified, the first SMTP server in the MX record will be targeted.")
4242
smtpCmd.Flags().IntVar(&smtpOptions.Thread, "thread", 2, "Number of threads")

src/modules/smtp/struct.go

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Options struct {
1313
Mode string
1414
utils.BaseOptions
1515

16+
all bool
1617
connectionsPool chan *smtp.Client
1718
}
1819

src/modules/smtp/userEnum.go

+32-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"GoMapEnum/src/utils"
55
"fmt"
66
"net"
7+
"reflect"
78
"strconv"
89
"strings"
910
"time"
@@ -26,7 +27,7 @@ func PrepareSMTPConnections(optionsInterface *interface{}) {
2627

2728
var nbConnectionsRequired int
2829
nbConnectionsRequired = options.Thread
29-
if len(options.UsernameList) < options.Thread {
30+
if (options.Mode != "" && len(options.UsernameList) < options.Thread) || (options.Mode == "" && len(options.UsernameList)*3 < options.Thread) {
3031
nbConnectionsRequired = len(options.UsernameList)
3132
}
3233
options.Log.Debug("Preparing a pool of " + strconv.Itoa(nbConnectionsRequired) + " connections")
@@ -53,7 +54,7 @@ func UserEnum(optionsInterface *interface{}, username string) bool {
5354
valid := false
5455
smtpConnection := <-options.connectionsPool
5556
switch strings.ToLower(options.Mode) {
56-
case "rcpt", "":
57+
case "rcpt":
5758
err := smtpConnection.Rcpt(username)
5859
if err == nil {
5960
options.Log.Success(username)
@@ -81,14 +82,39 @@ func UserEnum(optionsInterface *interface{}, username string) bool {
8182
options.Log.Debug(username + " => " + err.Error())
8283
options.Log.Fail(username)
8384
// If the command is not implemented no need to pursue
84-
if code == "502" {
85+
if code == "502" && !options.all {
8586
CloseSMTPConnections(optionsInterface)
86-
options.Log.Fatal("The command is not implemented. No need to pursue using this method.")
87+
options.Log.Fatal("The command EXPN is not implemented. No need to pursue using this method.")
8788
}
88-
fmt.Println(code)
8989
}
90+
case "":
91+
options.connectionsPool <- smtpConnection
92+
// Execute the 3 enumeration methods
93+
options.all = true
94+
// RCPT request
95+
options.Log.Debug("No enumeration method specify. Executing enumeration with RCPT, VRFY and EXPN")
96+
options.Log.Debug("Enumerate with RCPT")
97+
options.Mode = "rcpt"
98+
newOptionsInterface := reflect.ValueOf(options).Interface()
99+
valid = UserEnum(&newOptionsInterface, username)
100+
if valid {
101+
return true
102+
}
103+
// VRFY
104+
options.Log.Debug("Enumerate with VRFY")
105+
options.Mode = "vrfy"
106+
newOptionsInterface = reflect.ValueOf(options).Interface()
107+
valid = UserEnum(&newOptionsInterface, username)
108+
if valid {
109+
return true
110+
}
111+
// EXPN
112+
options.Log.Debug("Enumerate with EXPN")
113+
options.Mode = "expn"
114+
newOptionsInterface = reflect.ValueOf(options).Interface()
115+
valid = UserEnum(&newOptionsInterface, username)
116+
return valid
90117
default:
91-
CloseSMTPConnections(optionsInterface)
92118
options.Log.Fatal("Unrecognised mode: " + options.Mode + ". Only RCPT, VRFY and EXPN are supported.")
93119
}
94120

0 commit comments

Comments
 (0)