@@ -19,14 +19,14 @@ import (
19
19
20
20
//globals
21
21
22
- //SessionConfig holds the configuration for this autodiscover session
22
+ // SessionConfig holds the configuration for this autodiscover session
23
23
var SessionConfig * utils.Session
24
24
var autodiscoverStep int
25
25
var secondaryEmail string //a secondary email to use, edge case seen in office365
26
26
var Transport http.Transport
27
27
var basicAuth = false
28
28
29
- //the xml for the autodiscover service
29
+ // the xml for the autodiscover service
30
30
const autodiscoverXML = `<?xml version="1.0" encoding="utf-8"?><Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
31
31
<Request><EMailAddress>{{.Email}}</EMailAddress>
32
32
<AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
@@ -43,10 +43,10 @@ func parseTemplate(tmpl string) (string, error) {
43
43
return buff .String (), nil
44
44
}
45
45
46
- //createAutodiscover generates a domain name of the format autodiscover.domain.com
47
- //and checks if a DNS entry exists for it. If it doesn't it tries DNS for just the domain name.
48
- //returns an empty string if no valid domain was found.
49
- //returns the full (expected) autodiscover URL
46
+ // createAutodiscover generates a domain name of the format autodiscover.domain.com
47
+ // and checks if a DNS entry exists for it. If it doesn't it tries DNS for just the domain name.
48
+ // returns an empty string if no valid domain was found.
49
+ // returns the full (expected) autodiscover URL
50
50
func createAutodiscover (domain string , https bool ) string {
51
51
_ , err := net .LookupHost (domain )
52
52
if err != nil {
@@ -58,7 +58,7 @@ func createAutodiscover(domain string, https bool) string {
58
58
return fmt .Sprintf ("http://%s/autodiscover/autodiscover.xml" , domain )
59
59
}
60
60
61
- //GetMapiHTTP gets the details for MAPI/HTTP
61
+ // GetMapiHTTP gets the details for MAPI/HTTP
62
62
func GetMapiHTTP (email , autoURLPtr string , resp * utils.AutodiscoverResp ) (* utils.AutodiscoverResp , string , error ) {
63
63
//var resp *utils.AutodiscoverResp
64
64
var err error
@@ -87,7 +87,7 @@ func GetMapiHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils
87
87
return resp , rawAutodiscover , nil
88
88
}
89
89
90
- //GetRPCHTTP exports the RPC details for RPC/HTTP
90
+ // GetRPCHTTP exports the RPC details for RPC/HTTP
91
91
func GetRPCHTTP (email , autoURLPtr string , resp * utils.AutodiscoverResp ) (* utils.AutodiscoverResp , string , string , string , bool , error ) {
92
92
//var resp *utils.AutodiscoverResp
93
93
var err error
@@ -190,7 +190,7 @@ func GetRPCHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils.
190
190
return resp , rawAutodiscover , RPCURL , user , ntlmAuth , nil
191
191
}
192
192
193
- //CheckCache checks to see if there is a stored copy of the autodiscover record
193
+ // CheckCache checks to see if there is a stored copy of the autodiscover record
194
194
func CheckCache (email string ) * utils.AutodiscoverResp {
195
195
//check the cache folder for a stored autodiscover record
196
196
email = strings .Replace (email , "@" , "_" , - 1 )
@@ -215,7 +215,7 @@ func CheckCache(email string) *utils.AutodiscoverResp {
215
215
return & autodiscoverResp
216
216
}
217
217
218
- //CreateCache function stores the raw autodiscover record to file
218
+ // CreateCache function stores the raw autodiscover record to file
219
219
func CreateCache (email , autodiscover string ) {
220
220
221
221
if autodiscover == "" { //no autodiscover record passed in, don't try write
@@ -240,7 +240,7 @@ func CreateCache(email, autodiscover string) {
240
240
}
241
241
}
242
242
243
- //Autodiscover function to retrieve mailbox details using the autodiscover mechanism from MS Exchange
243
+ // Autodiscover function to retrieve mailbox details using the autodiscover mechanism from MS Exchange
244
244
func Autodiscover (domain string ) (* utils.AutodiscoverResp , string , error ) {
245
245
if SessionConfig .Proxy == "" {
246
246
Transport = http.Transport {
@@ -258,8 +258,8 @@ func Autodiscover(domain string) (*utils.AutodiscoverResp, string, error) {
258
258
return autodiscover (domain , false )
259
259
}
260
260
261
- //MAPIDiscover function to do the autodiscover request but specify the MAPI header
262
- //indicating that the MAPI end-points should be returned
261
+ // MAPIDiscover function to do the autodiscover request but specify the MAPI header
262
+ // indicating that the MAPI end-points should be returned
263
263
func MAPIDiscover (domain string ) (* utils.AutodiscoverResp , string , error ) {
264
264
//set transport
265
265
if SessionConfig .Proxy == "" {
@@ -344,7 +344,7 @@ func autodiscover(domain string, mapi bool) (*utils.AutodiscoverResp, string, er
344
344
345
345
if SessionConfig .Basic == true {
346
346
if SessionConfig .Domain != "" {
347
- req .SetBasicAuth (SessionConfig .Domain + "\\ " + SessionConfig .User , SessionConfig .Pass )
347
+ req .SetBasicAuth (SessionConfig .Domain + "\\ " + SessionConfig .User , SessionConfig .Pass )
348
348
} else {
349
349
req .SetBasicAuth (SessionConfig .Email , SessionConfig .Pass )
350
350
}
@@ -491,17 +491,17 @@ func redirectAutodiscover(redirdom string) (string, error) {
491
491
return resp .Header .Get ("Location" ), nil
492
492
}
493
493
494
- //InsecureRedirectsO365 allows forwarding the Authorization header even when we shouldn't
494
+ // InsecureRedirectsO365 allows forwarding the Authorization header even when we shouldn't
495
495
type InsecureRedirectsO365 struct {
496
496
Transport http.RoundTripper
497
497
User string
498
498
Pass string
499
499
Insecure bool
500
500
}
501
501
502
- //RoundTrip custom redirector that allows us to forward the auth header, even when the domain changes.
503
- //This is needed as some office365 domains will redirect from autodiscover.domain.com to autodiscover.outlook.com
504
- //and Go does not forward Sensitive headers such as Authorization (https://golang.org/src/net/http/client.go#41)
502
+ // RoundTrip custom redirector that allows us to forward the auth header, even when the domain changes.
503
+ // This is needed as some office365 domains will redirect from autodiscover.domain.com to autodiscover.outlook.com
504
+ // and Go does not forward Sensitive headers such as Authorization (https://golang.org/src/net/http/client.go#41)
505
505
func (l InsecureRedirectsO365 ) RoundTrip (req * http.Request ) (resp * http.Response , err error ) {
506
506
t := l .Transport
507
507
0 commit comments