BishopFox / sliver

Adversary Emulation Framework
GNU General Public License v3.0
8.54k stars 1.13k forks source link

Can't build sliver under several Linux distro #1497

Closed Gr4yG closed 6 months ago

Gr4yG commented 11 months ago

Description: I have tried to build Sliver under Kali, Debian-11, Debian-10 but I always keep getting the same error. I even tried to build it with different versions of Golang installed, yet it's always the same error.

Some ENV details: The Golang version used were: Go.1.20.1 & Go.1.21.5 (latest) The Sliver branches I tried were: V1.5.40 & v1.5.39 Tried it under a VM and on my main machine, same result.

The error is as follow, when running the make or make linux:

...
...
touch ./.downloaded_assets
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -mod=vendor -trimpath -tags osusergo,netgo,cgosqlite,sqlite_omit_load_extension,server -ldflags "-s -w -extldflags '-static' -X github.com/bishopfox/sliver/client/version.Version=v1.5.39 -X \"github.com/bishopfox/sliver/client/version.GoVersion=go version go1.21.3 linux/amd64\" -X github.com/bishopfox/sliver/client/version.CompiledAt=1702124090 -X github.com/bishopfox/sliver/client/version.GithubReleasesURL=https://api.github.com/repos/BishopFox/sliver/releases -X github.com/bishopfox/sliver/client/version.GitCommit=af46878f8520c0c65bbb1e80d813a9658ba09188 -X github.com/bishopfox/sliver/client/version.GitDirty= -X github.com/bishopfox/sliver/client/assets.DefaultArmoryPublicKey=RWSBpxpRWDrD7Fe+VvRE3c2VEDC2NK80rlNCj+BX0gz44Xw07r6KQD9L -X github.com/bishopfox/sliver/client/assets.DefaultArmoryRepoURL=https://api.github.com/repos/sliverarmory/armory/releases" -o sliver-server ./server
package github.com/bishopfox/sliver/server
    imports github.com/bishopfox/sliver/server/cli
    imports github.com/bishopfox/sliver/server/builder
    imports github.com/bishopfox/sliver/server/generate
    imports github.com/bishopfox/sliver/server/certs
    imports github.com/bishopfox/sliver/server/core
    imports github.com/bishopfox/sliver/implant/sliver/transports/wireguard
    imports github.com/bishopfox/sliver/implant/sliver/netstack
    imports gvisor.dev/gvisor/pkg/bufferv2
    imports gvisor.dev/gvisor/pkg/atomicbitops
    imports gvisor.dev/gvisor/pkg/state
    imports gvisor.dev/gvisor/pkg/state/wire
    imports gvisor.dev/gvisor/pkg/gohacks: build constraints exclude all Go files in /home/XX/Documents/sliver/vendor/gvisor.dev/gvisor/pkg/gohacks
make: *** [Makefile:137: linux] Error 1

Note: I've done some research, and found some ppl talking about it and it looks like some Go bug in the gvisor, I'm not sure about that

moloch-- commented 11 months ago

Check the go version on your PATH

kmahyyg commented 10 months ago

go version go1.21.6 linux/amd64.

Same problem here.

kmahyyg commented 10 months ago

https://github.com/google/gvisor/pull/9197 https://github.com/google/gvisor/commit/c006f01e0e550ea5609190131747d7b1533f8e03

It seems you may need to upgrade gVisor library. And after upgrade, tun implementation need some fixes for v1.5.x to build and work.

leader0001 commented 9 months ago

After updating gVisor, it still gives an error: go: inconsistent vendoring in /home/kali/sliver: gvisor.dev/gvisor@v0.0.0-20240124230955-d788c40b192d: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt gvisor.dev/gvisor@v0.0.0-20220817001344-846276b3dbc5: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod To ignore the vendor directory, use -mod=readonly or -mod=mod. To sync the vendor directory, run: go mod vendor

'go mod vendor' don't solve the problem

dobin commented 9 months ago

Using the weird install instructions of gvisor from https://gvisor.dev/docs/user_guide/install/ didnt help, using sliver v1.5.41.

But master seems to have fixed it:

root@sliver:~/sliver# git checkout tags/v1.5.41
Note: switching to 'tags/v1.5.41'.
root@sliver:~/sliver# make
rm -f sliver-client sliver-server sliver-*.exe
CGO_ENABLED=1 go build -mod=vendor -trimpath -tags osusergo,netgo,cgosqlite,sqlite_omit_load_extension,server -ldflags "-s -w -X github.com/bishopfox/sliver/client/version.Version=v1.5.41 -X \"github.com/bishopfox/sliver/client/version.GoVersion=go version go1.21.6 linux/amd64\" -X github.com/bishopfox/sliver/client/version.CompiledAt=1706440357 -X github.com/bishopfox/sliver/client/version.GithubReleasesURL=https://api.github.com/repos/BishopFox/sliver/releases -X github.com/bishopfox/sliver/client/version.GitCommit=f2a3915c79b31ab31c0c2f0428bbd53d9e93c54b -X github.com/bishopfox/sliver/client/version.GitDirty= -X github.com/bishopfox/sliver/client/assets.DefaultArmoryPublicKey=RWSBpxpRWDrD7Fe+VvRE3c2VEDC2NK80rlNCj+BX0gz44Xw07r6KQD9L -X github.com/bishopfox/sliver/client/assets.DefaultArmoryRepoURL=https://api.github.com/repos/sliverarmory/armory/releases" -o sliver-server ./server
package github.com/bishopfox/sliver/server
        imports github.com/bishopfox/sliver/server/cli
        imports github.com/bishopfox/sliver/server/builder
        imports github.com/bishopfox/sliver/server/generate
        imports github.com/bishopfox/sliver/server/certs
        imports github.com/bishopfox/sliver/server/core
        imports github.com/bishopfox/sliver/implant/sliver/transports/wireguard
        imports github.com/bishopfox/sliver/implant/sliver/netstack
        imports gvisor.dev/gvisor/pkg/bufferv2
        imports gvisor.dev/gvisor/pkg/atomicbitops
        imports gvisor.dev/gvisor/pkg/state
        imports gvisor.dev/gvisor/pkg/state/wire
        imports gvisor.dev/gvisor/pkg/gohacks: build constraints exclude all Go files in /root/sliver/vendor/gvisor.dev/gvisor/pkg/gohacks
root@sliver:~/sliver# git checkout master
Previous HEAD position was f2a3915c7 Merge pull request #1344 from BishopFox/fix/pstree
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
root@sliver:~/sliver# make
rm -f sliver-client sliver-client_* sliver-server sliver-server_* sliver-*.exe
CGO_ENABLED=0 go build -mod=vendor -trimpath -tags go_sqlite,server -ldflags "-s -w -X github.com/bishopfox/sliver/client/version.Version=v1.5.39 -X \"github.com/bishopfox/sliver/client/version.GoVersion=go version go1.21.6 linux/amd64\" -X github.com/bishopfox/sliver/client/version.CompiledAt=1706440502 -X github.com/bishopfox/sliver/client/version.GithubReleasesURL=https://api.github.com/repos/BishopFox/sliver/releases -X github.com/bishopfox/sliver/client/version.GitCommit=d0dc42ea2f578624da804e889b391b059c4470c0 -X github.com/bishopfox/sliver/client/version.GitDirty= -X github.com/bishopfox/sliver/client/assets.DefaultArmoryPublicKey=RWSBpxpRWDrD7Fe+VvRE3c2VEDC2NK80rlNCj+BX0gz44Xw07r6KQD9L -X github.com/bishopfox/sliver/client/assets.DefaultArmoryRepoURL=https://api.github.com/repos/sliverarmory/armory/releases" -o sliver-server ./server
CGO_ENABLED=0 go build -mod=vendor -trimpath -tags go_sqlite,client -ldflags "-s -w -X github.com/bishopfox/sliver/client/version.Version=v1.5.39 -X \"github.com/bishopfox/sliver/client/version.GoVersion=go version go1.21.6 linux/amd64\" -X github.com/bishopfox/sliver/client/version.CompiledAt=1706440502 -X github.com/bishopfox/sliver/client/version.GithubReleasesURL=https://api.github.com/repos/BishopFox/sliver/releases -X github.com/bishopfox/sliver/client/version.GitCommit=d0dc42ea2f578624da804e889b391b059c4470c0 -X github.com/bishopfox/sliver/client/version.GitDirty= -X github.com/bishopfox/sliver/client/assets.DefaultArmoryPublicKey=RWSBpxpRWDrD7Fe+VvRE3c2VEDC2NK80rlNCj+BX0gz44Xw07r6KQD9L -X github.com/bishopfox/sliver/client/assets.DefaultArmoryRepoURL=https://api.github.com/repos/sliverarmory/armory/releases" -o sliver-client ./client
root@sliver:~/sliver#
moloch-- commented 8 months ago

Make sure to use Go v1.20.7 when building v1.5.x

SLizerin-CLI commented 7 months ago

From the documentation, When compiling v1.5.x use Go v1.20.7. I downgraded the go version to 1.20.7 and that solved the issue.