Impersonated user is displayed in the client UI and persisted in the team server database.

This commit is contained in:
Jakob Friedl
2025-10-17 13:01:12 +02:00
parent 0fc8ff3caa
commit 4a1a70da4d
11 changed files with 95 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ proc `%`*(agent: Agent): JsonNode =
result["agentId"] = %agent.agentId
result["listenerId"] = %agent.listenerId
result["username"] = %agent.username
result["impersonationToken"] = %agent.impersonationToken
result["hostname"] = %agent.hostname
result["domain"] = %agent.domain
result["ipInternal"] = %agent.ipInternal
@@ -188,5 +189,28 @@ proc sendLootData*(client: WsConnection, loot: LootItem, data: string) =
"data": encode(data)
}
)
if client != nil:
client.ws.sendEvent(event, client.sessionKey)
proc sendImpersonateToken*(client: WsConnection, agentId: string, username: string) =
let event = Event(
eventType: CLIENT_IMPERSONATE_TOKEN,
timestamp: now().toTime().toUnix(),
data: %*{
"agentId": agentId,
"username": username
}
)
if client != nil:
client.ws.sendEvent(event, client.sessionKey)
proc sendRevertToken*(client: WsConnection, agentId: string) =
let event = Event(
eventType: CLIENT_REVERT_TOKEN,
timestamp: now().toTime().toUnix(),
data: %*{
"agentId": agentId
}
)
if client != nil:
client.ws.sendEvent(event, client.sessionKey)