From eda0e94cc30f82bc80b6e4dbbcddffded8da4265 Mon Sep 17 00:00:00 2001 From: jm33-m0 Date: Wed, 24 Jan 2024 17:41:50 +0800 Subject: [PATCH] feature: support DLL agent stub (`amd64` only) you will need to build the DLL yourself --- core/lib/cc/buildAgent.go | 12 ++++++++++-- core/lib/cc/cc.go | 1 + core/lib/data/def.go | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/lib/cc/buildAgent.go b/core/lib/cc/buildAgent.go index bed42a7f7..8ad0b9c17 100644 --- a/core/lib/cc/buildAgent.go +++ b/core/lib/cc/buildAgent.go @@ -26,7 +26,6 @@ var Arch_List = []string{ "riscv64", } -// a wrapper for CmdFuncs func genAgentWrapper() { CliPrint("Generated agent binary: %s."+ "You can `use stager` to generate a one liner for your target host", GenAgent()) @@ -39,9 +38,10 @@ func GenAgent() (agent_binary_path string) { ) now := time.Now() stubFile := fmt.Sprintf("%s-%s", emp3r0r_data.Stub_Linux, arch_choice) - os_choice := CliAsk("Generate agent for (1) Linux, (2) Windows: ", false) + os_choice := CliAsk("Generate agent for (1) Linux, (2) Windows (3) Windows DLL: ", false) is_win := os_choice == "2" is_linux := os_choice == "1" + is_dll := os_choice == "3" if is_linux { CliPrintInfo("You chose Linux") for n, arch := range Arch_List { @@ -69,7 +69,15 @@ func GenAgent() (agent_binary_path string) { EmpWorkSpace, arch_choice, now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second()) } + if is_dll { + CliPrintInfo("You chose Windows DLL") + stubFile = fmt.Sprintf("%s-%s", emp3r0r_data.Stub_Windows_DLL, arch_choice) + outfile = fmt.Sprintf("%s/agent_windows_%s_%d-%d-%d_%d-%d-%d.dll", + EmpWorkSpace, arch_choice, + now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second()) + } + // is this stub file available? if !util.IsExist(stubFile) { CliPrintError("%s not found, build it first", stubFile) return diff --git a/core/lib/cc/cc.go b/core/lib/cc/cc.go index 0139ace0a..10044cc05 100644 --- a/core/lib/cc/cc.go +++ b/core/lib/cc/cc.go @@ -507,6 +507,7 @@ func InitConfig() (err error) { // binaries emp3r0r_data.Stub_Linux = EmpWorkSpace + "/stub" emp3r0r_data.Stub_Windows = EmpWorkSpace + "/stub-win" + emp3r0r_data.Stub_Windows_DLL = EmpWorkSpace + "/stub-win-dll" // copy stub binaries to ~/.emp3r0r for _, arch := range Arch_List { diff --git a/core/lib/data/def.go b/core/lib/data/def.go index 075c6b89e..fdba5d80e 100644 --- a/core/lib/data/def.go +++ b/core/lib/data/def.go @@ -54,6 +54,7 @@ var ( // to be updated by DirSetup Stub_Linux = "" Stub_Windows = "" + Stub_Windows_DLL = "" Packer_Stub = "" Packer_Stub_Windows = "" )