Skip to content

Commit 25ba18b

Browse files
committed
If target is not specified use the server in MX record
1 parent 993fa7f commit 25ba18b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/cmd/enum/smtp.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ func init() {
3838
smtpCmd.Flags().StringVarP(&smtpOptions.Domain, "domain", "d", "", "Targeted domain ")
3939
smtpCmd.Flags().StringVarP(&smtpOptions.Mode, "mode", "m", "", "RCPT, VRFY, EXPN (default: RCPT)")
4040
smtpCmd.Flags().StringVarP(&smtpOptions.Users, "user", "u", "", "Username or file containing the usernames")
41-
smtpCmd.Flags().StringVarP(&smtpOptions.Target, "target", "t", "", "Host pointing to the OWA service")
41+
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")
4343
smtpCmd.MarkFlagRequired("user")
44-
smtpCmd.MarkFlagRequired("target")
4544
smtpCmd.MarkFlagRequired("domain")
4645
}

src/modules/smtp/userEnum.go

+10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package smtp
33
import (
44
"GoMapEnum/src/utils"
55
"fmt"
6+
"net"
67
"strconv"
78
"strings"
89
"time"
@@ -13,6 +14,15 @@ import (
1314
func PrepareSMTPConnections(optionsInterface *interface{}) {
1415
options := (*optionsInterface).(*Options)
1516
options.connectionsPool = make(chan *smtp.Client, options.Thread)
17+
18+
if options.Target == "" {
19+
mxrecords, err := net.LookupMX(options.Domain)
20+
if err != nil {
21+
options.Log.Fatal("Not able to retrieve the MX for the domain " + options.Domain)
22+
}
23+
options.Target = mxrecords[0].Host
24+
}
25+
1626
var nbConnectionsRequired int
1727
nbConnectionsRequired = options.Thread
1828
if len(options.UsernameList) < options.Thread {

0 commit comments

Comments
 (0)