Add Go c-archive output format#2290
Open
ph0neh0me wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2289
Adds
archiveas a generation output format for Go c-archives. The new format builds Sliver as a Goc-archiveand packages the generated.a, generated cgo export header, and renderedmain.hinto a.zip.This format requires CGO because Go c-archive output depends on
-buildmode=c-archive; the implementation mirrors the existing shared-library compiler setup where possible.Motivation
Sliver already supports Go shared library output for compatible targets. This adds a closely related archive output for users who need to link the generated implant archive into their own native wrapper or loader workflow.
Implementation
GO_ARCHIVEto the client protobuf output format enum.archivethrough the CLI, generate forms, profiles, RPC generation path, server builder, and external builder metadata.SliverArchivebeside the existing shared-library generation path.config.IsSharedLib = true.-buildmode=c-archive..a, generated.h, and renderedmain.hinto a.zip.Tests
.a, generated.h, andmain.hare included.Manual Validation
Generated a Windows AMD64 archive with:
As expected, a ZIP archive is emitted containing the archive and header files:
Created a minimal wrapper for native linking validation:
Linked the archive into a DLL:
Created a minimal loader to validate symbol resolution and invocation:
Created a simple application to test calls:
Validated the generated artifact end-to-end in a local test environment:
Server-side validation: