Skip to content

Commit

Permalink
Expanded unit tests to cover linux shared library builds and windows …
Browse files Browse the repository at this point in the history
…service builds issue #348
  • Loading branch information
moloch-- committed Mar 15, 2021
1 parent 75ee37f commit d86661a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get update --fix-missing && apt-get -y install \
libapr1 libaprutil1 libsvn1 \
libpcap-dev libsqlite3-dev libgmp3-dev \
zip unzip mingw-w64 binutils-mingw-w64 g++-mingw-w64 \
nasm
nasm gcc-multilib

#
# > User
Expand Down
38 changes: 37 additions & 1 deletion server/generate/binaries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func TestSliverExecutableWindows(t *testing.T) {
multiExe(t, "windows", "amd64", false)
multiExe(t, "windows", "386", false)
multiExe(t, "windows", "386", false)

// Service
multiWindowsService(t, "windows", "amd64", true)
multiWindowsService(t, "windows", "amd64", false)
}

func TestSliverSharedLibWindows(t *testing.T) {
Expand All @@ -76,6 +80,13 @@ func TestSliverExecutableLinux(t *testing.T) {
tcpPivotExe(t, "linux", "amd64", false)
}

func TestSliverSharedLibraryLinux(t *testing.T) {
multiLibrary(t, "linux", "amd64", true)
multiLibrary(t, "linux", "amd64", false)
multiLibrary(t, "linux", "386", true)
multiLibrary(t, "linux", "386", false)
}

func TestSliverExecutableDarwin(t *testing.T) {
multiExe(t, "darwin", "amd64", true)
multiExe(t, "darwin", "amd64", false)
Expand All @@ -89,7 +100,6 @@ func TestSliverDefaultBuild(t *testing.T) {
httpExe(t, "freebsd", "amd64", true)
dnsExe(t, "plan9", "amd64", false)
dnsExe(t, "plan9", "amd64", true)

}

func TestSymbolObfuscation(t *testing.T) {
Expand Down Expand Up @@ -191,6 +201,32 @@ func multiExe(t *testing.T, goos string, goarch string, debug bool) {
}
}

func multiWindowsService(t *testing.T, goos string, goarch string, debug bool) {
t.Logf("[multi] %s/%s - debug: %v", goos, goarch, debug)
config := &models.ImplantConfig{
GOOS: goos,
GOARCH: goarch,
Format: clientpb.ImplantConfig_SERVICE,

C2: []models.ImplantC2{
{URL: "mtls://1.example.com"},
{URL: "mtls://2.example.com", Options: "asdf"},
{URL: "https://3.example.com"},
{Priority: 3, URL: "dns://4.example.com"},
},
MTLSc2Enabled: true,
HTTPc2Enabled: true,
DNSc2Enabled: true,
Debug: debug,
ObfuscateSymbols: false,
}
nonce++
_, err := SliverExecutable(fmt.Sprintf("service_test%d", nonce), config)
if err != nil {
t.Errorf(fmt.Sprintf("%v", err))
}
}

func tcpPivotExe(t *testing.T, goos string, goarch string, debug bool) {
t.Logf("[tcppivot] EXE %s/%s - debug: %v", goos, goarch, debug)
config := &models.ImplantConfig{
Expand Down

0 comments on commit d86661a

Please sign in to comment.