Skip to content

Commit

Permalink
Fix issue on teams enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
nodauf committed Jan 26, 2022
1 parent 4e58daa commit de70448
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/cmd/enum/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ If these emails exist the presence of the user is retrieved as well as the devic

func init() {

teamsCmd.Flags().StringVarP(&teamsOptions.Email, "email", "e", "", "Email or file containing the email address")
teamsCmd.Flags().StringVarP(&teamsOptions.Token, "token", "t", "", "Bearer token (only the base64 part: eyJ0...)")
teamsCmd.Flags().StringVarP(&teamsOptions.Users, "user", "u", "", "Email or file containing the email address")
teamsCmd.Flags().StringVarP(&teamsOptions.Token, "token", "t", "", "Bearer token (only the base64 part: eyJ0...). This token can be found on requests made to teams.microsoft.com/api/")
teamsCmd.Flags().IntVar(&teamsOptions.Thread, "thread", 1, "Number of threads")

teamsCmd.MarkFlagRequired("token")
teamsCmd.MarkFlagRequired("email")
teamsCmd.MarkFlagRequired("user")
}
7 changes: 1 addition & 6 deletions src/modules/teams/struct.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package teams

import (
"GoMapEnum/src/logger"
"GoMapEnum/src/utils"
)

var log *logger.Logger

// Options for teams module
type Options struct {
Email string
Token string
Thread int
Token string
utils.BaseOptions
}

Expand Down
22 changes: 11 additions & 11 deletions src/modules/teams/userEnum.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func UserEnum(optionsInterface *interface{}, username string) bool {
}
resp, err := client.Do(req)
if err != nil {
log.Error("Error on response.\n[ERRO] - " + err.Error())
options.Log.Error("Error on response.\n[ERRO] - " + err.Error())
}

body, _ := ioutil.ReadAll(resp.Body)
Expand All @@ -50,30 +50,30 @@ func UserEnum(optionsInterface *interface{}, username string) bool {
json.Unmarshal([]byte(body), &jsonInterface)
json.Unmarshal([]byte(body), &usefulInformation)

log.Debug("Status code: " + strconv.Itoa(resp.StatusCode))
options.Log.Debug("Status code: " + strconv.Itoa(resp.StatusCode))

bytes, _ := json.MarshalIndent(jsonInterface, "", " ")
log.Debug("Response: " + string(bytes))
options.Log.Debug("Response: " + string(bytes))

switch resp.StatusCode {
case 200:
if reflect.ValueOf(jsonInterface).Len() > 0 {
presence, device, outOfOfficeNote := options.getPresence(usefulInformation[0].Mri, options.Token, log)
log.Success(username + " - " + usefulInformation[0].DisplayName + " - " + presence + " - " + device + " - " + outOfOfficeNote)
presence, device, outOfOfficeNote := options.getPresence(usefulInformation[0].Mri, options.Token, options.Log)
options.Log.Success(username + " - " + usefulInformation[0].DisplayName + " - " + presence + " - " + device + " - " + outOfOfficeNote)
valid = true
} else {
log.Fail(username)
options.Log.Fail(username)
}
// If the status code is 403 it means the user exists but the organization did not enable connection from outside
case 403:
log.Success(username)
options.Log.Success(username)
valid = true
case 401:
log.Fail(username)
log.Info("The token may be invalid or expired. The status code returned by the server is 401")
options.Log.Fail(username)
options.Log.Info("The token may be invalid or expired. The status code returned by the server is 401")
default:
log.Fail(username)
log.Error("Something went wrong. The status code returned by the server is " + strconv.Itoa(resp.StatusCode))
options.Log.Fail(username)
options.Log.Error("Something went wrong. The status code returned by the server is " + strconv.Itoa(resp.StatusCode))
}
return valid
}
4 changes: 2 additions & 2 deletions src/modules/teams/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (options *Options) getPresence(mri, bearer string, log *logger.Logger) (str
}
resp, err := client.Do(req)
if err != nil {
log.Error("Error on response.\n[ERRO] - " + err.Error())
options.Log.Error("Error on response.\n[ERRO] - " + err.Error())
return "", "", ""
}

Expand All @@ -52,7 +52,7 @@ func (options *Options) getPresence(mri, bearer string, log *logger.Logger) (str

json.Unmarshal([]byte(body), &status)
bytes, _ := json.MarshalIndent(status, "", " ")
log.Debug("Response: " + string(bytes))
options.Log.Debug("Response: " + string(bytes))

if len(status) > 0 {
return status[0].Presence.Availability, status[0].Presence.DeviceType, status[0].Presence.CalendarData.OutOfOfficeNote.Message
Expand Down

0 comments on commit de70448

Please sign in to comment.