4
4
"GoMapEnum/src/utils"
5
5
"fmt"
6
6
"net"
7
+ "reflect"
7
8
"strconv"
8
9
"strings"
9
10
"time"
@@ -26,7 +27,7 @@ func PrepareSMTPConnections(optionsInterface *interface{}) {
26
27
27
28
var nbConnectionsRequired int
28
29
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 ) {
30
31
nbConnectionsRequired = len (options .UsernameList )
31
32
}
32
33
options .Log .Debug ("Preparing a pool of " + strconv .Itoa (nbConnectionsRequired ) + " connections" )
@@ -53,7 +54,7 @@ func UserEnum(optionsInterface *interface{}, username string) bool {
53
54
valid := false
54
55
smtpConnection := <- options .connectionsPool
55
56
switch strings .ToLower (options .Mode ) {
56
- case "rcpt" , "" :
57
+ case "rcpt" :
57
58
err := smtpConnection .Rcpt (username )
58
59
if err == nil {
59
60
options .Log .Success (username )
@@ -81,14 +82,39 @@ func UserEnum(optionsInterface *interface{}, username string) bool {
81
82
options .Log .Debug (username + " => " + err .Error ())
82
83
options .Log .Fail (username )
83
84
// If the command is not implemented no need to pursue
84
- if code == "502" {
85
+ if code == "502" && ! options . all {
85
86
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." )
87
88
}
88
- fmt .Println (code )
89
89
}
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
90
117
default :
91
- CloseSMTPConnections (optionsInterface )
92
118
options .Log .Fatal ("Unrecognised mode: " + options .Mode + ". Only RCPT, VRFY and EXPN are supported." )
93
119
}
94
120
0 commit comments