Implemented sleep command to update sleep delay on agent
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import ./commands/[shell]
|
||||
export shell
|
||||
import ./commands/[shell, sleep]
|
||||
export shell, sleep
|
||||
|
||||
#[
|
||||
"Monarch" Agent commands:
|
||||
|
||||
21
server/agent/commands/sleep.nim
Normal file
21
server/agent/commands/sleep.nim
Normal file
@@ -0,0 +1,21 @@
|
||||
import nanoid, sequtils, strutils, strformat, terminal, times
|
||||
import ../../types
|
||||
|
||||
proc taskExecuteSleep*(cq: Conquest, delay: int) =
|
||||
|
||||
# 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: Sleep,
|
||||
args: @[$delay],
|
||||
result: "",
|
||||
status: Created
|
||||
)
|
||||
|
||||
# Add new task to the agent's task queue
|
||||
cq.interactAgent.tasks.add(task)
|
||||
|
||||
cq.writeLine(fgBlack, styleBright, fmt"[*] [{task.id}] ", resetStyle, "Tasked agent to update sleep settings.")
|
||||
@@ -13,6 +13,10 @@ var parser = newParser:
|
||||
arg("command", help="Command", nargs = 1)
|
||||
arg("arguments", help="Arguments.", nargs = -1) # Handle 0 or more command-line arguments (seq[string])
|
||||
|
||||
command("sleep"):
|
||||
help("Update sleep delay configuration.")
|
||||
arg("delay", help="Delay in seconds.", nargs = 1)
|
||||
|
||||
command("help"):
|
||||
nohelpflag()
|
||||
|
||||
@@ -44,7 +48,9 @@ proc handleAgentCommand*(cq: Conquest, args: varargs[string]) =
|
||||
arguments: seq[string] = opts.shell.get.arguments
|
||||
arguments.insert(command, 0)
|
||||
cq.taskExecuteShell(arguments)
|
||||
|
||||
|
||||
of "sleep":
|
||||
cq.taskExecuteSleep(parseInt(opts.sleep.get.delay))
|
||||
|
||||
# Handle help flag
|
||||
except ShortCircuit as err:
|
||||
@@ -52,6 +58,6 @@ proc handleAgentCommand*(cq: Conquest, args: varargs[string]) =
|
||||
cq.writeLine(err.help)
|
||||
|
||||
# Handle invalid arguments
|
||||
except UsageError:
|
||||
except CatchableError:
|
||||
cq.writeLine(fgRed, styleBright, "[-] ", getCurrentExceptionMsg(), "\n")
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ var parser = newParser:
|
||||
help("Generate a new agent to connect to an active listener.")
|
||||
option("-l", "--listener", help="Name of the listener.", required=true)
|
||||
option("-s", "--sleep", help="Sleep delay in seconds.", default=some("10") )
|
||||
option("-p", "--payload", help="Agent type", choices = @["monarch"], default=some("monarch"))
|
||||
option("-p", "--payload", help="Agent type.\n\t\t\t ", default=some("monarch"), choices = @["monarch"],)
|
||||
|
||||
command("help"):
|
||||
nohelpflag()
|
||||
|
||||
@@ -14,6 +14,7 @@ type
|
||||
ExecuteBof = "bof"
|
||||
ExecuteAssembly = "dotnet"
|
||||
ExecutePe = "pe"
|
||||
Sleep = "sleep"
|
||||
|
||||
TaskStatus* = enum
|
||||
Created = "created"
|
||||
|
||||
Reference in New Issue
Block a user