Skip to content

Commit

Permalink
internally flag is now upn
Browse files Browse the repository at this point in the history
  • Loading branch information
mfdooom committed Aug 9, 2022
1 parent 14fa43a commit 45685d5
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

type FlagOptions struct {
username string
upn string
password string
ntlm string
dc string
Expand All @@ -34,7 +34,7 @@ type FlagOptions struct {
}

func options() *FlagOptions {
username := flag.String("u", "", "Username (username@domain)")
upn := flag.String("u", "", "Username (username@domain)")
password := flag.String("p", "", "Password")
ntlm := flag.String("H", "", "Use NTLM authentication")
dc := flag.String("dc", "", "IP address or FQDN of target DC")
Expand All @@ -47,7 +47,7 @@ func options() *FlagOptions {

flag.Parse()
return &FlagOptions{
username: *username,
upn: *upn,
password: *password,
ntlm: *ntlm,
dc: *dc,
Expand Down Expand Up @@ -76,23 +76,21 @@ func main() {
var proxyConn net.Conn
var err error
var domain string
var username string
var target []string

target = strings.Split(opt.username, "@")
target = strings.Split(opt.upn, "@")

// Did the user supply the username correctly <user@domain>?
if len(target) == 1 {
opt.help = true
}else {
username = target[0]
domain = target[1]
// only include username for ntlm auth
if opt.ntlm != "" {
opt.username = target[0]
}
}

// if required flags aren't set, print help
if opt.username == "" || opt.dc == "" || (opt.password == "" && opt.ntlm == "") || opt.help {
if username == "" || opt.dc == "" || (opt.password == "" && opt.ntlm == "") || opt.help {
flag.Usage()
fmt.Println("Examples:")
fmt.Println("\tWith Password: \t./ldapper -u <username@domain> -p <password> -dc <ip/FQDN> -s")
Expand Down Expand Up @@ -165,7 +163,7 @@ func main() {

// if password option set
if opt.password != "" {
err = conn.Bind(opt.username, opt.password)
err = conn.Bind(opt.upn, opt.password)
if err != nil {
log.Fatal(err)
} else {
Expand All @@ -175,7 +173,7 @@ func main() {

// if ntlm hash option set
if opt.ntlm != "" {
err = conn.NTLMBindWithHash(domain, opt.username, opt.ntlm)
err = conn.NTLMBindWithHash(domain, username, opt.ntlm)
if err != nil {
fmt.Print("test\n")
log.Fatal(err)
Expand Down

0 comments on commit 45685d5

Please sign in to comment.