Skip to content

Commit

Permalink
Make compression configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
moloch-- committed Aug 17, 2022
1 parent 34f60a7 commit 98f55c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/command/commands.go
Expand Up @@ -478,8 +478,8 @@ func BindCommands(con *console.SliverConsoleClient) {
f.String("k", "key", "", "path to PEM encoded private key file (HTTPS only)")
f.Bool("e", "lets-encrypt", false, "attempt to provision a let's encrypt certificate (HTTPS only)")
f.StringL("aes-encrypt-key", "", "encrypt stage with AES encryption key")
f.StringL("aes-encrypt-iv", "", "encrypt stage with AES encyption iv")
f.Bool("C", "compress", false, "zlib compress the stage")
f.StringL("aes-encrypt-iv", "", "encrypt stage with AES encryption iv")
f.String("C", "compress", "zlib", "compress the stage before encrypting (zlib, gzip)")
},
Run: func(ctx *grumble.Context) error {
con.Println()
Expand Down
8 changes: 6 additions & 2 deletions client/command/jobs/stage.go
Expand Up @@ -38,7 +38,7 @@ func StageListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) {
listenerURL := ctx.Flags.String("url")
aesEncryptKey := ctx.Flags.String("aes-encrypt-key")
aesEncryptIv := ctx.Flags.String("aes-encrypt-iv")
compress := ctx.Flags.Bool("compress")
compress := ctx.Flags.String("compress")

if profileName == "" || listenerURL == "" {
con.PrintErrorf("Missing required flags, see `help stage-listener` for more info\n")
Expand Down Expand Up @@ -95,14 +95,18 @@ func StageListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) {
stage2 = util.PreludeEncrypt(stage2, []byte(aesEncryptKey), []byte(aesEncryptIv))
}

if compress {
switch compress {
case "zlib":
// use zlib to compress the stage2
var compBuff bytes.Buffer
zlibWriter := zlib.NewWriter(&compBuff)
zlibWriter.Write(stage2)
zlibWriter.Close()
stage2 = compBuff.Bytes()
case "gzip":
stage2 = util.GunzipBuf(stage2)
}

switch stagingURL.Scheme {
case "http":
ctrl := make(chan bool)
Expand Down

0 comments on commit 98f55c8

Please sign in to comment.