Skip to content

Commit

Permalink
fix concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
5amu committed Feb 18, 2024
1 parent 2f2f652 commit 850417e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<img src="https://github.com/5amu/goad/actions/workflows/lint-test.yml/badge.svg">
<img src="https://github.com/5amu/goad/actions/workflows/release.yml/badge.svg">
<a href="https://goreportcard.com/report/github.com/5amu/goad"><img src="https://goreportcard.com/badge/5amu/goad"></a>
<a href="https://pkg.go.dev/github.com/5amu/goad"><img href="https://pkg.go.dev/badge/github.com/5amu/goad.svg"></a>
<a href="https://pkg.go.dev/github.com/5amu/goad"><img src="https://pkg.go.dev/badge/github.com/5amu/goad.svg"></a>
</p>

---
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ require (
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/goidentity/v6 v6.0.1 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jlaffaye/ftp v0.2.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyC
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
Expand All @@ -70,6 +75,8 @@ github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jlaffaye/ftp v0.2.0 h1:lXNvW7cBu7R/68bknOX3MrRIIqZ61zELs1P2RAiA3lg=
github.com/jlaffaye/ftp v0.2.0/go.mod h1:is2Ds5qkhceAPy2xD6RLI6hmp/qysSoymZ+Z2uTnspI=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
Expand Down
17 changes: 14 additions & 3 deletions internal/goad/krb5.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,21 @@ type Krb5Options struct {
func (o *Krb5Options) Run() error {
o.targets = utils.ExtractTargets(o.Targets.TARGETS)
o.target2SMBInfo = make(map[string]*smb.SMBInfo)
var wg sync.WaitGroup
var mutex sync.Mutex
for _, t := range o.targets {
o.target2SMBInfo[t] = getSMBInfo(t)
wg.Add(1)
go func(s string) {
v := getSMBInfo(s)
if v != nil {
mutex.Lock()
o.target2SMBInfo[s] = v
mutex.Unlock()
}
wg.Done()
}(t)
}
wg.Wait()

if o.BruteforceStrategy.Pitchfork {
o.credentials = utils.NewCredentialsPitchFork(
Expand All @@ -64,8 +76,7 @@ func (o *Krb5Options) Run() error {
return nil
}

var wg sync.WaitGroup
for _, target := range o.targets {
for target := range o.target2SMBInfo {
wg.Add(1)
go func(t string) {
if err := f(t); err != nil {
Expand Down
8 changes: 5 additions & 3 deletions internal/goad/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ func (o *LdapOptions) Run() (err error) {
wg.Add(1)
go func(s string) {
v := getSMBInfo(s)
mutex.Lock()
o.target2SMBInfo[s] = v
mutex.Unlock()
if v != nil {
mutex.Lock()
o.target2SMBInfo[s] = v
mutex.Unlock()
}
wg.Done()

}(t)
Expand Down

0 comments on commit 850417e

Please sign in to comment.