Skip to content

Commit de70448

Browse files
committed
Fix issue on teams enumeration
1 parent 4e58daa commit de70448

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

src/cmd/enum/teams.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ If these emails exist the presence of the user is retrieved as well as the devic
3434

3535
func init() {
3636

37-
teamsCmd.Flags().StringVarP(&teamsOptions.Email, "email", "e", "", "Email or file containing the email address")
38-
teamsCmd.Flags().StringVarP(&teamsOptions.Token, "token", "t", "", "Bearer token (only the base64 part: eyJ0...)")
37+
teamsCmd.Flags().StringVarP(&teamsOptions.Users, "user", "u", "", "Email or file containing the email address")
38+
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/")
3939
teamsCmd.Flags().IntVar(&teamsOptions.Thread, "thread", 1, "Number of threads")
4040

4141
teamsCmd.MarkFlagRequired("token")
42-
teamsCmd.MarkFlagRequired("email")
42+
teamsCmd.MarkFlagRequired("user")
4343
}

src/modules/teams/struct.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
package teams
22

33
import (
4-
"GoMapEnum/src/logger"
54
"GoMapEnum/src/utils"
65
)
76

8-
var log *logger.Logger
9-
107
// Options for teams module
118
type Options struct {
12-
Email string
13-
Token string
14-
Thread int
9+
Token string
1510
utils.BaseOptions
1611
}
1712

src/modules/teams/userEnum.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func UserEnum(optionsInterface *interface{}, username string) bool {
3636
}
3737
resp, err := client.Do(req)
3838
if err != nil {
39-
log.Error("Error on response.\n[ERRO] - " + err.Error())
39+
options.Log.Error("Error on response.\n[ERRO] - " + err.Error())
4040
}
4141

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

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

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

5858
switch resp.StatusCode {
5959
case 200:
6060
if reflect.ValueOf(jsonInterface).Len() > 0 {
61-
presence, device, outOfOfficeNote := options.getPresence(usefulInformation[0].Mri, options.Token, log)
62-
log.Success(username + " - " + usefulInformation[0].DisplayName + " - " + presence + " - " + device + " - " + outOfOfficeNote)
61+
presence, device, outOfOfficeNote := options.getPresence(usefulInformation[0].Mri, options.Token, options.Log)
62+
options.Log.Success(username + " - " + usefulInformation[0].DisplayName + " - " + presence + " - " + device + " - " + outOfOfficeNote)
6363
valid = true
6464
} else {
65-
log.Fail(username)
65+
options.Log.Fail(username)
6666
}
6767
// If the status code is 403 it means the user exists but the organization did not enable connection from outside
6868
case 403:
69-
log.Success(username)
69+
options.Log.Success(username)
7070
valid = true
7171
case 401:
72-
log.Fail(username)
73-
log.Info("The token may be invalid or expired. The status code returned by the server is 401")
72+
options.Log.Fail(username)
73+
options.Log.Info("The token may be invalid or expired. The status code returned by the server is 401")
7474
default:
75-
log.Fail(username)
76-
log.Error("Something went wrong. The status code returned by the server is " + strconv.Itoa(resp.StatusCode))
75+
options.Log.Fail(username)
76+
options.Log.Error("Something went wrong. The status code returned by the server is " + strconv.Itoa(resp.StatusCode))
7777
}
7878
return valid
7979
}

src/modules/teams/utils.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (options *Options) getPresence(mri, bearer string, log *logger.Logger) (str
2828
}
2929
resp, err := client.Do(req)
3030
if err != nil {
31-
log.Error("Error on response.\n[ERRO] - " + err.Error())
31+
options.Log.Error("Error on response.\n[ERRO] - " + err.Error())
3232
return "", "", ""
3333
}
3434

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

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

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

0 commit comments

Comments
 (0)