Added profile system to agent communication. Randomized URL endpoints/request methods and dynamic data transformation based on C2 profile. Profile is defined as compile-time string for now.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import parsetoml, strutils
|
||||
import parsetoml, strutils, random
|
||||
import ./[types, utils]
|
||||
|
||||
proc findKey(profile: Profile, path: string): TomlValueRef =
|
||||
@@ -41,3 +41,14 @@ proc getTable*(profile: Profile, path: string): TomlTableRef =
|
||||
if key == nil:
|
||||
return new TomlTableRef
|
||||
return key.getTable()
|
||||
|
||||
proc getArray*(profile: Profile, path: string): seq[TomlValueRef] =
|
||||
let key = profile.findKey(path)
|
||||
if key == nil:
|
||||
return @[]
|
||||
return key.getElems()
|
||||
|
||||
proc getRandom*(values: seq[TomlValueRef]): TomlValueRef =
|
||||
if values.len == 0:
|
||||
return nil
|
||||
return values[rand(values.len - 1)]
|
||||
@@ -176,7 +176,7 @@ type
|
||||
|
||||
# Agent config
|
||||
type
|
||||
AgentConfig* = ref object
|
||||
AgentCtx* = ref object
|
||||
agentId*: string
|
||||
listenerId*: string
|
||||
ip*: string
|
||||
@@ -184,6 +184,7 @@ type
|
||||
sleep*: int
|
||||
sessionKey*: Key
|
||||
agentPublicKey*: Key
|
||||
profile*: Profile
|
||||
|
||||
# Structure for command module definitions
|
||||
type
|
||||
@@ -200,4 +201,4 @@ type
|
||||
example*: string
|
||||
arguments*: seq[Argument]
|
||||
dispatchMessage*: string
|
||||
execute*: proc(config: AgentConfig, task: Task): TaskResult {.nimcall.}
|
||||
execute*: proc(config: AgentCtx, task: Task): TaskResult {.nimcall.}
|
||||
Reference in New Issue
Block a user