TS API

Agent Functions

TsAgentIsExists

Checks if an agent exists by ID.

TsAgentIsExists(agentId string) bool
Parameter
Type
Description

agentId

string

Unique agent identifier

Returns: bool — true if agent exists


TsAgentCreate

Creates a new agent on first connection.

TsAgentCreate(agentCrc string, agentId string, beat []byte, listenerName string, ExternalIP string, Async bool) (adaptix.AgentData, error)
Parameter
Type
Description

agentCrc

string

CRC/watermark of agent type

agentId

string

Unique agent ID

beat

[]byte

Initial data from agent (heartbeat)

listenerName

string

Listener name

ExternalIP

string

Agent's external IP

Async

bool

Async mode

Returns: adaptix.AgentData, error

Events:

  • agent.new (Pre/Post hooks)


TsAgentProcessData

Processes data received from the agent.

Parameter
Type
Description

agentId

string

Agent ID

bodyData

[]byte

Data from agent

Note: If the agent has Mark="Inactive", it is automatically activated and the agent.activate event is called.


TsAgentUpdateData

Updates agent data (sleep, jitter, killdate, workingtime).


TsAgentUpdateDataPartial

Partial update of agent data.

Supported fields:

  • InternalIP, ExternalIP, GmtOffset, ACP, OemCP

  • Pid, Tid, Arch, Elevated, Process

  • Os, OsDesc, Domain, Computer, Username

  • Impersonated, Tags, Mark, Color


TsAgentTerminate

Terminates the agent.

Actions on call:

  1. Cancels all active downloads

  2. Stops all tunnels

  3. Closes terminals

  4. Clears task queues

  5. Removes pivot connections

Events:

  • agent.terminate (Pre/Post hooks)


TsAgentSetTick

Updates the agent's last response time and current listener.


TsAgentConsoleOutput

Outputs a message to the agent console.

Parameter
Type
Description

agentId

string

Agent ID

messageType

int

Message type (5=INFO, 6=ERROR, 7=SUCCESS)

message

string

Message title

clearText

string

Message text

store

bool

Store in DB


TsAgentBuildExecute

Executes an external command during agent build with output redirected to the WebSocket build channel.

Parameter
Type
Description

builderId

string

Builder ID (empty string for synchronous execution)

workingDir

string

Working directory for the command

program

string

Executable

args

...string

Command-line arguments

Note: If builderId is empty, the command executes synchronously without WebSocket output. Otherwise, stdout/stderr are redirected to the build channel.


TsAgentBuildLog

Sends a log message to the agent's WebSocket build channel.

Parameter
Type
Description

builderId

string

Builder ID

status

int

Status: BUILD_LOG_NONE=0, INFO=1, ERROR=2, SUCCESS=3

message

string

Message text


TsAgentGetHosted* Functions

Gets tasks for sending to the agent. All functions pack tasks considering size limitations.

TsAgentGetHostedAll

Gets all available tasks: regular tasks, tunnel tasks, tunnel data, and pivot tasks.

Parameter
Type
Description

agentId

string

Agent ID

maxDataSize

int

Maximum data size (bytes)

Returns: Packed task data for sending to the agent.

TsAgentGetHostedTasks

Gets only regular tasks and tunnel tasks (without pivot).

TsAgentGetHostedTasksCount

Gets the specified number of tasks.

Parameter
Type
Description

agentId

string

Agent ID

count

int

Maximum number of tasks

maxDataSize

int

Maximum data size (bytes)


Task Functions

TsTaskRunningExists

Checks if a task is running.


TsTaskCreate

Creates a new task.

Events:

  • task.create (Pre/Post hooks)


TsTaskUpdate

Updates the task with execution results.

Events:

  • task.complete (Post hook) — when task is completed


TsTaskCancel

Cancels a task that is in the queue (not yet sent to the agent).

Parameter
Type
Description

agentId

string

Agent ID

taskId

string

Task ID

Note: Cancels only tasks in the queue. Already running tasks cannot be cancelled.


Client GUI Functions

Functions for synchronizing data with GUI clients (File Browser, Process Manager). These functions send results only to the client that initiated the request.

TsClientGuiDisksWindows

Sends the list of Windows drives to the client.

Parameter
Type
Description

taskData

adaptix.TaskData

Task data

drives

[]adaptix.ListingDrivesDataWin

Drive list


TsClientGuiFilesWindows

Sends the list of Windows files to the client.

Parameter
Type
Description

taskData

adaptix.TaskData

Task data

path

string

Directory path

files

[]adaptix.ListingFileDataWin

File list


TsClientGuiFilesUnix

Sends the list of Unix/Linux files to the client.

Parameter
Type
Description

taskData

adaptix.TaskData

Task data

path

string

Directory path

files

[]adaptix.ListingFileDataUnix

File list


TsClientGuiFilesStatus

Sends the file operation status (delete, rename, etc.) to the client.

Parameter
Type
Description

taskData

adaptix.TaskData

Task data with MessageType and Message for status


TsClientGuiProcessWindows

Sends the list of Windows processes to the client.

Parameter
Type
Description

taskData

adaptix.TaskData

Task data

process

[]adaptix.ListingProcessDataWin

Process list


TsClientGuiProcessUnix

Sends the list of Unix/Linux processes to the client.

Parameter
Type
Description

taskData

adaptix.TaskData

Task data

process

[]adaptix.ListingProcessDataUnix

Process list


Credentials Functions

TsCredentilsAdd

Adds credentials.

Credential structure:

Events:

  • credentials.add (Pre/Post hooks)


TsCredentilsEdit

Events:

  • credentials.edit (Pre/Post hooks)


TsCredentialsSetTag


TsCredentilsDelete

Events:

  • credentials.remove (Pre/Post hooks)


Download/Upload Functions

TsDownloadAdd

Initializes a file download.

Events:

  • download.start (Pre/Post hooks)


TsDownloadUpdate

Updates download state.

State
Value
Description

1

RUNNING

Download in progress

2

STOPPED

Paused

3

FINISHED

Completed

4

CANCELED

Cancelled


TsDownloadClose

Finishes a download.

Events:

  • download.finish (Pre/Post hooks)


TsDownloadSave

Saves a file directly (from memory).


TsDownloadGetFilepath

Returns the local path to the downloaded file.

Parameter
Type
Description

fileId

string

File ID

Returns: Full path to the file on the server.

Note: Works only for completed downloads (state=FINISHED).


TsDownloadDelete

Deletes downloaded files.

Parameter
Type
Description

fileId

[]string

List of file IDs

Actions:

  1. Deletes files from disk

  2. Removes records from DB

  3. Synchronizes with clients

Events:

  • download.remove (Pre/Post hooks)


Listener Functions

TsListenerGetProfile

Gets a profile for agent generation.

Returns: watermark, profile bytes, error


TsListenerInteralHandler

Handles internal requests (pivot agents).


Pivot Functions

TsPivotCreate

Creates a pivot connection.

Events:

  • pivot.create (Pre/Post hooks)


TsPivotDelete

Events:

  • pivot.remove (Pre/Post hooks)


TsGetPivotInfoByName / TsGetPivotInfoById


TsGetPivotByName / TsGetPivotById


Screenshot Functions

TsScreenshotAdd

Adds a screenshot.

Events:

  • screenshot.add (Pre/Post hooks)


TsScreenshotNote

Updates the note for a screenshot.

Parameter
Type
Description

screenId

string

Screenshot ID

note

string

Note text


TsScreenshotDelete

Deletes a screenshot.

Parameter
Type
Description

screenId

string

Screenshot ID

Actions:

  1. Deletes the file from disk

  2. Removes the record from the DB

  3. Synchronizes with clients

Events:

  • screenshot.remove (Pre/Post hooks)


Target Functions

TsTargetsAdd

Adds new targets (hosts). Duplicates are automatically ignored.

Target structure:

Events:

  • target.add (Pre/Post hooks)


TsTargetsEdit

Edits an existing target.

Parameter
Type
Description

targetId

string

Target ID

computer

string

Computer name

domain

string

Domain

address

string

IP address

os

int

OS type (1/2/3)

osDesk

string

OS description

tag

string

Tag

info

string

Additional info

alive

bool

Alive

Events:

  • target.edit (Pre/Post hooks)


TsTargetSetTag

Sets a tag for a group of targets.

Parameter
Type
Description

targetsId

[]string

List of target IDs

tag

string

New tag


TsTargetDelete

Deletes targets.

Parameter
Type
Description

targetsId

[]string

List of target IDs

Events:

  • target.remove (Pre/Post hooks)


Tunnel Functions

TsTunnelStart

Starts the created tunnel.

Parameter
Type
Description

TunnelId

string

Tunnel ID

Returns: TaskId for tracking

Events:

  • tunnel.start (Pre/Post hooks)


TsTunnelCreate* Functions

Functions for creating tunnels of different types. Return TunnelId.

TsTunnelCreateSocks4

Creates a SOCKS4 proxy.

Parameter
Type
Description

AgentId

string

Agent ID

Info

string

Tunnel description

Lhost

string

Bind address

Lport

int

Bind port

TsTunnelCreateSocks5

Creates a SOCKS5 proxy with optional authentication.

Parameter
Type
Description

AgentId

string

Agent ID

Info

string

Tunnel description

Lhost

string

Bind address

Lport

int

Bind port

UseAuth

bool

Use authentication

Username

string

Username (if UseAuth)

Password

string

Password (if UseAuth)

TsTunnelCreateLportfwd

Creates a local port forward.

Parameter
Type
Description

AgentId

string

Agent ID

Info

string

Tunnel description

Lhost

string

Local address

Lport

int

Local port

Thost

string

Target address (on agent)

Tport

int

Target port

TsTunnelCreateRportfwd

Creates a reverse port forward.

Parameter
Type
Description

AgentId

string

Agent ID

Info

string

Tunnel description

Lport

int

Port on agent

Thost

string

Target address (on server)

Tport

int

Target port


TsTunnelUpdateRportfwd

Updates reverse port forward status after the agent response.

Parameter
Type
Description

tunnelId

int

Tunnel ID (numeric)

result

bool

Whether the tunnel was created on the agent

Returns: TaskId, message, error


TsTunnelStop* Functions

Functions for stopping tunnels.

TsTunnelStop

Stops a tunnel by ID.

Events:

  • tunnel.stop (Pre/Post hooks)

TsTunnelStopSocks

Stops a SOCKS proxy by agent and port.

TsTunnelStopLportfwd

Stops a local port forward.

TsTunnelStopRportfwd

Stops a reverse port forward. Sends a close command to the agent.


TsTunnelChannelExists

Checks whether the tunnel channel exists.


TsTunnelGetPipe

Gets pipes for reading/writing tunnel data.

Parameter
Type
Description

AgentId

string

Agent ID

channelId

int

Channel ID

Returns: PipeReader for reading data from the server, PipeWriter for writing data to the tunnel.


TsTunnelConnection* Functions

Functions for managing tunnel connections.

TsTunnelConnectionData

Sends data to the tunnel channel.

TsTunnelConnectionResume

Resumes the connection after a successful connection on the agent side.

Parameter
Type
Description

AgentId

string

Agent ID

channelId

int

Channel ID

ioDirect

bool

true = direct transfer without buffering

TsTunnelConnectionClose

Closes the channel connection.

TsTunnelConnectionHalt

Closes the connection with a SOCKS error.

Parameter
Type
Description

channelId

int

Channel ID

errorCode

byte

SOCKS5 error code (1-8)

TsTunnelConnectionAccept

Accepts an incoming connection for reverse port forward.


Terminal Functions

Functions for managing interactive terminal sessions via the agent.

TsAgentTerminalCloseChannel

Closes the terminal channel and notifies the client.

Parameter
Type
Description

terminalId

string

Terminal session ID

status

string

Close status/reason


TsTerminalConnExists

Checks whether a terminal connection exists.

Parameter
Type
Description

terminalId

string

Terminal session ID

Returns: true if the session exists


TsTerminalConnResume

Resumes the terminal connection after a successful start on the agent.

Parameter
Type
Description

agentId

string

Agent ID

terminalId

string

Terminal session ID

ioDirect

bool

true = direct transfer without buffering


TsTerminalConnData

Sends data to the terminal session (output from the agent).

Parameter
Type
Description

terminalId

string

Terminal session ID

data

[]byte

Data to send


TsTerminalConnClose

Closes the terminal session.

Parameter
Type
Description

terminalId

string

Terminal session ID

reason

string

Close reason


TsTerminalGetPipe

Gets pipes for terminal input/output.

Parameter
Type
Description

AgentId

string

Agent ID

terminalId

string

Terminal session ID

Returns: PipeReader for reading input from the client, PipeWriter for writing agent output.


Service Functions

TsServiceSendDataAll

Sends data to all clients on behalf of the service.


TsServiceSendDataClient

Sends data to a specific client on behalf of the service.


Extender Data Functions

Functions for storing extender data in the database.

TsExtenderDataSave

Saves extender data to the database.


TsExtenderDataLoad

Loads extender data from the database.


TsExtenderDataDelete

Deletes data by key from the database.


TsExtenderDataKeys

Returns a list of saved extender keys.


TsExtenderDataDeleteAll

Deletes all extender data from the database.


Endpoint Functions

Functions for registering HTTP endpoints.

TsEndpointRegister

Registers a protected endpoint (uses the teamserver's shared JWT authentication).

Parameter
Type
Description

method

string

HTTP method (GET, POST...)

path

string

Endpoint path

handler

func(username string, body []byte) (int, []byte)

Handler

Handler parameters:

  • username — authenticated username

  • body — request body

Handler returns:

  • int — HTTP status code

  • []byte — response body


TsEndpointUnregister

Unregisters an endpoint.


TsEndpointExists

Checks whether an endpoint exists.


TsEndpointRegisterPublic

Registers a public endpoint (no authentication).

Parameter
Type
Description

method

string

HTTP method (GET, POST...)

path

string

Endpoint path

handler

func(body []byte) (int, []byte)

Handler


TsEndpointUnregisterPublic

Unregisters a public endpoint.


TsEndpointExistsPublic

Checks whether a public endpoint exists.


Utility Functions

TsConvertCpToUTF8

Converts a string from a code page to UTF-8.

Supported code pages:

  • 866 (Russian DOS)

  • 1251 (Cyrillic Windows)

  • 1252 (Western European Windows)

  • 936 (Chinese GBK)

  • 65001 (UTF-8)

  • and many others...


TsConvertUTF8toCp

Converts UTF-8 to the agent's code page.


TsWin32Error

Returns a description of a Windows error code.


Data Types

adaptix.AgentData


adaptix.TaskData


adaptix.ListenerData


adaptix.DownloadData


adaptix.TunnelData


adaptix.PivotData


adaptix.CredsData


adaptix.TargetData


Constants

Last updated