From 2d7754d8e2833b44abf3713b5f969f45cce05eb1 Mon Sep 17 00:00:00 2001 From: Ne0nd0g Date: Wed, 20 Jul 2022 21:00:00 -0400 Subject: [PATCH] Fixed load-assembly --- pkg/server/jobs/jobs.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/server/jobs/jobs.go b/pkg/server/jobs/jobs.go index f1d9b58e..e0957ba6 100644 --- a/pkg/server/jobs/jobs.go +++ b/pkg/server/jobs/jobs.go @@ -182,17 +182,19 @@ func Add(agentID uuid.UUID, jobType string, jobArgs []string) (string, error) { if err != nil { return "", fmt.Errorf("there was an error reading the assembly at %s:\n%s", jobArgs[0], err) } + + name := filepath.Base(jobArgs[0]) + if len(jobArgs) > 1 { + name = jobArgs[1] + } + fileHash := sha256.New() _, err = io.WriteString(fileHash, string(assembly)) if err != nil { message("warn", fmt.Sprintf("there was an error generating a file hash:\n%s", err)) } - jobArgs[2] = fmt.Sprintf("%s", fileHash.Sum(nil)) + jobArgs = append(jobArgs, fmt.Sprintf("%s", fileHash.Sum(nil))) - name := filepath.Base(jobArgs[0]) - if len(jobArgs) > 1 { - name = jobArgs[1] - } job.Payload = merlinJob.Command{ Command: "clr", Args: []string{jobType, base64.StdEncoding.EncodeToString([]byte(assembly)), name},