Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add protocol based flag handling #267

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add protocol based flag handling #267

wants to merge 3 commits into from

Conversation

terrorbyte
Copy link
Collaborator

@terrorbyte terrorbyte commented Nov 8, 2024

Closes #234

Allows for protocols to have explicit flags that will resolve when they get defined. For example, if your exploit defines "HTTP" as it's protocol, this change automatically applies the "user-agent" flag to the cli args and if it does not it will not appear.

I of course wanted to support multi-protocol or sub-protocol situations, so this also adds the cli.AddProtocolFlags function that will allow for manually adding flags where applicable.

Also adds a few checks for whether to print the Global User-Agent string based on that and a quick Warning check for if proxies are supported.


Here's the negative test case where a CVE does not use HTTP so the flag no longer appears:

poptart@grimm $ make && ./build/cve-2024-4548* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-4548.go reverse_shell.go
golangci-lint run --fix --timeout 3m cve-2024-4548.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-4548_linux-amd64 cve-2024-4548.go
  -user-agent string
    	The User-Agent to use in HTTP requests (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36")
poptart@grimm $ go mod edit -replace github.com/vulncheck-oss/go-exploit=$DEV/go-exploit
poptart@grimm $ make && ./build/cve-2024-4548* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-4548.go reverse_shell.go
golangci-lint run --fix --timeout 3m cve-2024-4548.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-4548_linux-amd64 cve-2024-4548.go

And here's the positive test case where a CVE does use HTTP so the flag appears:

poptart@grimm $ make && ./build/cve-2024-* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-45216.go verification.go
golangci-lint run --fix --timeout 3m cve-2024-45216.go verification.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-45216_linux-amd64 cve-2024-45216.go verification.go
  -user-agent string
    	The User-Agent to use in HTTP requests (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36")
poptart@grimm $ go mod edit -replace github.com/vulncheck-oss/go-exploit=$DEV/go-exploit
poptart@grimm $ make && ./build/cve-2024-* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-45216.go verification.go
golangci-lint run --fix --timeout 3m cve-2024-45216.go verification.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-45216_linux-amd64 cve-2024-45216.go verification.go
  -user-agent string
    	The User-Agent to use in HTTP requests (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36")

Closes #234

Allows for protocols to have explicit flags that will resolve when they
get defined. For example, if your exploit defines "HTTP" as it's
protocol, this change automatically applies the "user-agent" flag to the
cli args and if it does not it will not appear.

I of course wanted to support multi-protocol or sub-protocol situations,
so this also adds the `cli.AddProtocolFlags` function that will allow
for manually adding flags where applicable.

Also adds a few checks for whether to print the Global User-Agent string
based on that and a quick Warning check for if proxies are supported.
@terrorbyte terrorbyte added enhancement New feature or request rfc labels Nov 8, 2024
@terrorbyte terrorbyte self-assigned this Nov 8, 2024
cli/commandline.go Outdated Show resolved Hide resolved
@terrorbyte
Copy link
Collaborator Author

Updated with our offline discussion of moving it to protocol vs cli which I think is smart:

Negative case:

poptart@grimm $ make && ./build/cve-2024-4548* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-4548.go reverse_shell.go
golangci-lint run --fix --timeout 3m cve-2024-4548.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-4548_linux-amd64 cve-2024-4548.go
  -user-agent string
    	The User-Agent to use in HTTP requests (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36")
poptart@grimm $ go mod edit -replace github.com/vulncheck-oss/go-exploit=$DEV/go-exploit
poptart@grimm $ make && ./build/cve-2024-4548* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-4548.go reverse_shell.go
golangci-lint run --fix --timeout 3m cve-2024-4548.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-4548_linux-amd64 cve-2024-4548.go

Positive case:

poptart@grimm $ make && ./build/cve-2024-* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-45216.go verification.go
golangci-lint run --fix --timeout 3m cve-2024-45216.go verification.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-45216_linux-amd64 cve-2024-45216.go verification.go
  -user-agent string
    	The User-Agent to use in HTTP requests (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36")
poptart@grimm $ go mod edit -replace github.com/vulncheck-oss/go-exploit=$DEV/go-exploit
poptart@grimm $ make && ./build/cve-2024-* -h 2>&1 | grep -A 1 "user-agent"
gofmt -d -w cve-2024-45216.go verification.go
golangci-lint run --fix --timeout 3m cve-2024-45216.go verification.go
GOOS=linux GOARCH=amd64 go build  -o build/cve-2024-45216_linux-amd64 cve-2024-45216.go verification.go
  -user-agent string
    	The User-Agent to use in HTTP requests (default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Match config.Protocol for global flag assignment
2 participants