Skip to content

Commit e3ff067

Browse files
committed
misc: go fmt the source tree
1 parent 1e5ee2d commit e3ff067

18 files changed

+639
-637
lines changed

autodiscover/autodiscover.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ import (
1919

2020
//globals
2121

22-
//SessionConfig holds the configuration for this autodiscover session
22+
// SessionConfig holds the configuration for this autodiscover session
2323
var SessionConfig *utils.Session
2424
var autodiscoverStep int
2525
var secondaryEmail string //a secondary email to use, edge case seen in office365
2626
var Transport http.Transport
2727
var basicAuth = false
2828

29-
//the xml for the autodiscover service
29+
// the xml for the autodiscover service
3030
const autodiscoverXML = `<?xml version="1.0" encoding="utf-8"?><Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
3131
<Request><EMailAddress>{{.Email}}</EMailAddress>
3232
<AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
@@ -43,10 +43,10 @@ func parseTemplate(tmpl string) (string, error) {
4343
return buff.String(), nil
4444
}
4545

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
5050
func createAutodiscover(domain string, https bool) string {
5151
_, err := net.LookupHost(domain)
5252
if err != nil {
@@ -58,7 +58,7 @@ func createAutodiscover(domain string, https bool) string {
5858
return fmt.Sprintf("http://%s/autodiscover/autodiscover.xml", domain)
5959
}
6060

61-
//GetMapiHTTP gets the details for MAPI/HTTP
61+
// GetMapiHTTP gets the details for MAPI/HTTP
6262
func GetMapiHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils.AutodiscoverResp, string, error) {
6363
//var resp *utils.AutodiscoverResp
6464
var err error
@@ -87,7 +87,7 @@ func GetMapiHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils
8787
return resp, rawAutodiscover, nil
8888
}
8989

90-
//GetRPCHTTP exports the RPC details for RPC/HTTP
90+
// GetRPCHTTP exports the RPC details for RPC/HTTP
9191
func GetRPCHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils.AutodiscoverResp, string, string, string, bool, error) {
9292
//var resp *utils.AutodiscoverResp
9393
var err error
@@ -190,7 +190,7 @@ func GetRPCHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils.
190190
return resp, rawAutodiscover, RPCURL, user, ntlmAuth, nil
191191
}
192192

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
194194
func CheckCache(email string) *utils.AutodiscoverResp {
195195
//check the cache folder for a stored autodiscover record
196196
email = strings.Replace(email, "@", "_", -1)
@@ -215,7 +215,7 @@ func CheckCache(email string) *utils.AutodiscoverResp {
215215
return &autodiscoverResp
216216
}
217217

218-
//CreateCache function stores the raw autodiscover record to file
218+
// CreateCache function stores the raw autodiscover record to file
219219
func CreateCache(email, autodiscover string) {
220220

221221
if autodiscover == "" { //no autodiscover record passed in, don't try write
@@ -240,7 +240,7 @@ func CreateCache(email, autodiscover string) {
240240
}
241241
}
242242

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
244244
func Autodiscover(domain string) (*utils.AutodiscoverResp, string, error) {
245245
if SessionConfig.Proxy == "" {
246246
Transport = http.Transport{
@@ -258,8 +258,8 @@ func Autodiscover(domain string) (*utils.AutodiscoverResp, string, error) {
258258
return autodiscover(domain, false)
259259
}
260260

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
263263
func MAPIDiscover(domain string) (*utils.AutodiscoverResp, string, error) {
264264
//set transport
265265
if SessionConfig.Proxy == "" {
@@ -344,7 +344,7 @@ func autodiscover(domain string, mapi bool) (*utils.AutodiscoverResp, string, er
344344

345345
if SessionConfig.Basic == true {
346346
if SessionConfig.Domain != "" {
347-
req.SetBasicAuth(SessionConfig.Domain + "\\" + SessionConfig.User, SessionConfig.Pass)
347+
req.SetBasicAuth(SessionConfig.Domain+"\\"+SessionConfig.User, SessionConfig.Pass)
348348
} else {
349349
req.SetBasicAuth(SessionConfig.Email, SessionConfig.Pass)
350350
}
@@ -491,17 +491,17 @@ func redirectAutodiscover(redirdom string) (string, error) {
491491
return resp.Header.Get("Location"), nil
492492
}
493493

494-
//InsecureRedirectsO365 allows forwarding the Authorization header even when we shouldn't
494+
// InsecureRedirectsO365 allows forwarding the Authorization header even when we shouldn't
495495
type InsecureRedirectsO365 struct {
496496
Transport http.RoundTripper
497497
User string
498498
Pass string
499499
Insecure bool
500500
}
501501

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)
505505
func (l InsecureRedirectsO365) RoundTrip(req *http.Request) (resp *http.Response, err error) {
506506
t := l.Transport
507507

autodiscover/brute.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import (
66
"io/ioutil"
77
"net/http"
88
"net/http/cookiejar"
9+
"net/url"
910
"regexp"
1011
"strings"
1112
"time"
12-
"net/url"
1313

1414
"github.com/sensepost/ruler/http-ntlm"
1515
"github.com/sensepost/ruler/utils"
1616
)
1717

18-
//Result struct holds the result of a bruteforce attempt
18+
// Result struct holds the result of a bruteforce attempt
1919
type Result struct {
2020
Username string
2121
Password string
@@ -114,7 +114,7 @@ func autodiscoverDomain(domain string) string {
114114
return ""
115115
}
116116

117-
//Init function to setup the brute-force session
117+
// Init function to setup the brute-force session
118118
func Init(domain, usersFile, passwordsFile, userpassFile, pURL, u, n string, b, i, s, v bool, c, d, t int) error {
119119
stopSuccess = s
120120
insecure = i
@@ -133,7 +133,6 @@ func Init(domain, usersFile, passwordsFile, userpassFile, pURL, u, n string, b,
133133
return fmt.Errorf("No autodiscover end-point found")
134134
}
135135

136-
137136
if autodiscoverURL == "https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml" {
138137
basic = true
139138
}
@@ -157,16 +156,16 @@ func Init(domain, usersFile, passwordsFile, userpassFile, pURL, u, n string, b,
157156
return nil
158157
}
159158

160-
//BruteForce function takes a domain/URL, file path to users and filepath to passwords whether to use BASIC auth and to trust insecure SSL
161-
//And whether to stop on success
159+
// BruteForce function takes a domain/URL, file path to users and filepath to passwords whether to use BASIC auth and to trust insecure SSL
160+
// And whether to stop on success
162161
func BruteForce() {
163162

164163
attempts := 0
165164
stp := false
166165

167166
for index, p := range passwords {
168-
if index % 10 == 0 {
169-
utils.Info.Printf("%d of %d passwords checked",index,len(passwords))
167+
if index%10 == 0 {
168+
utils.Info.Printf("%d of %d passwords checked", index, len(passwords))
170169
}
171170
if p != "" {
172171
attempts++
@@ -251,15 +250,15 @@ func BruteForce() {
251250
}
252251
}
253252

254-
//UserPassBruteForce function does a bruteforce using a supplied user:pass file
253+
// UserPassBruteForce function does a bruteforce using a supplied user:pass file
255254
func UserPassBruteForce() {
256255

257256
count := 0
258257
sem := make(chan bool, concurrency)
259258
stp := false
260259
for index, up := range userpass {
261-
if index % 10 == 0 {
262-
utils.Info.Printf("%d of %d checked",index,len(userpass))
260+
if index%10 == 0 {
261+
utils.Info.Printf("%d of %d checked", index, len(userpass))
263262
}
264263
count++
265264
if up == "" {
@@ -339,7 +338,7 @@ func connect(autodiscoverURL, user, password string, basic, insecure bool) Resul
339338
return result
340339
}
341340
tr = &http.Transport{Proxy: http.ProxyURL(proxy),
342-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
341+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
343342
DisableKeepAlives: true,
344343
}
345344
}

forms/rulerforms.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/sensepost/ruler/utils"
1212
)
1313

14-
//CreateFormAttachmentPointer creates the first attachment that holds info about the new form
14+
// CreateFormAttachmentPointer creates the first attachment that holds info about the new form
1515
func CreateFormAttachmentPointer(folderid, messageid []byte) error {
1616
utils.Info.Println("Create Form Pointer Attachment")
1717
data := []byte("FormStg=%d\\FS525C.tmp\nMsgCls=IPM.Note.grr\nBaseMsgCls=IPM.Note\n") //don't think this is strictly necessary
@@ -31,17 +31,17 @@ func CreateFormAttachmentPointer(folderid, messageid []byte) error {
3131
return err
3232
}
3333

34-
//CreateFormAttachmentTemplate creates the template attachment holding the actual command to execute
34+
// CreateFormAttachmentTemplate creates the template attachment holding the actual command to execute
3535
func CreateFormAttachmentTemplate(folderid, messageid []byte, pstr string) error {
3636
return CreateFormAttachmentWithTemplate(folderid, messageid, pstr, "templates/formtemplate.bin")
3737
}
3838

39-
//CreateFormAttachmentForDeleteTemplate creates the template attachment holding the actual command to execute
39+
// CreateFormAttachmentForDeleteTemplate creates the template attachment holding the actual command to execute
4040
func CreateFormAttachmentForDeleteTemplate(folderid, messageid []byte, pstr string) error {
4141
return CreateFormAttachmentWithTemplate(folderid, messageid, pstr, "templates/formdeletetemplate.bin")
4242
}
4343

44-
//CreateFormAttachmentWithTemplate creates a form with a specific template
44+
// CreateFormAttachmentWithTemplate creates a form with a specific template
4545
func CreateFormAttachmentWithTemplate(folderid, messageid []byte, pstr, templatepath string) error {
4646
utils.Info.Println("Create Form Template Attachment")
4747

@@ -89,7 +89,7 @@ func CreateFormAttachmentWithTemplate(folderid, messageid []byte, pstr, template
8989
return err
9090
}
9191

92-
//CreateFormMessage creates the associate message that holds the form data
92+
// CreateFormMessage creates the associate message that holds the form data
9393
func CreateFormMessage(suffix, assocRule string) ([]byte, error) {
9494
folderid := mapi.AuthSession.Folderids[mapi.INBOX]
9595
propertyTagx := make([]mapi.TaggedPropertyValue, 10)
@@ -158,8 +158,8 @@ func CreateFormMessage(suffix, assocRule string) ([]byte, error) {
158158
return msg.MessageID, err
159159
}
160160

161-
//CreateFormTriggerMessage creates a valid message to trigger RCE through an existing form
162-
//requires a valid suffix to be supplied
161+
// CreateFormTriggerMessage creates a valid message to trigger RCE through an existing form
162+
// requires a valid suffix to be supplied
163163
func CreateFormTriggerMessage(suffix, subject, body string) ([]byte, error) {
164164
folderid := mapi.AuthSession.Folderids[mapi.INBOX]
165165
propertyTagx := make([]mapi.TaggedPropertyValue, 8)
@@ -186,7 +186,7 @@ func CreateFormTriggerMessage(suffix, subject, body string) ([]byte, error) {
186186
return msg.MessageID, nil
187187
}
188188

189-
//DeleteForm is used to delete a specific form stored in an associated table
189+
// DeleteForm is used to delete a specific form stored in an associated table
190190
func DeleteForm(suffix string, folderid []byte) ([]byte, error) {
191191

192192
columns := make([]mapi.PropertyTag, 3)
@@ -251,7 +251,7 @@ func DeleteForm(suffix string, folderid []byte) ([]byte, error) {
251251
return nil, nil
252252
}
253253

254-
//DisplayForms is used to display all forms in the specified folder
254+
// DisplayForms is used to display all forms in the specified folder
255255
func DisplayForms(folderid []byte) error {
256256

257257
columns := make([]mapi.PropertyTag, 2)
@@ -284,8 +284,8 @@ func DisplayForms(folderid []byte) error {
284284
return nil
285285
}
286286

287-
//CheckForm verfies that a form does not already exist.
288-
//having multiple forms with same suffix causes issues in outlook..
287+
// CheckForm verfies that a form does not already exist.
288+
// having multiple forms with same suffix causes issues in outlook..
289289
func CheckForm(folderid []byte, suffix string) error {
290290
columns := make([]mapi.PropertyTag, 2)
291291
columns[0] = mapi.PidTagOfflineAddressBookName

http-ntlm/ntlmtransport.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (t NtlmTransport) RoundTrip(req *http.Request) (res *http.Response, err err
5454
b, _ := session.GenerateNegotiateMessage()
5555
// first send NTLM Negotiate header
5656
r, _ := http.NewRequest("GET", req.URL.String(), strings.NewReader(""))
57-
r.Header.Add("Authorization", "NTLM " + utils.EncBase64(b.Bytes()))
57+
r.Header.Add("Authorization", "NTLM "+utils.EncBase64(b.Bytes()))
5858
r.Header.Add("User-Agent", req.UserAgent())
5959

6060
if t.Proxy == "" {
@@ -134,7 +134,7 @@ func (t NtlmTransport) RoundTrip(req *http.Request) (res *http.Response, err err
134134
}
135135

136136
// set NTLM Authorization header
137-
req.Header.Set("Authorization", "NTLM " + utils.EncBase64(authenticate.Bytes()))
137+
req.Header.Set("Authorization", "NTLM "+utils.EncBase64(authenticate.Bytes()))
138138

139139
resp, err = client.Do(req)
140140
}

0 commit comments

Comments
 (0)