build

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERRORSRDI    = errors.New("srdi error")
	ERROROBJCOPY = errors.New("objcopy error")
)
View Source
var (
	//NameSpace                   = "ghcr.io/chainreactors"
	//Tag                         = "nightly-2024-02-03-latest"
	Ver                          = "latest"
	ContainerSourceCodePath      = "/root/src"
	ContainerCargoRegistryCache  = "/root/cargo/registry"
	ContainerCargoGitCache       = "/root/cargo/git"
	ContainerBinPath             = "/root/bin"
	ContainerBuiltinResourcePath = "/tmp/builtin/resources"
	ContainerCustomResourcePath  = "/tmp/custom/resources"
	ContainerResourcePath        = "/root/src/resources"
	ContainerAutoRunPath         = "/root/src/prelude.yaml"
	ContainerConfigPath          = "/root/src/implant.yaml"

	PATH_ENV = ContainerBinPath + ":/root/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/osxcross/bin:/usr/bin/mingw-w64"
)
View Source
var (
	TemplatePath = filepath.Join(configs.ServerRootPath, "templates")
)

Functions

func AmountArtifact

func AmountArtifact(artifactName string) error

func AutoCheckSource added in v0.1.2

func AutoCheckSource(ctx context.Context, req *clientpb.BuildConfig) (*clientpb.BuildConfig, error)

func CheckSource added in v0.1.2

func CheckSource(ctx context.Context, req *clientpb.BuildConfig) (*clientpb.BuildConfig, error)

CheckSource

func ConvertArtifact added in v0.1.2

func ConvertArtifact(artifact *clientpb.Artifact, format string, rdi string) (*clientpb.Artifact, error)

func CopyProfileFilesExceptConfig added in v0.1.2

func CopyProfileFilesExceptConfig(profilePath, targetPath string) error

CopyProfileFilesExceptConfig copies all files from the profile directory except implant.yaml to the target path

func DeleteSuccessWorkflow

func DeleteSuccessWorkflow(owner, repo, token string, workflowID int64) error

删除成功workflow

func DetectTransport added in v0.3.0

func DetectTransport(implantYaml []byte) string

DetectTransport infers the transport type from implant.yaml content. It looks for transport-related keywords in the targets section.

func FindTemplate added in v0.3.0

func FindTemplate(transport, target string) (string, error)

FindTemplate locates a pre-compiled template binary by transport and target. Naming convention: malefic-{transport}-{target}[.exe]

func GetActionStatus

func GetActionStatus(owner, repo, token, artifactName string) (string, string, error)

获取action状态

func GetContainerID

func GetContainerID(d *DockerBuilder) string

func GetDockerClient

func GetDockerClient() (*client.Client, error)

func GetDockerStatus

func GetDockerStatus(cli *client.Client, containerName string) (string, error)

func GetFilePath

func GetFilePath(name, target, buildType, format string) string

func GetImage added in v0.1.2

func GetImage(target string) string

func GetVolumes added in v0.3.0

func GetVolumes() []string

GetVolumes returns Docker volume mounts computed from current configs paths. Called at build time (not init time) so that UpdateSourceCodeRoot takes effect.

func GetWorkflowStatus

func GetWorkflowStatus(config *clientpb.GithubActionBuildConfig) error

func InitTemplatePath added in v0.3.0

func InitTemplatePath()

func ListTemplates added in v0.3.0

func ListTemplates() map[string][]string

ListTemplates returns all available template files grouped by transport.

func MoveBuildOutput

func MoveBuildOutput(target, buildType string, enable3RD bool, outputType string) (string, string, error)

func MutantSrdi added in v0.1.2

func MutantSrdi(path string) ([]byte, error)

func ObjcopyPulse added in v0.1.2

func ObjcopyPulse(path, platform, arch string) ([]byte, error)

ObjcopyPulse extracts shellcode from compiled artifact using objcopy

func ProcessAutorunWithProfile added in v0.1.2

func ProcessAutorunWithProfile(paramsBytes []byte, profilePath, targetPath string) error

ProcessAutorunWithProfile processes autorun.zip and copies profile files

func ProcessAutorunZip added in v0.1.2

func ProcessAutorunZip(zipData []byte, targetPath string) error

ProcessAutorunZip processes autorun.zip file, extracting only files from the resource directory to the target root directory

func ProcessAutorunZipFromBytes added in v0.3.0

func ProcessAutorunZipFromBytes(zipData []byte) (*clientpb.BuildConfig, error)

ProcessAutorunZipFromBytes

func ProcessAutorunZipToBase64 added in v0.1.2

func ProcessAutorunZipToBase64(paramsByte []byte, profileName string) (string, string, error)

func PushArtifact

func PushArtifact(owner, repo, token, buildName string, isRemove bool) (*models.Artifact, error)

主流程

func SRDIArtifact added in v0.1.2

func SRDIArtifact(bin []byte, platform, arch string, RDIType string) ([]byte, error)

func SaveArtifact

func SaveArtifact(dst string, bin []byte) error

func SendBuildMsg

func SendBuildMsg(artifact *clientpb.Artifact, status string, params []byte, err error)

func SetLicenseID added in v0.1.2

func SetLicenseID(d *DockerBuilder, licenseID string)

func WriteAutoYaml added in v0.1.2

func WriteAutoYaml(data []byte) error

func WriteBuildConfigToPath added in v0.3.0

func WriteBuildConfigToPath(buildConfig *clientpb.BuildConfig, srcPath string) error

WriteBuildConfigToPath

func WriteProfile added in v0.1.2

func WriteProfile(data []byte) error

Types

type ActionBuilder

type ActionBuilder struct {
	// contains filtered or unexported fields
}

func NewActionBuilder

func NewActionBuilder(req *clientpb.BuildConfig) *ActionBuilder

func (*ActionBuilder) Collect

func (a *ActionBuilder) Collect() (string, string, error)

func (*ActionBuilder) Execute

func (a *ActionBuilder) Execute() error

func (*ActionBuilder) Generate

func (a *ActionBuilder) Generate() (*clientpb.Artifact, error)

type Artifact

type Artifact struct {
	ID                 int64     `json:"id"`
	NodeID             string    `json:"node_id"`
	Name               string    `json:"name"`
	SizeInBytes        int64     `json:"size_in_bytes"`
	URL                string    `json:"url"`
	ArchiveDownloadURL string    `json:"archive_download_url"`
	Expired            bool      `json:"expired"`
	CreatedAt          time.Time `json:"created_at"`
	ExpiresAt          time.Time `json:"expires_at"`
	UpdatedAt          time.Time `json:"updated_at"`
	WorkflowRun        struct {
		ID               int64  `json:"id"`
		RepositoryID     int64  `json:"repository_id"`
		HeadRepositoryID int64  `json:"head_repository_id"`
		HeadBranch       string `json:"head_branch"`
		HeadSHA          string `json:"head_sha"`
	} `json:"workflow_run"`
}

Artifact represents a GitHub Actions artifact

type ArtifactsResponse

type ArtifactsResponse struct {
	TotalCount int        `json:"total_count"`
	Artifacts  []Artifact `json:"artifacts"`
}

ArtifactsResponse is the response structure for listing artifacts

type Builder

type Builder interface {
	Generate() (*clientpb.Artifact, error)

	Execute() error

	Collect() (string, string, error)
}

Builder

func NewBuilder

func NewBuilder(req *clientpb.BuildConfig) (Builder, error)

type BuilderState

type BuilderState struct {
	ID     uint32 // Artifact.ID
	Status string // 状态
}

type DockerBuilder

type DockerBuilder struct {
	// contains filtered or unexported fields
}

func NewDockerBuilder

func NewDockerBuilder(req *clientpb.BuildConfig) *DockerBuilder

func (*DockerBuilder) Collect

func (d *DockerBuilder) Collect() (string, string, error)

func (*DockerBuilder) Execute

func (d *DockerBuilder) Execute() error

func (*DockerBuilder) Generate

func (d *DockerBuilder) Generate() (*clientpb.Artifact, error)

type Job

type Job struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
	Steps      []Step `json:"steps"`
}

type JobsResponse

type JobsResponse struct {
	TotalCount int   `json:"total_count"`
	Jobs       []Job `json:"jobs"`
}

type PatchBuilder added in v0.3.0

type PatchBuilder struct {
	// contains filtered or unexported fields
}

func NewPatchBuilder added in v0.3.0

func NewPatchBuilder(req *clientpb.BuildConfig) *PatchBuilder

func (*PatchBuilder) Collect added in v0.3.0

func (p *PatchBuilder) Collect() (string, string, error)

func (*PatchBuilder) Execute added in v0.3.0

func (p *PatchBuilder) Execute() error

func (*PatchBuilder) Generate added in v0.3.0

func (p *PatchBuilder) Generate() (*clientpb.Artifact, error)

type SaasBuilder

type SaasBuilder struct {
	// contains filtered or unexported fields
}

func NewSaasBuilder

func NewSaasBuilder(req *clientpb.BuildConfig) *SaasBuilder

func (*SaasBuilder) Collect

func (s *SaasBuilder) Collect() (string, string, error)

func (*SaasBuilder) Execute

func (s *SaasBuilder) Execute() error

func (*SaasBuilder) Generate

func (s *SaasBuilder) Generate() (*clientpb.Artifact, error)

type Step

type Step struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Conclusion string `json:"conclusion"`
}

type Workflow

type Workflow struct {
	ID           int64     `json:"id"`
	NodeID       string    `json:"node_id"`
	Name         string    `json:"name"`
	Path         string    `json:"path"`
	CreatedAt    time.Time `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	Status       string    `json:"status"`
	State        string    `json:"state"`
	Conclusion   string    `json:"conclusion"`
	URL          string    `json:"url"`
	HTMLURL      string    `json:"html_url"`
	ArtifactsURL string    `json:"artifacts_url"`
}

Workflow represents a GitHub Actions workflow

type WorkflowDispatchPayload

type WorkflowDispatchPayload struct {
	Ref    string            `json:"ref"`
	Inputs map[string]string `json:"inputs,omitempty"`
}

WorkflowDispatchPayload defines the payload for triggering a workflow dispatch event

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL