From 756717ed28dc60716f5a6de59ee8d1b3a4616781 Mon Sep 17 00:00:00 2001
From: its-a-feature <codybthomas@gmail.com>
Date: Wed, 13 Nov 2024 11:12:18 -0600
Subject: [PATCH] tweaking lsopen response creation

---
 .../poseidon/agent_code/lsopen/lsopen.go      | 35 ++++++++-----------
 .../agent_code/lsopen/lsopen_darwin.go        |  3 +-
 2 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen.go b/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen.go
index aac42bc..518b017 100644
--- a/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen.go
+++ b/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen.go
@@ -10,44 +10,37 @@ import (
 )
 
 type Arguments struct {
-	Application string `json:"application"`
-	HideApp     bool   `json:"hideApp"`
-	AppArgs     []string   `json:"appArgs"`
+	Application string   `json:"application"`
+	HideApp     bool     `json:"hideApp"`
+	AppArgs     []string `json:"appArgs"`
 }
 
 func Run(task structs.Task) {
-	msg := structs.Response{}
-	msg.TaskID = task.TaskID
+	msg := task.NewResponse()
 
 	args := Arguments{}
 	err := json.Unmarshal([]byte(task.Params), &args)
 
 	if err != nil {
-		msg.UserOutput = err.Error()
-		msg.Completed = true
-		msg.Status = "error"
+		msg.SetError(err.Error())
 		task.Job.SendResponses <- msg
 		return
 	}
 
 	r, err := runCommand(args.Application, args.HideApp, args.AppArgs)
 	if err != nil {
-		msg.UserOutput = err.Error()
-		msg.Completed = true
-		msg.Status = "error"
+		msg.SetError(err.Error())
 		task.Job.SendResponses <- msg
 		return
 	}
 
-        if r.Successful {
-                msg.UserOutput = "Successfully spawned application."
-                msg.Completed = true
-                task.Job.SendResponses <- msg
-        } else {
-                msg := task.NewResponse()
-                msg.SetError("Failed to spawn application.")
-                task.Job.SendResponses <- msg
-        }
-
+	if r.Successful {
+		msg.UserOutput = "Successfully spawned application."
+		msg.Completed = true
+		task.Job.SendResponses <- msg
+	} else {
+		msg.SetError("Failed to spawn application.")
+		task.Job.SendResponses <- msg
+	}
 	return
 }
diff --git a/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen_darwin.go b/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen_darwin.go
index fd49785..8285a30 100644
--- a/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen_darwin.go
+++ b/Payload_Type/poseidon/poseidon/agent_code/lsopen/lsopen_darwin.go
@@ -1,4 +1,4 @@
-// +build darwin
+//go:build darwin
 
 package lsopen
 
@@ -48,7 +48,6 @@ func runCommand(app string, hide bool, args []string) (LSOpenDarwin, error) {
 	}
 	c_argv = (**C.char)(unsafe.Pointer(&cArgs[0]))
 
-
 	res := C.lsopen_init(capp, ihide, c_argv, c_argc)
 
 	//free