Implemented 'pwd' command to retrieve working directory.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import ./[shell, sleep]
|
||||
export shell, sleep
|
||||
import ./[shell, sleep, pwd]
|
||||
export shell, sleep, pwd
|
||||
|
||||
#[
|
||||
"Monarch" Agent commands:
|
||||
|
||||
19
server/agent/commands/pwd.nim
Normal file
19
server/agent/commands/pwd.nim
Normal file
@@ -0,0 +1,19 @@
|
||||
import nanoid, sequtils, strutils, strformat, terminal, times
|
||||
import ../../types
|
||||
|
||||
proc taskGetWorkingDirectory*(cq: Conquest) =
|
||||
|
||||
# Create a new task
|
||||
let
|
||||
date: string = now().format("dd-MM-yyyy HH:mm:ss")
|
||||
task = Task(
|
||||
id: generate(alphabet=join(toSeq('A'..'Z'), ""), size=8),
|
||||
agent: cq.interactAgent.name,
|
||||
command: GetWorkingDirectory,
|
||||
args: @[],
|
||||
)
|
||||
|
||||
# Add new task to the agent's task queue
|
||||
cq.interactAgent.tasks.add(task)
|
||||
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[{date}] [*] ", resetStyle, "Tasked agent to get current working directory.")
|
||||
@@ -20,6 +20,9 @@ var parser = newParser:
|
||||
command("info"):
|
||||
help("Display agent information and current settings.")
|
||||
|
||||
command("pwd"):
|
||||
help("Retrieve current working directory")
|
||||
|
||||
command("help"):
|
||||
nohelpflag()
|
||||
|
||||
@@ -58,6 +61,9 @@ proc handleAgentCommand*(cq: Conquest, args: varargs[string]) =
|
||||
of "info":
|
||||
discard
|
||||
|
||||
of "pwd":
|
||||
cq.taskGetWorkingDirectory()
|
||||
|
||||
# Handle help flag
|
||||
except ShortCircuit as err:
|
||||
if err.flag == "argparse_help":
|
||||
|
||||
@@ -15,6 +15,7 @@ type
|
||||
ExecuteAssembly = "dotnet"
|
||||
ExecutePe = "pe"
|
||||
Sleep = "sleep"
|
||||
GetWorkingDirectory = "pwd"
|
||||
|
||||
TaskStatus* = enum
|
||||
Completed = "completed"
|
||||
|
||||
@@ -139,7 +139,7 @@ proc timeSince*(agent: Agent, timestamp: DateTime): Cell =
|
||||
proc drawTable*(cq: Conquest, agents: seq[Agent]) =
|
||||
|
||||
let headers: seq[string] = @["Name", "Address", "Username", "Hostname", "Operating System", "Process", "PID", "Activity"]
|
||||
let widths = @[8, 15, 15, 15, 16, 15, 5, 8]
|
||||
let widths = @[8, 15, 15, 15, 16, 13, 5, 8]
|
||||
let headerCells = headers.mapIt(Cell(text: it, fg: fgWhite, bg: bgDefault))
|
||||
|
||||
cq.writeLine(border(topLeft, topMid, topRight, widths))
|
||||
|
||||
Reference in New Issue
Block a user