You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: server/sgn/README.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,4 +6,41 @@ SGN (Sliver Guard Node) coordination and helpers. Implements SGN enrollment, mes
6
6
7
7
## Go Files
8
8
9
-
-`sgn.go` – Implements SGN coordination logic and message handling.
9
+
-`sgn.go` – Implements SGN coordination logic and message handling, including the Shikata Ga Nai encoder helpers.
10
+
-`sgn_test.go` – Unit tests covering SGN configuration wiring and helper utilities.
11
+
12
+
## SGN Encoder Helpers
13
+
14
+
The server helper wraps the [`github.com/moloch--/sgn`](https://github.com/moloch--/sgn) encoder and exposes a simple `SGNConfig` with the following knobs:
15
+
16
+
-`Architecture` – `386`/`amd64` (case-insensitive) selection passed to `sgn.NewEncoder`.
17
+
-`Iterations` – number of encode passes mapped to `Encoder.EncodingCount`.
18
+
-`MaxObfuscation` – byte budget forwarded to `Encoder.ObfuscationLimit`.
19
+
-`PlainDecoder` – keep the decoder stub in clear text.
20
+
-`Safe` – enable register preservation via `Encoder.SaveRegisters`.
21
+
-`BadChars` / `Asci` – optional post-processing filters that brute force new seeds until constraints pass.
22
+
23
+
These options mirror the upstream CLI flags so server-side tasks can reuse the same behavior.
24
+
25
+
## Test Fixtures
26
+
27
+
Shellcode fixtures used by the unit tests live under `testdata/` with a `.bin` extension. They are produced via `msfvenom` using a dedicated Go generator:
28
+
29
+
```bash
30
+
go generate ./server/sgn
31
+
```
32
+
33
+
The generator invokes `msfvenom` three times (reverse TCP/HTTP stagers and an exec payload) and writes raw shellcode into the `testdata` directory. Ensure the Metasploit framework is installed and `msfvenom` is on `$PATH` before running the generation step.
34
+
35
+
## Testing
36
+
37
+
The log subsystem expects a writable Sliver root directory. Point it to a temporary location when running tests:
38
+
39
+
```bash
40
+
export SLIVER_ROOT_DIR=$(pwd)/.tmp-sliver
41
+
export GOCACHE=$(pwd)/.tmp-gocache
42
+
mkdir -p "$SLIVER_ROOT_DIR""$GOCACHE"
43
+
go test ./server/sgn
44
+
```
45
+
46
+
The test suite focuses on option wiring and constraint helpers rather than the full stochastic encoding pipeline.
0 commit comments