Skip to content

Commit

Permalink
Merge pull request #1445 from BishopFox/fix-1444
Browse files Browse the repository at this point in the history
Fixing issue with User Agent in Implant Generation
  • Loading branch information
moloch-- authored Nov 3, 2023
2 parents 16db603 + 4da9233 commit 9d1fa0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion implant/sliver/transports/httpclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import (
var (
goHTTPDriver = "go"

userAgent = "{{GenerateUserAgent}}"
userAgent = `{{GenerateUserAgent}}`
nonceQueryArgs = "{{.HTTPC2ImplantConfig.NonceQueryArgs}}" // "abcdefghijklmnopqrstuvwxyz"

ErrClosed = errors.New("http session closed")
Expand Down
13 changes: 13 additions & 0 deletions server/configs/http-c2.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ var (
ErrTooFewSessionFiles = errors.New("implant config must specify at least one session_files value")
ErrNonuniqueFileExt = errors.New("implant config must specify unique file extensions")
ErrQueryParamNameLen = errors.New("implant config url query parameter names must be 3 or more characters")
ErrUserAgentIllegalCharacters = errors.New("user agent cannot contain the ` character")

fileNameExp = regexp.MustCompile(`[^a-zA-Z0-9\\._-]+`)
)
Expand Down Expand Up @@ -536,5 +537,17 @@ func checkImplantConfig(config *HTTPC2ImplantConfig) error {
}
}

/*
User agent
Do not allow backticks in user agents because that breaks compilation of the
implant.
*/
if strings.Index(config.UserAgent, "`") != -1 {
// Blank out the user agent so that a default one will be filled in later
config.UserAgent = ""
return ErrUserAgentIllegalCharacters
}

return nil
}

0 comments on commit 9d1fa0d

Please sign in to comment.