diff --git a/core/lib/agent/mod.go b/core/lib/agent/mod.go index e27e819a8..dab88df1d 100644 --- a/core/lib/agent/mod.go +++ b/core/lib/agent/mod.go @@ -8,7 +8,6 @@ import ( "path/filepath" "runtime" - "github.com/jm33-m0/arc" 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" @@ -107,16 +106,11 @@ func runStartScript(startScript, modDir string) (string, error) { if err != nil { return "", fmt.Errorf("downloading %s: %w", startScript, err) } + scriptData := payload - // Decompress the payload using XZ - decompressedPayload, err := arc.DecompressXz(payload) - if err != nil { - return "", err - } - - log.Printf("Running %s:\n%s...", startScript, decompressedPayload[:100]) + log.Printf("Running %s:\n%s...", startScript, scriptData[:100]) if runtime.GOOS == "windows" { - return RunModuleScript(decompressedPayload) + return RunModuleScript(scriptData) } // otherwise save the file and run it @@ -130,7 +124,7 @@ func runStartScript(startScript, modDir string) (string, error) { } scriptPath := filepath.Join(modDir, startScript) // write script to file - if writeErr := os.WriteFile(scriptPath, decompressedPayload, 0o700); writeErr != nil { + if writeErr := os.WriteFile(scriptPath, scriptData, 0o700); writeErr != nil { return "", fmt.Errorf("writing %s: %v", startScript, writeErr) } cmd := exec.Command(emp3r0r_data.DefaultShell, scriptPath) diff --git a/core/lib/cc/modcustom.go b/core/lib/cc/modcustom.go index 2141b74cf..169be5cdd 100644 --- a/core/lib/cc/modcustom.go +++ b/core/lib/cc/modcustom.go @@ -13,7 +13,6 @@ import ( "github.com/fatih/color" "github.com/google/uuid" - "github.com/jm33-m0/arc" 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" @@ -286,7 +285,7 @@ func readModCondig(file string) (pconfig *ModConfig, err error) { return } -// genStartScript reads config.json of a module +// genStartScript reads config.json of a module and generates a start script to invoke the module func genStartScript(config *ModConfig, outfile string) error { module_exec_path := fmt.Sprintf("%s/%s/%s", config.Path, config.Name, config.Exec) var builder strings.Builder @@ -318,17 +317,11 @@ func genStartScript(config *ModConfig, outfile string) error { } else { builder.WriteString(fmt.Sprintf(" ./%s", config.Exec)) } + defer builder.Reset() + _ = os.WriteFile(outfile+".orig", []byte(builder.String()), 0o600) - // compress start script with XZ - CliPrintInfo("Compressing start script with XZ...") - // compress start script with XZ - compressedData, compressErr := arc.CompressXz([]byte(builder.String())) - if compressErr != nil { - return fmt.Errorf("CompressXz: %v", compressErr) - } - - // write compressed data to file - return os.WriteFile(outfile, compressedData, 0o600) + // write to file + return os.WriteFile(outfile, []byte(builder.String()), 0o600) } func updateModuleHelp(config *ModConfig) error {