Skip to content

Commit

Permalink
If target is not specified use the server in MX record
Browse files Browse the repository at this point in the history
  • Loading branch information
nodauf committed Jan 26, 2022
1 parent 993fa7f commit 25ba18b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/cmd/enum/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ func init() {
smtpCmd.Flags().StringVarP(&smtpOptions.Domain, "domain", "d", "", "Targeted domain ")
smtpCmd.Flags().StringVarP(&smtpOptions.Mode, "mode", "m", "", "RCPT, VRFY, EXPN (default: RCPT)")
smtpCmd.Flags().StringVarP(&smtpOptions.Users, "user", "u", "", "Username or file containing the usernames")
smtpCmd.Flags().StringVarP(&smtpOptions.Target, "target", "t", "", "Host pointing to the OWA service")
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.")
smtpCmd.Flags().IntVar(&smtpOptions.Thread, "thread", 2, "Number of threads")
smtpCmd.MarkFlagRequired("user")
smtpCmd.MarkFlagRequired("target")
smtpCmd.MarkFlagRequired("domain")
}
10 changes: 10 additions & 0 deletions src/modules/smtp/userEnum.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package smtp
import (
"GoMapEnum/src/utils"
"fmt"
"net"
"strconv"
"strings"
"time"
Expand All @@ -13,6 +14,15 @@ import (
func PrepareSMTPConnections(optionsInterface *interface{}) {
options := (*optionsInterface).(*Options)
options.connectionsPool = make(chan *smtp.Client, options.Thread)

if options.Target == "" {
mxrecords, err := net.LookupMX(options.Domain)
if err != nil {
options.Log.Fatal("Not able to retrieve the MX for the domain " + options.Domain)
}
options.Target = mxrecords[0].Host
}

var nbConnectionsRequired int
nbConnectionsRequired = options.Thread
if len(options.UsernameList) < options.Thread {
Expand Down

0 comments on commit 25ba18b

Please sign in to comment.