Fix formatting for multi-line command output and delete tasks after completion.

This commit is contained in:
Jakob Friedl
2025-05-23 16:02:16 +02:00
parent 5ab9cd302c
commit a8a32668d1
6 changed files with 33 additions and 21 deletions

View File

@@ -9,7 +9,7 @@ var parser = newParser:
help("Conquest Command & Control")
command("shell"):
help("Execute a shell command.")
help("Execute a shell command and retrieve the output.")
arg("command", help="Command", nargs = 1)
arg("arguments", help="Arguments.", nargs = -1) # Handle 0 or more command-line arguments (seq[string])
@@ -44,6 +44,7 @@ proc handleAgentCommand*(cq: Conquest, args: varargs[string]) =
arguments: seq[string] = opts.shell.get.arguments
arguments.insert(command, 0)
cq.taskExecuteShell(arguments)
# Handle help flag
except ShortCircuit as err:
@@ -52,7 +53,5 @@ proc handleAgentCommand*(cq: Conquest, args: varargs[string]) =
# Handle invalid arguments
except UsageError:
cq.writeLine(fgRed, styleBright, "[-] ", getCurrentExceptionMsg())
cq.writeLine("")
cq.writeLine(fgRed, styleBright, "[-] ", getCurrentExceptionMsg(), "\n")