2025-09-25 19:22:17 +02:00
|
|
|
import whisky
|
2025-09-27 13:54:12 +02:00
|
|
|
import times, tables, json
|
|
|
|
|
import ../common/[types, utils, serialize, event]
|
|
|
|
|
export sendHeartbeat, recvEvent
|
2025-09-25 19:22:17 +02:00
|
|
|
|
|
|
|
|
#[
|
|
|
|
|
Client -> Server
|
|
|
|
|
]#
|
|
|
|
|
proc sendStartListener*(ws: WebSocket, listener: UIListener) =
|
2025-09-27 13:54:12 +02:00
|
|
|
let event = Event(
|
|
|
|
|
eventType: CLIENT_LISTENER_START,
|
|
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %listener
|
|
|
|
|
)
|
|
|
|
|
ws.sendEvent(event)
|
2025-09-25 19:22:17 +02:00
|
|
|
|
|
|
|
|
proc sendStopListener*(ws: WebSocket, listenerId: string) =
|
2025-09-27 13:54:12 +02:00
|
|
|
let event = Event(
|
|
|
|
|
eventType: CLIENT_LISTENER_STOP,
|
|
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %*{
|
|
|
|
|
"listenerId": listenerId
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
ws.sendEvent(event)
|
2025-09-25 19:22:17 +02:00
|
|
|
|
2025-09-27 15:18:45 +02:00
|
|
|
proc sendAgentBuild*(ws: WebSocket, buildInformation: AgentBuildInformation) =
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
ws.sendEvent(event)
|
|
|
|
|
|
2025-09-27 17:45:52 +02:00
|
|
|
proc sendAgentCommand*(ws: WebSocket, agentId: string, command: string) =
|
|
|
|
|
let event = Event(
|
|
|
|
|
eventType: CLIENT_AGENT_COMMAND,
|
|
|
|
|
timestamp: now().toTime().toUnix(),
|
|
|
|
|
data: %*{
|
|
|
|
|
"agentId": agentId,
|
|
|
|
|
"command": command
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
ws.sendEvent(event)
|