Skip to content

Commit

Permalink
Allow unauthenticated binds
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Apr 6, 2022
1 parent 86a3666 commit 7112c1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion modules/integrations/activedirectory/collect/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
port = Command.Flags().Int("port", 636, "LDAP port to connect to (389 or 636 typical)")
domain = Command.Flags().String("domain", "", "domain suffix to analyze (contoso.local, auto-detected if not supplied)")
user = Command.Flags().String("username", "", "username to connect with (someuser@contoso.local)")
pass = Command.Flags().String("password", "", "password to connect with ex. --password hunter42")
pass = Command.Flags().String("password", "", "password to connect with ex. --password hunter42 (use ! for blank password)")

tlsmodeString = Command.Flags().String("tlsmode", "TLS", "Transport mode (TLS, StartTLS, NoTLS)")

Expand Down Expand Up @@ -185,6 +185,11 @@ func PreRun(cmd *cobra.Command, args []string) error {
*pass = string(passwd)
}
}

if *pass == "!" {
// A single ! indicates we want to use a blank password, so lets change it to that
*pass = ""
}
}

if authmode == 3 {
Expand Down
9 changes: 7 additions & 2 deletions modules/integrations/activedirectory/collect/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ func (ad *AD) Connect(authmode byte) error {
log.Debug().Msgf("Doing unauthenticated bind with user %s", ad.User)
err = ad.conn.UnauthenticatedBind(ad.User)
case 1:
log.Debug().Msgf("Doing simple bind with user %s", ad.User)
err = ad.conn.Bind(ad.User, ad.Password)
if ad.Password == "" {
log.Debug().Msgf("Doing simple unauthenticated bind with user %s", ad.User)
err = ad.conn.UnauthenticatedBind(ad.User)
} else {
log.Debug().Msgf("Doing simple bind with user %s", ad.User)
err = ad.conn.Bind(ad.User, ad.Password)
}
case 2:
log.Debug().Msgf("Doing MD5 auth with user %s from domain %s", ad.User, ad.AuthDomain)
err = ad.conn.MD5Bind(ad.AuthDomain, ad.User, ad.Password)
Expand Down

0 comments on commit 7112c1e

Please sign in to comment.