Skip to content

Commit

Permalink
feature: use upx to further compress packed agent binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Mar 29, 2022
1 parent 3c1b9b3 commit 1c6800f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ test_agent:

if agent.RuntimeConfig.UseShadowsocks {
// since we are Internet-facing, we can use Shadowsocks proxy to obfuscate our C2 traffic a bit
agent.RuntimeConfig.AgentProxy = fmt.Sprintf("socks5://127.0.0.1:%s", agent.RuntimeConfig.ShadowsocksPort)
agent.RuntimeConfig.AgentProxy = fmt.Sprintf("socks5://127.0.0.1:%s",
agent.RuntimeConfig.ShadowsocksPort)
go agent.ShadowsocksC2Client()
}
}
Expand Down
12 changes: 12 additions & 0 deletions core/lib/cc/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"

emp3r0r_data "github.com/jm33-m0/emp3r0r/core/lib/data"
"github.com/jm33-m0/emp3r0r/core/lib/tun"
"github.com/jm33-m0/emp3r0r/core/lib/util"
"github.com/mholt/archiver"
)

Expand Down Expand Up @@ -64,6 +66,16 @@ func Packer(inputELF string) (err error) {
return fmt.Errorf("write to packed file %s: %v", packed_file, err)
}

// upx
if util.IsCommandExist("upx") {
CliPrintInfo("Using upx to further compress the executable %s", packed_file)
cmd := exec.Command("upx", "-9", packed_file)
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("Packer: upx: %s (%v)", out, err)
}
}

// done
CliPrintSuccess("%s has been packed as %s", inputELF, packed_file)
return
Expand Down

0 comments on commit 1c6800f

Please sign in to comment.