This guide will help you get started with go-exploit, a Go package that assists developers in defining the following four stages of exploitation:
- Target validation
- Version checking
- Exploitation
- Command and control
An exploit is structured as follows:
package main
import (
"github.com/vulncheck-oss/go-exploit"
"github.com/vulncheck-oss/go-exploit/c2"
"github.com/vulncheck-oss/go-exploit/config"
)
type MyExploit struct{}
func (sploit MyExploit) ValidateTarget(conf *config.Config) bool {
return false
}
func (sploit MyExploit) CheckVersion(conf *config.Config) exploit.VersionCheckType {
return exploit.NotImplemented
}
func (sploit MyExploit) RunExploit(conf *config.Config) bool {
return true
}
func main() {
supportedC2 := []c2.Impl{
c2.SimpleShellServer,
c2.SimpleShellClient,
}
conf := config.NewRemoteExploit(
config.ImplementedFeatures{AssetDetection: false, VersionScanning: false, Exploitation: false},
config.CodeExecution, supportedC2, "Vendor", []string{"Product"},
[]string{"cpe:2.3:a:vendor:product"}, "CVE-2024-1270", "HTTP", 8080)
sploit := MyExploit{}
exploit.RunProgram(sploit, conf)
}The above code demonstrates the four stages of exploitation that go-exploit cares about:
ValidateTarget()is called to verify if the target is correct.CheckVersion()is called to perform a version check on the target.RunExploitis called to exploit the target.mainsets up the possible command and control (C2) methods (e.g.,c2.SimpleShellServer), defines the type of exploit (config.CodeExecution), and passes execution togo-exploitusingexploit.RunProgram.
To compile the skeleton, you can use a Makefile. Here's a simple one:
all: format compile
format:
go fmt
compile:
go build
clean:
go clean
To compile the skeleton, follow these steps:
- Initialize the exploit's
go.mod, download/validate the most recentgo-exploit, and creatego.sum.
go mod init github.com/username/example;
GO111MODULE=on go mod tidy;
make;This guide should provide you with enough information to get started with go-exploit. For more details on exploit types, command and control (C2), and version checking), please refer to the additional documentation.