Events and Hooks

The AdaptixC2 TeamServer event system allows plugins to react to various actions in the system: agent connections, task execution, tunnel creation, etc.

Architecture

Concept
Description

Event

Notification about an action in the system

Hook

Event handler function

Phase

Execution phase: Pre (before) or Post (after)

Priority

Execution priority (lower = earlier)

Timeout

Maximum hook execution time

Hook Phases

The event system supports two hook phases with fundamentally different capabilities.

Pre Hooks (Phase: Pre)

Pre hooks execute before the main action is performed. They have full control over the event:

Capability
Description

Modify data

Can modify event data before the action executes. Changes are passed to subsequent hooks and the action itself

Cancel event

Can completely cancel the event by returning an error. The action will not be executed

Validate

Can validate input data and reject invalid requests

Synchronous

Execute sequentially in priority order. Block the action until all Pre hooks complete

Timeout

5 seconds maximum execution time per hook

Use cases:

  • Input validation (reject agents from specific IP ranges)

  • Data enrichment (add tags, modify parameters)

  • Access control (block certain operations)

  • Data transformation before processing

Post Hooks (Phase: Post)

Post hooks execute after the main action has completed. They are read-only observers:

Capability
Description

Read-only

Receive a copy of the event data. Modifications have no effect on the system

Cannot cancel

The action has already been executed. Returning an error only logs a warning

Asynchronous

Execute in parallel via worker pool. Do not block the main flow

Timeout

30 seconds maximum execution time per hook

Use cases:

  • Notifications (Telegram, Slack, email)

  • Logging and analytics

  • External integrations

  • Metrics collection

Comparison Table

Feature
Pre Hook
Post Hook

Execution time

Before action

After action

Can modify data

✅ Yes

❌ No (read-only copy)

Can cancel event

✅ Yes (return error)

❌ No

Execution mode

Synchronous

Asynchronous

Blocks main flow

✅ Yes

❌ No

Timeout

5 seconds

30 seconds

Error handling

Cancels event

Logs warning

Priorities

Hooks are executed in order of priority (lower value = earlier):

Priority
Recommended usage

1-10

Critical validators

10-50

Data modifiers

50-100

Standard processing

100+

Logging, monitoring

Event Types

Client Events

Event Type
Description
Data

client.connect

Client GUI connection

EventDataClientConnect

client.disconnect

Client GUI disconnection

EventDataClientDisconnect

Agent Events

Event Type
Description
Data

agent.new

New agent connected

EventDataAgentNew

agent.generate

Agent payload generation

EventDataAgentGenerate

agent.checkin

Agent check-in (heartbeat)

EventDataAgentCheckin

agent.activate

Agent activated (from Inactive)

EventDataAgentActivate

agent.update

Agent data update

EventDataAgentUpdate

agent.terminate

Agent terminated

EventDataAgentTerminate

agent.remove

Agent removed

EventDataAgentRemove

Listener Events

Event Type
Description
Data

listener.start

Listener started (start/resume)

EventDataListenerStart

listener.stop

Listener stopped (stop/pause)

EventDataListenerStop

Task Events

Event Type
Description
Data

task.create

Task creation

EventDataTaskCreate

task.start

Task start

EventDataTaskStart

task.update_job

Background task update

EventDataTaskUpdateJob

task.complete

Task completion

EventDataTaskComplete

Credentials Events

Event Type
Description
Data

credentials.add

Credentials added

EventCredentialsAdd

credentials.edit

Credentials edited

EventCredentialsEdit

credentials.remove

Credentials removed

EventCredentialsRemove

Download Events

Event Type
Description
Data

download.start

Download started

EventDataDownloadStart

download.finish

Download finished

EventDataDownloadFinish

download.remove

Download removed

EventDataDownloadRemove

Screenshot Events

Event Type
Description
Data

screenshot.add

Screenshot added

EventDataScreenshotAdd

screenshot.remove

Screenshot removed

EventDataScreenshotRemove

Tunnel Events

Event Type
Description
Data

tunnel.start

Tunnel started

EventDataTunnelStart

tunnel.stop

Tunnel stopped

EventDataTunnelStop

Target Events

Event Type
Description
Data

target.add

Target added

EventDataTargetAdd

target.edit

Target edited

EventDataTargetEdit

target.remove

Target removed

EventDataTargetRemove

Pivot Events

Event Type
Description
Data

pivot.create

Pivot connection created

EventDataPivotCreate

pivot.remove

Pivot connection removed

EventDataPivotRemove


Hook Registration

TsEventHookRegister

Full registration with all parameters specified.

Example:

TsEventHookOnPre / TsEventHookOnPost

Simplified registration for Pre/Post hooks.

TsEventHookUnregister

Unregister a hook by ID.

TsEventHookUnregisterByName

Unregister all hooks with the specified name.


Event Data Structures

BaseEvent

Base structure embedded in all events.

Client Events

Agent Events

Listener Events

Task Events

Credentials Events

Download Events

Screenshot Events

Tunnel Events

Target Events

Pivot Events


Usage Examples

Example 1: Event Logger

Example 2: IP Blacklist Validator (Pre Hook)

Example 3: Auto-Tagger

Example 4: Webhook Integration


Best Practices

1. Error Handling

2. Asynchronous Processing in Post Hooks

3. Correct Usage of Pre Hooks

4. Unique Hook Names

5. Priorities

6. Timeouts

  • Pre hooks: 5 seconds (short operations)

  • Post hooks: executed in a separate thread, 30 seconds (you can do external requests)

If a hook exceeds the timeout, it is interrupted with an error.


Constants

Last updated