Updated task result console output
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Agent configuration
|
# Agent configuration
|
||||||
-d:ListenerUuid="KPDHWZNT"
|
-d:ListenerUuid="JEBFQPEP"
|
||||||
-d:ListenerIp="localhost"
|
-d:ListenerIp="127.0.0.1"
|
||||||
-d:ListenerPort=7777
|
-d:ListenerPort=5555
|
||||||
-d:SleepDelay=10
|
-d:SleepDelay=10
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ proc handleTask*(task: Task, config: AgentConfig): TaskResult =
|
|||||||
|
|
||||||
# Update sleep delay in agent config
|
# Update sleep delay in agent config
|
||||||
if taskResult.status == Completed:
|
if taskResult.status == Completed:
|
||||||
config.sleep = delay
|
config.sleep = parseInt(task.args[0])
|
||||||
|
|
||||||
# Return result
|
# Return result
|
||||||
return taskResult
|
return taskResult
|
||||||
|
|||||||
@@ -214,14 +214,22 @@ proc handleResult*(listener, agent, task: string, taskResult: TaskResult) =
|
|||||||
|
|
||||||
{.cast(gcsafe).}:
|
{.cast(gcsafe).}:
|
||||||
|
|
||||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task}] ", resetStyle, "Task execution finished.")
|
let date: string = now().format("dd-MM-yyyy HH:mm:ss")
|
||||||
|
|
||||||
|
if taskResult.status == Failed:
|
||||||
|
cq.writeLine(fgBlack, styleBright, fmt"[{date}]", fgRed, styleBright, " [-] ", resetStyle, fmt"Task {task} failed.", "\n")
|
||||||
|
|
||||||
|
else:
|
||||||
|
cq.writeLine(fgBlack, styleBright, fmt"[{date}]", fgGreen, " [+] ", resetStyle, fmt"Task {task} finished.")
|
||||||
|
|
||||||
if taskResult.data != "":
|
if taskResult.data != "":
|
||||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task}] ", resetStyle, "Output:")
|
cq.writeLine(fgBlack, styleBright, fmt"[{date}]", fgGreen, " [+] ", resetStyle, "Output:")
|
||||||
|
|
||||||
# Split result string on newline to keep formatting
|
# Split result string on newline to keep formatting
|
||||||
for line in decode(taskResult.data).split("\n"):
|
for line in decode(taskResult.data).split("\n"):
|
||||||
cq.writeLine(line)
|
cq.writeLine(line)
|
||||||
|
else:
|
||||||
|
cq.writeLine()
|
||||||
|
|
||||||
# Update task queue to include all tasks, except the one that was just completed
|
# Update task queue to include all tasks, except the one that was just completed
|
||||||
cq.agents[agent].tasks = cq.agents[agent].tasks.filterIt(it.id != task)
|
cq.agents[agent].tasks = cq.agents[agent].tasks.filterIt(it.id != task)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import ./commands/[shell, sleep]
|
import ./[shell, sleep]
|
||||||
export shell, sleep
|
export shell, sleep
|
||||||
|
|
||||||
#[
|
#[
|
||||||
@@ -16,4 +16,4 @@ proc taskExecuteShell*(cq: Conquest, arguments: seq[string]) =
|
|||||||
# Add new task to the agent's task queue
|
# Add new task to the agent's task queue
|
||||||
cq.interactAgent.tasks.add(task)
|
cq.interactAgent.tasks.add(task)
|
||||||
|
|
||||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task.id}] ", resetStyle, "Tasked agent to execute shell command.")
|
cq.writeLine(fgBlack, styleBright, fmt"[{date}] [*] ", resetStyle, "Tasked agent to execute shell command.")
|
||||||
@@ -25,4 +25,4 @@ proc taskExecuteSleep*(cq: Conquest, delay: int) =
|
|||||||
# Add new task to the agent's task queue
|
# Add new task to the agent's task queue
|
||||||
cq.interactAgent.tasks.add(task)
|
cq.interactAgent.tasks.add(task)
|
||||||
|
|
||||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task.id}] ", resetStyle, "Tasked agent to update sleep settings.")
|
cq.writeLine(fgBlack, styleBright, fmt"[{date}] [*] ", resetStyle, "Tasked agent to update sleep settings.")
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import argparse, times, strformat, terminal, nanoid
|
import argparse, times, strformat, terminal, nanoid
|
||||||
|
import ./commands/commands
|
||||||
import ../[types]
|
import ../[types]
|
||||||
import ./commands
|
|
||||||
|
|
||||||
#[
|
#[
|
||||||
Agent Argument parsing
|
Agent Argument parsing
|
||||||
@@ -17,6 +17,9 @@ var parser = newParser:
|
|||||||
help("Update sleep delay configuration.")
|
help("Update sleep delay configuration.")
|
||||||
arg("delay", help="Delay in seconds.", nargs = 1)
|
arg("delay", help="Delay in seconds.", nargs = 1)
|
||||||
|
|
||||||
|
command("info"):
|
||||||
|
help("Display agent information and current settings.")
|
||||||
|
|
||||||
command("help"):
|
command("help"):
|
||||||
nohelpflag()
|
nohelpflag()
|
||||||
|
|
||||||
@@ -52,6 +55,9 @@ proc handleAgentCommand*(cq: Conquest, args: varargs[string]) =
|
|||||||
of "sleep":
|
of "sleep":
|
||||||
cq.taskExecuteSleep(parseInt(opts.sleep.get.delay))
|
cq.taskExecuteSleep(parseInt(opts.sleep.get.delay))
|
||||||
|
|
||||||
|
of "info":
|
||||||
|
discard
|
||||||
|
|
||||||
# Handle help flag
|
# Handle help flag
|
||||||
except ShortCircuit as err:
|
except ShortCircuit as err:
|
||||||
if err.flag == "argparse_help":
|
if err.flag == "argparse_help":
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ var parser = newParser:
|
|||||||
help("List all active listeners.")
|
help("List all active listeners.")
|
||||||
command("start"):
|
command("start"):
|
||||||
help("Starts a new HTTP listener.")
|
help("Starts a new HTTP listener.")
|
||||||
option("-i", "--ip", default=some("localhost"), help="IPv4 address to listen on.", required=false)
|
option("-i", "--ip", default=some("127.0.0.1"), help="IPv4 address to listen on.", required=false)
|
||||||
option("-p", "--port", help="Port to listen on.", required=true)
|
option("-p", "--port", help="Port to listen on.", required=true)
|
||||||
|
|
||||||
# TODO: Future features:
|
# TODO: Future features:
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ proc timeSince*(agent: Agent, timestamp: DateTime): Cell =
|
|||||||
proc drawTable*(cq: Conquest, agents: seq[Agent]) =
|
proc drawTable*(cq: Conquest, agents: seq[Agent]) =
|
||||||
|
|
||||||
let headers: seq[string] = @["Name", "Address", "Username", "Hostname", "Operating System", "Process", "PID", "Activity"]
|
let headers: seq[string] = @["Name", "Address", "Username", "Hostname", "Operating System", "Process", "PID", "Activity"]
|
||||||
let widths = @[8, 15, 15, 15, 16, 15, 5, 13]
|
let widths = @[8, 15, 15, 15, 16, 15, 5, 8]
|
||||||
let headerCells = headers.mapIt(Cell(text: it, fg: fgWhite, bg: bgDefault))
|
let headerCells = headers.mapIt(Cell(text: it, fg: fgWhite, bg: bgDefault))
|
||||||
|
|
||||||
cq.writeLine(border(topLeft, topMid, topRight, widths))
|
cq.writeLine(border(topLeft, topMid, topRight, widths))
|
||||||
|
|||||||
Reference in New Issue
Block a user