Skip to content

Commit 943e33b

Browse files
authored
Merge branch 'master' into fix-http-ntlm-proxy
2 parents faed735 + 6730108 commit 943e33b

20 files changed

+696
-673
lines changed

autodiscover/autodiscover.go

+21-22
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"crypto/tls"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net"
99
"net/http"
1010
"net/url"
@@ -13,21 +13,20 @@ import (
1313
"strings"
1414
"text/template"
1515

16-
"github.com/sensepost/ruler/http-ntlm"
1716
httpntlm "github.com/sensepost/ruler/http-ntlm"
1817
"github.com/sensepost/ruler/utils"
1918
)
2019

2120
//globals
2221

23-
//SessionConfig holds the configuration for this autodiscover session
22+
// SessionConfig holds the configuration for this autodiscover session
2423
var SessionConfig *utils.Session
2524
var autodiscoverStep int
2625
var secondaryEmail string //a secondary email to use, edge case seen in office365
2726
var Transport http.Transport
2827
var basicAuth = false
2928

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

47-
//createAutodiscover generates a domain name of the format autodiscover.domain.com
48-
//and checks if a DNS entry exists for it. If it doesn't it tries DNS for just the domain name.
49-
//returns an empty string if no valid domain was found.
50-
//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
5150
func createAutodiscover(domain string, https bool) string {
5251
_, err := net.LookupHost(domain)
5352
if err != nil {
@@ -59,7 +58,7 @@ func createAutodiscover(domain string, https bool) string {
5958
return fmt.Sprintf("http://%s/autodiscover/autodiscover.xml", domain)
6059
}
6160

62-
//GetMapiHTTP gets the details for MAPI/HTTP
61+
// GetMapiHTTP gets the details for MAPI/HTTP
6362
func GetMapiHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils.AutodiscoverResp, string, error) {
6463
//var resp *utils.AutodiscoverResp
6564
var err error
@@ -88,7 +87,7 @@ func GetMapiHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils
8887
return resp, rawAutodiscover, nil
8988
}
9089

91-
//GetRPCHTTP exports the RPC details for RPC/HTTP
90+
// GetRPCHTTP exports the RPC details for RPC/HTTP
9291
func GetRPCHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils.AutodiscoverResp, string, string, string, bool, error) {
9392
//var resp *utils.AutodiscoverResp
9493
var err error
@@ -191,7 +190,7 @@ func GetRPCHTTP(email, autoURLPtr string, resp *utils.AutodiscoverResp) (*utils.
191190
return resp, rawAutodiscover, RPCURL, user, ntlmAuth, nil
192191
}
193192

194-
//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
195194
func CheckCache(email string) *utils.AutodiscoverResp {
196195
//check the cache folder for a stored autodiscover record
197196
email = strings.Replace(email, "@", "_", -1)
@@ -206,7 +205,7 @@ func CheckCache(email string) *utils.AutodiscoverResp {
206205
return nil
207206
}
208207
utils.Info.Println("Found cached Autodiscover record. Using this (use --nocache to force new lookup)")
209-
data, err := ioutil.ReadFile(path)
208+
data, err := os.ReadFile(path)
210209
if err != nil {
211210
utils.Error.Println("Error reading stored record ", err)
212211
return nil
@@ -216,7 +215,7 @@ func CheckCache(email string) *utils.AutodiscoverResp {
216215
return &autodiscoverResp
217216
}
218217

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

222221
if autodiscover == "" { //no autodiscover record passed in, don't try write
@@ -241,7 +240,7 @@ func CreateCache(email, autodiscover string) {
241240
}
242241
}
243242

244-
//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
245244
func Autodiscover(domain string) (*utils.AutodiscoverResp, string, error) {
246245
if SessionConfig.Proxy == "" {
247246
Transport = http.Transport{
@@ -259,8 +258,8 @@ func Autodiscover(domain string) (*utils.AutodiscoverResp, string, error) {
259258
return autodiscover(domain, false)
260259
}
261260

262-
//MAPIDiscover function to do the autodiscover request but specify the MAPI header
263-
//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
264263
func MAPIDiscover(domain string) (*utils.AutodiscoverResp, string, error) {
265264
//set transport
266265
if SessionConfig.Proxy == "" {
@@ -345,7 +344,7 @@ func autodiscover(domain string, mapi bool) (*utils.AutodiscoverResp, string, er
345344

346345
if SessionConfig.Basic == true {
347346
if SessionConfig.Domain != "" {
348-
req.SetBasicAuth(SessionConfig.Domain + "\\" + SessionConfig.User, SessionConfig.Pass)
347+
req.SetBasicAuth(SessionConfig.Domain+"\\"+SessionConfig.User, SessionConfig.Pass)
349348
} else {
350349
req.SetBasicAuth(SessionConfig.Email, SessionConfig.Pass)
351350
}
@@ -375,7 +374,7 @@ func autodiscover(domain string, mapi bool) (*utils.AutodiscoverResp, string, er
375374

376375
defer resp.Body.Close()
377376

378-
body, err := ioutil.ReadAll(resp.Body)
377+
body, err := io.ReadAll(resp.Body)
379378
if err != nil {
380379
return nil, "", err
381380
}
@@ -492,17 +491,17 @@ func redirectAutodiscover(redirdom string) (string, error) {
492491
return resp.Header.Get("Location"), nil
493492
}
494493

495-
//InsecureRedirectsO365 allows forwarding the Authorization header even when we shouldn't
494+
// InsecureRedirectsO365 allows forwarding the Authorization header even when we shouldn't
496495
type InsecureRedirectsO365 struct {
497496
Transport http.RoundTripper
498497
User string
499498
Pass string
500499
Insecure bool
501500
}
502501

503-
//RoundTrip custom redirector that allows us to forward the auth header, even when the domain changes.
504-
//This is needed as some office365 domains will redirect from autodiscover.domain.com to autodiscover.outlook.com
505-
//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)
506505
func (l InsecureRedirectsO365) RoundTrip(req *http.Request) (resp *http.Response, err error) {
507506
t := l.Transport
508507

autodiscover/brute.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package autodiscover
33
import (
44
"crypto/tls"
55
"fmt"
6-
"io/ioutil"
76
"net/http"
87
"net/http/cookiejar"
98
"net/url"
9+
"os"
1010
"regexp"
1111
"strings"
1212
"time"
@@ -311,7 +311,7 @@ func UserPassBruteForce() {
311311
func readFile(filename string) []string {
312312
var outputs []string
313313

314-
data, err := ioutil.ReadFile(filename)
314+
data, err := os.ReadFile(filename)
315315
if err != nil {
316316
utils.Error.Println("Input file not found")
317317
return nil

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

go.mod

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
module github.com/sensepost/ruler
22

3-
go 1.15
3+
go 1.21
44

55
require (
6-
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c
6+
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef
77
github.com/staaldraad/go-ntlm v0.0.0-20200612175713-cd032d41aa8c
8-
github.com/urfave/cli v1.22.5
9-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
10-
golang.org/x/net v0.0.0-20210119194325-5f4716e94777
8+
github.com/urfave/cli v1.22.15
9+
golang.org/x/net v0.26.0
1110
gopkg.in/yaml.v2 v2.4.0
1211
)
12+
13+
require (
14+
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
15+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
16+
golang.org/x/crypto v0.24.0 // indirect
17+
golang.org/x/sys v0.21.0 // indirect
18+
golang.org/x/term v0.21.0 // indirect
19+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
20+
)

go.sum

+39-24
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
1-
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
2-
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
3-
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
4-
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c h1:aY2hhxLhjEAbfXOx2nRJxCXezC6CO2V/yN+OCr1srtk=
5-
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
1+
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
2+
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
4+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7+
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef h1:A9HsByNhogrvm9cWb28sjiS3i7tcKCkflWFEkHfuAgM=
8+
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
9+
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
10+
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
11+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
12+
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
13+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
614
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
715
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8-
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
9-
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
10-
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
11-
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
16+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
17+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
1218
github.com/staaldraad/go-ntlm v0.0.0-20200612175713-cd032d41aa8c h1:ZGPsFTrrYiQUmVV+86h6HX9ml4PyrA1REy8NWQwrcBE=
1319
github.com/staaldraad/go-ntlm v0.0.0-20200612175713-cd032d41aa8c/go.mod h1:Jzdz9vcdmcS8ZT5Q+UYGSx8PSIKaQtxQvNVUqN/MOMQ=
14-
github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU=
15-
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
16-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
17-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
18-
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=
19-
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
20-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
21-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
22-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
23-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
24-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
25-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
26-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
27-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
20+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
21+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
22+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
23+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
24+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
25+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
26+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
27+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
28+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
29+
github.com/urfave/cli v1.22.15 h1:nuqt+pdC/KqswQKhETJjo7pvn/k4xMUxgW6liI7XpnM=
30+
github.com/urfave/cli v1.22.15/go.mod h1:wSan1hmo5zeyLGBjRJbzRTNk8gwoYa2B9n4q9dmRIc0=
31+
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
32+
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
33+
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
34+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
35+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
36+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
37+
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
38+
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
2839
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
29-
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
40+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
41+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
3042
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
3143
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
44+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
45+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
46+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

http-ntlm/ntlmtransport.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"errors"
1313
"fmt"
1414
"io"
15-
"io/ioutil"
1615
"net/http"
1716
"net/http/cookiejar"
1817
"net/url"
@@ -54,7 +53,7 @@ func (t NtlmTransport) RoundTrip(req *http.Request) (res *http.Response, err err
5453
b, _ := session.GenerateNegotiateMessage()
5554
// first send NTLM Negotiate header
5655
r, _ := http.NewRequest("GET", req.URL.String(), strings.NewReader(""))
57-
r.Header.Add("Authorization", "NTLM " + utils.EncBase64(b.Bytes()))
56+
r.Header.Add("Authorization", "NTLM "+utils.EncBase64(b.Bytes()))
5857
r.Header.Add("User-Agent", req.UserAgent())
5958

6059
if t.Proxy == "" {
@@ -84,7 +83,7 @@ func (t NtlmTransport) RoundTrip(req *http.Request) (res *http.Response, err err
8483

8584
// it's necessary to reuse the same http connection
8685
// in order to do that it's required to read Body and close it
87-
_, err = io.Copy(ioutil.Discard, resp.Body)
86+
_, err = io.Copy(io.Discard, resp.Body)
8887
if err != nil {
8988
return nil, err
9089
}
@@ -134,7 +133,7 @@ func (t NtlmTransport) RoundTrip(req *http.Request) (res *http.Response, err err
134133
}
135134

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

139138
resp, err = client.Do(req)
140139
}

0 commit comments

Comments
 (0)