diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9902426259..bedb2ab4bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,9 +24,10 @@ Contributing to Sliver * _Never_ use homegrown or non-peer reviewed encryption or random number generation algorithms. * Whenever possible, use the following algorithms/encryption modes: - AES-GCM-256 - - RSA-OAEP-2048 / RSA-OAEP-4096 - SHA2-256 / HMAC-SHA2-256 or higher (e.g. SHA2-384) - Curves P521, P384, P256 + - Curve25519, XSalsa20, and Poly1305 (Nacl) + - ChaCha20Poly1305 * _Never_ use the following in a security context, and _avoid_ use even in a non-security context: - MD5 - SHA1 diff --git a/client/command/beacons/beacons.go b/client/command/beacons/beacons.go index 41b2464b7e..7a98165309 100644 --- a/client/command/beacons/beacons.go +++ b/client/command/beacons/beacons.go @@ -30,6 +30,7 @@ import ( "github.com/bishopfox/sliver/protobuf/commonpb" "github.com/desertbit/grumble" "github.com/jedib0t/go-pretty/v6/table" + "golang.org/x/crypto/ssh/terminal" ) // BeaconsCmd - Display/interact with beacons @@ -65,21 +66,37 @@ func PrintBeacons(beacons []*clientpb.Beacon, con *console.SliverConsoleClient) con.PrintInfof("No beacons 🙁\n") return } + width, _, err := terminal.GetSize(0) + if err != nil { + width = 999 + } tw := table.NewWriter() tw.SetStyle(settings.GetTableStyle(con)) - tw.AppendHeader(table.Row{ - "ID", - "Name", - "Tasks", - "Transport", - "Remote Address", - "Hostname", - "Username", - "Operating System", - "Last Check-in", - "Next Check-in", - }) + if 182 < width { + tw.AppendHeader(table.Row{ + "ID", + "Name", + "Tasks", + "Transport", + "Remote Address", + "Hostname", + "Username", + "Operating System", + "Last Check-in", + "Next Check-in", + }) + } else { + tw.AppendHeader(table.Row{ + "ID", + "Name", + "Transport", + "Username", + "Operating System", + "Last Check-in", + "Next Check-in", + }) + } for _, beacon := range beacons { color := console.Normal @@ -88,26 +105,39 @@ func PrintBeacons(beacons []*clientpb.Beacon, con *console.SliverConsoleClient) color = console.Green } - next := time.Unix(beacon.NextCheckin, 0).Format(time.RFC1123) - // Arbitrary 3 second margin of error (jitter is already accounted for) - if time.Unix(beacon.NextCheckin, 0).Add(3 * time.Second).Before(time.Now()) { - next = fmt.Sprintf("%s%s%s", console.Bold+console.Red, next, console.Normal) + nextCheckin := time.Unix(beacon.NextCheckin, 0) + var next string + if time.Unix(beacon.NextCheckin, 0).Before(time.Now()) { + past := time.Now().Sub(nextCheckin) + next = fmt.Sprintf("%s-%s%s", console.Bold+console.Red, past, console.Normal) } else { - next = fmt.Sprintf("%s%s%s", console.Bold+console.Green, next, console.Normal) + eta := nextCheckin.Sub(time.Now()) + next = fmt.Sprintf("%s%s%s", console.Bold+console.Green, eta, console.Normal) + } + if 182 < width { + tw.AppendRow(table.Row{ + fmt.Sprintf(color+"%s"+console.Normal, strings.Split(beacon.ID, "-")[0]), + fmt.Sprintf(color+"%s"+console.Normal, beacon.Name), + fmt.Sprintf(color+"%d / %d"+console.Normal, beacon.TasksCountCompleted, beacon.TasksCount), + fmt.Sprintf(color+"%s"+console.Normal, beacon.Transport), + fmt.Sprintf(color+"%s"+console.Normal, beacon.RemoteAddress), + fmt.Sprintf(color+"%s"+console.Normal, beacon.Hostname), + fmt.Sprintf(color+"%s"+console.Normal, beacon.Username), + fmt.Sprintf(color+"%s/%s"+console.Normal, beacon.OS, beacon.Arch), + fmt.Sprintf(color+"%s ago"+console.Normal, time.Now().Sub(time.Unix(beacon.LastCheckin, 0))), + next, + }) + } else { + tw.AppendRow(table.Row{ + fmt.Sprintf(color+"%s"+console.Normal, strings.Split(beacon.ID, "-")[0]), + fmt.Sprintf(color+"%s"+console.Normal, beacon.Name), + fmt.Sprintf(color+"%s"+console.Normal, beacon.Transport), + fmt.Sprintf(color+"%s"+console.Normal, beacon.Username), + fmt.Sprintf(color+"%s/%s"+console.Normal, beacon.OS, beacon.Arch), + fmt.Sprintf(color+"%s ago"+console.Normal, time.Now().Sub(time.Unix(beacon.LastCheckin, 0))), + next, + }) } - - tw.AppendRow(table.Row{ - fmt.Sprintf(color+"%s"+console.Normal, strings.Split(beacon.ID, "-")[0]), - fmt.Sprintf(color+"%s"+console.Normal, beacon.Name), - fmt.Sprintf(color+"%d / %d"+console.Normal, beacon.TasksCountCompleted, beacon.TasksCount), - fmt.Sprintf(color+"%s"+console.Normal, beacon.Transport), - fmt.Sprintf(color+"%s"+console.Normal, beacon.RemoteAddress), - fmt.Sprintf(color+"%s"+console.Normal, beacon.Hostname), - fmt.Sprintf(color+"%s"+console.Normal, beacon.Username), - fmt.Sprintf(color+"%s/%s"+console.Normal, beacon.OS, beacon.Arch), - fmt.Sprintf(color+"%s ago"+console.Normal, time.Now().Sub(time.Unix(beacon.LastCheckin, 0))), - next, - }) } con.Printf("%s\n", tw.Render()) } diff --git a/client/command/exec/execute-assembly.go b/client/command/exec/execute-assembly.go index 6ec8ff2461..73cd1f069f 100644 --- a/client/command/exec/execute-assembly.go +++ b/client/command/exec/execute-assembly.go @@ -3,14 +3,17 @@ package exec /* Sliver Implant Framework Copyright (C) 2019 Bishop Fox + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -74,7 +77,7 @@ func ExecuteAssemblyCmd(ctx *grumble.Context, con *console.SliverConsoleClient) <-ctrl if err != nil { - con.PrintErrorf("Error: %v", err) + con.PrintErrorf("Error: %s", err) return } diff --git a/client/command/prelude-operator/README.md b/client/command/prelude-operator/README.md new file mode 100644 index 0000000000..1210e07a14 --- /dev/null +++ b/client/command/prelude-operator/README.md @@ -0,0 +1,4 @@ +Prelude Operator +================= + +Connection code for [Prelude Operator](https://www.prelude.org/) diff --git a/client/command/prelude-operator/connect.go b/client/command/prelude-operator/connect.go index 1cfe1ccc29..24542f1b20 100644 --- a/client/command/prelude-operator/connect.go +++ b/client/command/prelude-operator/connect.go @@ -51,10 +51,10 @@ func ConnectCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { } if len(sessions.Sessions) > 0 { con.PrintInfof("Adding existing sessions ...\n") - for _, sess := range sessions.Sessions { - err = sessionMapper.AddSession(sess) + for _, session := range sessions.Sessions { + err = sessionMapper.AddSession(session) if err != nil { - con.PrintErrorf("Could not add session %s to session mapper: %s", sess.Name, err) + con.PrintErrorf("Could not add session %s to session mapper: %s", session.Name, err) } } con.PrintInfof("Done !\n") diff --git a/client/prelude/agent-session.go b/client/prelude/agent-session.go index dad2165341..63373e0467 100644 --- a/client/prelude/agent-session.go +++ b/client/prelude/agent-session.go @@ -1,5 +1,23 @@ package prelude +/* + Sliver Implant Framework + Copyright (C) 2021 Bishop Fox + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + import ( "bufio" "bytes" diff --git a/client/prelude/commands.go b/client/prelude/commands.go index a2fcd8a77f..fc66a3cc4d 100644 --- a/client/prelude/commands.go +++ b/client/prelude/commands.go @@ -1,5 +1,23 @@ package prelude +/* + Sliver Implant Framework + Copyright (C) 2021 Bishop Fox + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + import ( "context" "fmt" diff --git a/client/prelude/config.go b/client/prelude/config.go index 0712987efe..2cf75da945 100644 --- a/client/prelude/config.go +++ b/client/prelude/config.go @@ -1,5 +1,23 @@ package prelude +/* + Sliver Implant Framework + Copyright (C) 2021 Bishop Fox + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + import ( "crypto/md5" "encoding/hex" diff --git a/client/prelude/prelude.go b/client/prelude/prelude.go index 9a6275c8ec..f5463e3754 100644 --- a/client/prelude/prelude.go +++ b/client/prelude/prelude.go @@ -1,5 +1,23 @@ package prelude +/* + Sliver Implant Framework + Copyright (C) 2021 Bishop Fox + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + import ( "context" "errors" @@ -53,7 +71,7 @@ func (p *PreludeSessionMapper) AddSession(s *clientpb.Session) error { if pwdResp != nil { pwd = pwdResp.Path } - // Operator implants have embeded static IDs, but we don't, + // Operator implants have embedded static IDs, but we don't, // so to avoid having multiple sessions showing as one on the Operator // GUI, we need to have a unique name for them. // Plus, having the ID in the name will help the user to make the diff --git a/client/prelude/util/crypto.go b/client/prelude/util/crypto.go index 5e8e5a44e0..13f128bd54 100644 --- a/client/prelude/util/crypto.go +++ b/client/prelude/util/crypto.go @@ -1,5 +1,23 @@ package util +/* + Sliver Implant Framework + Copyright (C) 2021 Bishop Fox + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + import ( "crypto/aes" "crypto/cipher" diff --git a/client/prelude/util/executors.go b/client/prelude/util/executors.go index 72fe5ce0cb..a03f049423 100644 --- a/client/prelude/util/executors.go +++ b/client/prelude/util/executors.go @@ -1,5 +1,23 @@ package util +/* + Sliver Implant Framework + Copyright (C) 2021 Bishop Fox + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + func DetermineExecutors(platform string, arch string) []string { platformExecutors := map[string]map[string][]string{ "windows": { diff --git a/implant/sliver/sliver.c b/implant/sliver/sliver.c index cc4f4b0f6c..ea0fac7769 100644 --- a/implant/sliver/sliver.c +++ b/implant/sliver/sliver.c @@ -4,7 +4,7 @@ DWORD WINAPI Enjoy() { - RunSliver(); + Start(); return 0; } @@ -40,24 +40,24 @@ BOOL WINAPI DllMain( #elif __linux__ #include -void RunSliver(); +void Start(); static void init(int argc, char **argv, char **envp) { unsetenv("LD_PRELOAD"); unsetenv("LD_PARAMS"); - RunSliver(); + Start(); } __attribute__((section(".init_array"), used)) static typeof(init) *init_p = init; #elif __APPLE__ #include -void RunSliver(); +void Start(); __attribute__((constructor)) static void init(int argc, char **argv, char **envp) { unsetenv("DYLD_INSERT_LIBRARIES"); unsetenv("LD_PARAMS"); - RunSliver(); + Start(); } #endif