Skip to content

Commit 040113a

Browse files
committed
Fix a bug when the tenant was not valid.
Lower the number of request by remembering which domain are valid or note
1 parent b689510 commit 040113a

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/o365/userEnum.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func (options *Options) UserEnum() []string {
1313
emailList := strings.Split(options.Users, "\n")
1414
var wg sync.WaitGroup
1515
var validusers []string
16+
domainValidated := make(map[string]bool)
1617
queue := make(chan string)
1718

1819
for i := 0; i < options.Thread; i++ {
@@ -22,11 +23,26 @@ func (options *Options) UserEnum() []string {
2223
defer wg.Done()
2324
for email := range queue {
2425
domain := strings.Split(email, "@")[1]
25-
if !options.validTenant(domain) {
26-
options.Log.Error("Tenant " + domain + " is not valid")
27-
return
26+
// If we didn't already checked the domain
27+
mux.Lock()
28+
if domainValid, ok := domainValidated[domain]; !ok {
29+
if !options.validTenant(domain) {
30+
options.Log.Error("Tenant " + domain + " is not valid")
31+
domainValidated[domain] = false
32+
mux.Unlock()
33+
continue
34+
}
35+
options.Log.Info("Tenant " + domain + " is valid")
36+
domainValidated[domain] = true
37+
} else {
38+
// If the domain was not valid, skip the email
39+
if !domainValid {
40+
options.Log.Debug("Tenant " + domain + " already checked and was not valid")
41+
mux.Unlock()
42+
continue
43+
}
2844
}
29-
options.Log.Verbose("Tenant " + domain + " is valid")
45+
mux.Unlock()
3046

3147
switch options.Mode {
3248
case "office":

src/utils/utils.go

+9
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,12 @@ func GetKeysMap(m map[string]string) []string {
161161
}
162162
return keys
163163
}
164+
165+
func StringInSlice(item string, slice []string) bool {
166+
for _, elementOfSlice := range slice {
167+
if item == elementOfSlice {
168+
return true
169+
}
170+
}
171+
return false
172+
}

0 commit comments

Comments
 (0)