2025-09-25 19:22:17 +02:00
|
|
|
import whisky
|
2025-10-01 21:57:26 +02:00
|
|
|
import times, tables, json, base64
|
2025-10-03 12:44:28 +02:00
|
|
|
import ../../common/[types, utils, serialize, event]
|
2025-09-27 13:54:12 +02:00
|
|
|
export sendHeartbeat, recvEvent
|
2025-09-25 19:22:17 +02:00
|
|
|
|
|
|
|
|
#[
|
|
|
|
|
Client -> Server
|
|
|
|
|
]#
|
2025-10-01 21:57:26 +02:00
|
|
|
proc sendPublicKey*(connection: WsConnection, publicKey: Key) =
|
|
|
|
|
let event = Event(
|
|
|
|
|
eventType: CLIENT_KEY_EXCHANGE,
|
|
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %*{
|
|
|
|
|
"publicKey": encode(Bytes.toString(publicKey))
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
connection.ws.sendEvent(event, connection.sessionKey)
|
|
|
|
|
|
|
|
|
|
proc sendStartListener*(connection: WsConnection, listener: UIListener) =
|
2025-09-27 13:54:12 +02:00
|
|
|
let event = Event(
|
|
|
|
|
eventType: CLIENT_LISTENER_START,
|
|
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %listener
|
|
|
|
|
)
|
2025-10-01 21:57:26 +02:00
|
|
|
connection.ws.sendEvent(event, connection.sessionKey)
|
2025-09-25 19:22:17 +02:00
|
|
|
|
2025-10-01 21:57:26 +02:00
|
|
|
proc sendStopListener*(connection: WsConnection, listenerId: string) =
|
2025-09-27 13:54:12 +02:00
|
|
|
let event = Event(
|
|
|
|
|
eventType: CLIENT_LISTENER_STOP,
|
|
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %*{
|
|
|
|
|
"listenerId": listenerId
|
|
|
|
|
}
|
|
|
|
|
)
|
2025-10-01 21:57:26 +02:00
|
|
|
connection.ws.sendEvent(event, connection.sessionKey)
|
2025-09-25 19:22:17 +02:00
|
|
|
|
2025-10-01 21:57:26 +02:00
|
|
|
proc sendAgentBuild*(connection: WsConnection, buildInformation: AgentBuildInformation) =
|
2025-09-27 15:18:45 +02:00
|
|
|
let event = Event(
|
|
|
|
|
eventType: CLIENT_AGENT_BUILD,
|
|
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %*{
|
|
|
|
|
"listenerId": buildInformation.listenerId,
|
|
|
|
|
"sleepDelay": buildInformation.sleepDelay,
|
|
|
|
|
"sleepTechnique": cast[uint8](buildInformation.sleepTechnique),
|
|
|
|
|
"spoofStack": buildInformation.spoofStack,
|
|
|
|
|
"modules": buildInformation.modules
|
|
|
|
|
}
|
|
|
|
|
)
|
2025-10-01 21:57:26 +02:00
|
|
|
connection.ws.sendEvent(event, connection.sessionKey)
|
2025-09-27 15:18:45 +02:00
|
|
|
|
2025-10-02 13:51:04 +02:00
|
|
|
proc sendAgentTask*(connection: WsConnection, agentId: string, command: string, task: Task) =
|
2025-09-27 17:45:52 +02:00
|
|
|
let event = Event(
|
2025-09-30 10:04:29 +02:00
|
|
|
eventType: CLIENT_AGENT_TASK,
|
2025-09-27 17:45:52 +02:00
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %*{
|
|
|
|
|
"agentId": agentId,
|
2025-10-02 13:51:04 +02:00
|
|
|
"command": command,
|
2025-09-30 10:04:29 +02:00
|
|
|
"task": task
|
2025-09-27 17:45:52 +02:00
|
|
|
}
|
|
|
|
|
)
|
2025-10-01 21:57:26 +02:00
|
|
|
connection.ws.sendEvent(event, connection.sessionKey)
|