From cd071821d3fd479a6cdf6420632419724ed3fc5a Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 26 Jan 2021 12:56:28 -0800 Subject: [PATCH] add optional args to run python script --- agent/agent_windows.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/agent/agent_windows.go b/agent/agent_windows.go index e024a87..999cf9d 100644 --- a/agent/agent_windows.go +++ b/agent/agent_windows.go @@ -398,7 +398,7 @@ except: print("None", end='') ` - user, err := a.RunPythonCode(pyCode, 5) + user, err := a.RunPythonCode(pyCode, 5, []string{}) if err == nil { return user } @@ -754,7 +754,7 @@ func (a *WindowsAgent) CleanupAgentUpdates() { } } -func (a *WindowsAgent) RunPythonCode(code string, timeout int) (string, error) { +func (a *WindowsAgent) RunPythonCode(code string, timeout int, args []string) (string, error) { content := []byte(code) dir, err := ioutil.TempDir("", "tacticalpy") if err != nil { @@ -777,7 +777,12 @@ func (a *WindowsAgent) RunPythonCode(code string, timeout int) (string, error) { defer cancel() var outb, errb bytes.Buffer - cmd := exec.CommandContext(ctx, a.PyBin, tmpfn.Name()) + cmdArgs := []string{tmpfn.Name()} + if len(args) > 0 { + cmdArgs = append(cmdArgs, args...) + } + a.Logger.Debugln(cmdArgs) + cmd := exec.CommandContext(ctx, a.PyBin, cmdArgs...) cmd.Stdout = &outb cmd.Stderr = &errb