> For the complete documentation index, see [llms.txt](https://adaptix-framework.gitbook.io/adaptix-framework/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adaptix-framework.gitbook.io/adaptix-framework/development/axscript/axfunction.md).

# AxFunction

## Data Model

### agents

Get information about all agents calling back to this Adaptix teamserver.

```javascript
AGENT[id] ax.agents();
```

```javascript
// AGENT STRUCT
int    agent["id"]
string agent["type"]
string agent["listener"]
string agent["external_ip"]
string agent["internal_ip"]
string agent["domain"]
string agent["computer"]
string agent["username"]
string agent["impersonated"]
string agent["process"]
string agent["arch"]
int    agent["pid"]
int    agent["tid"]
int    agent["gmt"]
int    agent["acp"]
int    agent["oemcp"]
bool   agent["elevated"]
string agent["tags"]
bool   agent["async"]
int    agent["sleep"]
string agent["os"]
string agent["os_full"]
```

<details>

<summary>Example</summary>

```javascript
var agents = ax.agents(); 

for (var id in agents) {
    ax.log("Agent ID: " + id);
    var agent = agents[id];
    for (var key in agent) {
        ax.log("  " + key + ": " + agent[key]);
    }
}
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-06a95e3be202d2ab26754b874bdd34647f5e3442%2FScreenshot_20250726_223045.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### credentials

Returns a list of credentials.

```javascript
CRED[id] ax.credentials()
```

```javascript
// CRED STRUCT
int    cred["id"]
string cred["username"]
string cred["password"]
string cred["realm"]
string cred["type"]
string cred["tag"]
string cred["date"]
string cred["storage"]
int    cred["agent_id"]
string cred["host"]
```

<details>

<summary>Example</summary>

```javascript
var creds = ax.credentials(); 

for (var id in creds) {
    ax.log("Cred ID: " + id);
    var cred = creds[id];
    for (var key in cred) {
        ax.log("  " + key + ": " + cred[key]);
    }
}
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-8054f15aaad8734bdec247290c57282b2d486b20%2FScreenshot_20250726_223225.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### downloads

Returns a list of downloads.

```javascript
DOWNLOAD[id] ax.downloads()
```

```javascript
// DOWNLOAD STRUCT
int    download["id"]
int    download["agent_id"]
string download["agent_name"]
string download["user"]
string download["computer"]
string download["filename"]
int    download["recv_size"]
int    download["total_size"]
string download["date"]
string download["state"]       // "running" | "stopped" | "finished" | "canceled"
```

<details>

<summary>Example</summary>

```javascript
var downloads = ax.downloads();

for (var id in downloads) {
    ax.log("Download ID: " + id);
    var dw = downloads[id];
    for (var key in dw) {
        ax.log("  " + key + ": " + dw[key]);
    }
}
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-f8707573c66e3d0478032ab2a24221e19eeb8b32%2FScreenshot_20250828_135048.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### payloads

Returns the payloads stored on the teamserver. The client returns an object keyed by the payload id. The teamserver returns an array of objects.

```javascript
PAYLOAD[id] ax.payloads();
```

```javascript
// PAYLOAD STRUCT
int      payload["id"]
string   payload["name"]
string   payload["description"]
string   payload["type"]
string   payload["artifact"]
string   payload["arch"]
string[] payload["listeners"]
int      payload["size"]
string   payload["creator"]
int      payload["created"]
string   payload["filename"]
string   payload["md5"]
string   payload["sha1"]
string   payload["sha256"]
string   payload["tag"]       // client only. not present on the teamserver object
string   payload["uid"]
bool     payload["hidden"]
bool     payload["missing"]   // client only. not present on the teamserver object
```

The client reads `p_id` from JSON through a JavaScript number, so an id above 2^53 is already rounded before it becomes the object key.

<details>

<summary>Example</summary>

```javascript
var payloads = ax.payloads();

for (var id in payloads) {
    ax.log("Payload ID: " + id);
    var payload = payloads[id];
    for (var key in payload) {
        ax.log("  " + key + ": " + payload[key]);
    }
}
```

</details>

***

### screenshots

Returns a list of screenshots.

```javascript
SCREEN[id] ax.screenshots()
```

```javascript
// SCREEN STRUCT
int    screen["id"]
string screen["user"]
string screen["computer"]
string screen["note"]
string screen["date"]
```

<details>

<summary>Example</summary>

```javascript
var screenshots = ax.screenshots();

for (var id in screenshots) {
    ax.log("Screen ID: " + id);
    var screen = screenshots[id];
    for (var key in screen) {
        ax.log("  " + key + ": " + screen[key]);
    }
}
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-a12113e0cbbe8c73287cd100fd9862c9710a8a7e%2FScreenshot_20250828_135629.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### targets

Returns a list of targets.

```javascript
TARGET[id] ax.targets()
```

```javascript
// TARGET STRUCT
int    target["id"]
string target["computer"]
string target["domain"]
string target["address"]
string target["tag"]
string target["date"]
string target["info"]
bool   target["alive"]
int[]  target["agents"]    // client: array of linked agent ids. not present on the teamserver JSON
string target["os"]        // client: "windows" | "linux" | "macos" | "unknown"
string target["os_desc"]
```

<details>

<summary>Example</summary>

```javascript
var targets = ax.targets();

for (var id in targets) {
    ax.log("Target ID: " + id);
    var targ = targets[id];
    for (var key in targ) {
        ax.log("  " + key + ": " + targ[key]);
    }
}
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-85811c78d3e22fe1c50c43a341a1bbc9acb311f1%2FScreenshot_20250828_135948.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### tunnels

Returns a list of tunnels.

```javascript
TUNNEL[id] ax.tunnels()
```

```javascript
// TUNNEL STRUCT
int    tunnel["id"]
int    tunnel["agent_id"]
string tunnel["username"]
string tunnel["computer"]
string tunnel["process"]
string tunnel["type"]
string tunnel["info"]
string tunnel["interface"]
string tunnel["port"]
string tunnel["client"]
string tunnel["f_port"]
string tunnel["f_host"]
```

<details>

<summary>Example</summary>

```javascript
var tunnels = ax.tunnels();

for (var id in tunnels) {
    ax.log("Tunn ID: " + id);
    var tun = tunnels[id];
    for (var key in tun) {
        ax.log("  " + key + ": " + tun[key]);
    }
}
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-8d3ad266bfd9c3fbd470e340616c55699462b6ac%2FScreenshot_20250828_140330.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

## Functions

The following is a list of AxScript's functions:

### agents

[See here](#agents)

***

### agent\_get\_command\_groups

Returns the command groups of one session as `{name, enabled}` objects. The teamserver returns `[]` when the session is missing.

```javascript
array ax.agent_get_command_groups(int id);
```

***

### agent\_info

Get information from a agent session's metadata.

```javascript
any ax.agent_info(int id, string property)
```

* `id` - agent ID
* `property` - CRED property ([see here](#agents))

<details>

<summary>Example</summary>

```javascript
ax.agent_info(12, "username");
ax.agent_info(12, "pid");
```

</details>

***

### agent\_hide

Hide agents from Sessions Table.

```javascript
void ax.agent_hide(int[] ids)
```

* `ids` - array of agent ids. A single id is an error. On the teamserver this call does nothing.

***

### agent\_remove

Remove agents from server.

```javascript
void ax.agent_remove(int[] ids)
```

* `ids` - array of agent ids. A single id is an error. On the teamserver this call does nothing.

***

### agent\_set\_color

Set color for agent's item in Session Table

```javascript
void ax.agent_set_color(int[] ids, string background, string foreground, bool reset);
```

* `ids` - array of agent ids
* `background` - item background color in hex RGB
* `foreground` - item text color in hex RGB
* `reset` - if true, reset the color to default. `ids` must be an array.

<details>

<summary>Example</summary>

```
ax.agent_set_color([12], "008000", "000000", false);
```

</details>

***

### agent\_set\_command\_group

Enables or disables one command group on a session.

```javascript
void ax.agent_set_command_group(int id, string group, bool enabled);
```

***

### agent\_set\_impersonate

Set impersonate for agent's item in Session Table

```javascript
void ax.agent_set_impersonate(int id, string impersonate, bool elevated);
```

* `id` - agent ID
* `impersonate` - impersonated user
* `elevated` - is impersonated user elevated

<details>

<summary>Example</summary>

```javascript
ax.agent_set_impersonate(12, "SYSTEM", true);
```

</details>

***

### agent\_set\_mark

Set mark for agent's item in Session Table

```javascript
void ax.agent_set_mark(int[] ids, string mark);
```

* `ids` - array of agent ids. A single id is an error.
* `mark` - agent's mark ("Terminated", "Inactive", "Disconnect", empty "" for active).

<details>

<summary>Example</summary>

```javascript
ax.agent_set_mark(12, "Inactive");
```

</details>

***

### agent\_set\_tag

Set tag for agent's item in Session Table

```javascript
void ax.agent_set_tag(int[] ids, string tag);
```

* `ids` - array of agent ids. A single id is an error.
* `tag` - agent's tag

<details>

<summary>Example</summary>

```javascript
ax.agent_set_tag(12, "long");
```

</details>

***

### agent\_update\_data

Update/set agent data

```javascript
void ax.agent_update_data(int id, json_property object);
```

* `id` - agent ID
* `json_property` - CRED property ([see here](#agents))

<details>

<summary>Example</summary>

```javascript
ax.agent_update_data(12, {
    internal_ip:"192.168.1.1", 
    domain:"dom.local"
    pid: 1234
});
```

</details>

***

### arch

Returns the architecture of agent session (e.g., x86 or x64)

```javascript
string ax.arch(int id);
```

* `id` - agent ID

***

### base64\_decode / base64\_encode

Teamserver only. The client does not define these. Decode returns an `ArrayBuffer`, empty on a bad string. Encode returns a string. Input to encode is an `ArrayBuffer`, a typed array, or a string.

```javascript
string ax.base64_encode(data);
ArrayBuffer ax.base64_decode(string b64);
```

***

### bof\_pack

Pack arguments in a way that's suitable for BOF APIs to unpack. A `bytes` argument is an `ArrayBuffer`, a typed array, or a UTF-8 string.

```javascript
string ax.bof_pack(string types, any[] args);
```

* `types` - a set of comma separated string types for BOF's arguments
* `args` - array of BOF's arguments

<table><thead><tr><th width="114">Type</th><th width="329">Description</th><th>Unpack With (C)</th></tr></thead><tbody><tr><td>bytes</td><td>binary data</td><td>BeaconDataExtract</td></tr><tr><td>int</td><td>4-byte integer</td><td>BeaconDataInt</td></tr><tr><td>short</td><td>2-byte short integer</td><td>BeaconDataShort</td></tr><tr><td>cstr</td><td>zero-terminated+encoded string</td><td>BeaconDataExtract</td></tr><tr><td>wstr</td><td>zero-terminated wide-char string</td><td>(wchar_t *)BeaconDataExtract</td></tr></tbody></table>

<details>

<summary>Example</summary>

```javascript
ax.bof_pack("bytes,int,short,cstr,wstr", ["bytes_str", 123, 12, "c_string", "w_string"]);
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-0609bbcb2724649bdc30f31cc6a933e2743cba51%2FScreenshot_20250727_004155.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### copy\_to\_clipboard

Copy `text` to client's clipboard.

```javascript
void ax.copy_to_clipboard(string text);
```

<details>

<summary>Example</summary>

```javascript
ax.copy_to_clipboard("stored data");
```

</details>

***

### console\_message

Print an output message and text to the agent console.

```javascript
void ax.console_message(int id, string message, string type = "", string text = "");
```

* `id` - agent ID
* `message` - brief message
* `type` - message type ("info", "success", or "error")
* `text` - text output

<details>

<summary>Example</summary>

```javascript
ax.console_message("47ca27cf", "Info message\n", "info", "This is\nmulti line\ntext");
ax.console_message("47ca27cf", "Error message\n", "error");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-4de7ff2cc062828722282965b1a06b11b714cdc9%2FScreenshot_20250727_005620.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### convert\_to\_code

Renders bytes as source code. `data` is an `ArrayBuffer`, a typed array, or a string.

```javascript
string ax.convert_to_code(string language, data, string varName = "shellcode");
```

* `language` - `c`, `csharp`, `python`, `golang`, `vbs`, `nim`, `rust`, or `powershell`
* `varName` - variable name in the generated code

<details>

<summary>Example</summary>

```javascript
ax.convert_to_code("rust", "dGVzdCBtZXNzYWdlCg==", "shellcode");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-1990591446f7ce1041ba543da2f672d405c6fd78%2FScreenshot_20260115_002717.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

</details>

***

### credentials

[See here](#credentials)

***

### credentials\_add

Save the specified credentials in Credentials Manager. The client returns nothing. The teamserver returns `true` or `false`. Argument order is the same on both.

```javascript
void ax.credentials_add(string username, string password, string realm = "", string type = "password", string tag = "", string storage = "manual", string host = "");
```

* `username` - creds username
* `password` - creds secret
* `realm` - creds domain/realm
* `type` - creds type (possible "password", "hash", "rc4", "aes128", "aes256", "token")
* `tag` - creds tag
* `storage` - creds container (possible "browser", "dpapi", "database", "sam", "lsass", "ntds", "manual")
* `host` - the host where the credentials were stored

<details>

<summary>Example</summary>

```javascript
ax.credentials_add("user", "P@ssw0rd", "dom.local", "password", "", "dpapi", `SERVER12`);
```

</details>

***

### credentials\_add\_list

Save a list of creds in the Credentials Manager. The teamserver returns `true` or `false`. Each item is an object with `username`, `password`, `realm`, `type`, `tag`, `storage`, and `host`.

```javascript
void ax.credentials_add_list(cred[] array);
```

<pre class="language-javascript"><code class="lang-javascript">// cred STRUCT
<strong>string cred.username
</strong>string cred.password
string cred.realm
string cred.type
string cred.tag
string cred.storage
string cred.host
</code></pre>

<details>

<summary>Example</summary>

```javascript
var obj = {};
obj.username = "user";
obj.password = "!Q@W3e4r";
obj.realm = "domain";
obj.type = "password";
obj.host = "DB";

var arr = [];
arr.push(obj);

ax.credentials_add_list(arr);
```

</details>

***

### create\_command

[See here](/adaptix-framework/development/axscript/axcommand-type.md#command)

***

### create\_commands\_group

[See here](/adaptix-framework/development/axscript/axcommand-type.md#registering-commands)

***

### decode\_data

Decodes data and returns raw bytes. `hex`, `base64`, and `base32` take a text string. `xor` and `zip` take an `ArrayBuffer`, a typed array, or a string of bytes.

```javascript
ArrayBuffer ax.decode_data(string algorithm, data, string key = "");
```

* `algorithm` - `hex`, `base64`, `base32`, `zip`, or `xor`.
* `key` - key for `xor`.

<details>

<summary>Example</summary>

```javascript
ax.decode_data("xor", "GAAaQ1dH", "key123");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-250fd60db2bb7e5575e26cb214d09cf2f15dac0a%2FScreenshot_20260115_002343.png?alt=media" alt="" width="533"><figcaption></figcaption></figure>

</details>

***

### decode\_file

Reads a file and decodes it. Always returns an `ArrayBuffer`.

```javascript
ArrayBuffer ax.decode_file(string algorithm, string filepath, string key = "");
```

<details>

<summary>Example</summary>

```javascript
ax.decode_data("xor", "/tmp/encfile.txt", "key123");
```

</details>

***

### encode\_data

Same return rule as `encode_data`, reading the file first.

```javascript
string|ArrayBuffer ax.encode_data(string algorithm, data, string key = "");
```

* `algorithm` - string (UTF-8), `ArrayBuffer`, or typed array.
* `key` - key for `xor`.

<details>

<summary>Example</summary>

```javascript
ax.encode_data("xor", "secret", "key123");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-5d14b526c6e59fcfdb822935aef4530809bfec76%2FScreenshot_20260115_002315.png?alt=media" alt="" width="502"><figcaption></figcaption></figure>

</details>

***

### editor\_profile\_upsert

Client only. Registers or updates a managed code-editor profile. The teamserver does not define this function.

```javascript
string ax.editor_profile_upsert(object spec);
```

`id` is required and is the stable key. A value that is not an object returns `"error: expected object"`. An empty `id` returns `"error: id is required"`. The same text is written to the script log.

An id that starts with `system.`, or the name `AxScript`, `BOF`, or `Event Handler`, returns `"error: cannot upsert system profile"`.

* `name` — display name. Defaults to `id`. On insert, a name that is already taken becomes `name_1`, `name_2`, and so on.
* `language` — defaults to `"plain"`.
* `panel_script` or `panelScript` — panel script. An empty value uses the built-in custom panel.
* `persist` — defaults to `true`. `false` keeps the profile in memory and does not write it to the local database.
* `force` — defaults to `false`. `true` overwrites a profile the operator created in Settings and marks it managed. Without `force` that profile is left unchanged.
* `toolbar` — `newFile`, `openFile`, `openFolder`, `save`, `explorer`, `buildLog`, `minimap`, `wordWrap` (bool, on by default), and `panel`. `"axscript"` shows the script panel, `"build"` shows the build panel, and any other value hides the panel.
* `actions` — `{id, label, icon, script}` objects. An empty `id` becomes the lower-case label. An empty list uses the built-in Build and Stop actions.

Returns `"inserted"`, `"updated"`, `"unchanged"`, or `"error:…"`. The same `id` and the same content does nothing. Changing only `persist` does not change the stored hash, so that call also returns `"unchanged"`. An update keeps the panel state already stored for the profile.

***

### encode\_file

Same return rule as `encode_data`, reading the file first.

```javascript
string|ArrayBuffer ax.encode_file(string algorithm, string filepath, string key = "");
```

* `algorithm` - "hex", "base64", "base32", "zip" or "xor".
* `filepath` - file with data in base64
* `key` - encrypt key (for `xor`)

<details>

<summary>Example</summary>

```javascript
ax.encode_data("xor", "/tmp/encfile.txt", "key123");
```

</details>

***

### event\_handler\_register

Client only. Registers an event handler through the teamserver. A server script, a missing connection, or a `meta` value that is not an object returns `false`, and the reason is written to the script log.

```javascript
bool ax.event_handler_register(object meta);
```

`name`, `event`, and `script` are required. Optional fields are `id`, `group`, `description`, `enabled`, and `filters`.

***

### execute\_alias

[See here](/adaptix-framework/development/axscript/axcommand-type/commands-and-hooks.md#execute_alias)

***

### execute\_browser

[See here](/adaptix-framework/development/axscript/axcommand-type/commands-and-hooks.md#execute_browser)

***

### execute\_command

[See here](/adaptix-framework/development/axscript/axcommand-type/commands-and-hooks.md#execute_command)

***

### file\_basename

Returns the filename

```javascript
string ax.file_basename(string path);
```

* `path` - full filename

<details>

<summary>Example</summary>

```javascript
ax.file_basename("/tmp/test.txt");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-cc809b31b97b8fc67fa1348b5e995175a10546df%2FScreenshot_20250727_011742.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### file\_dirname

Returns the base directory name

```javascript
string ax.file_dirname(string path);
```

* `path` - full filename

<details>

<summary>Example</summary>

```javascript
ax.file_dirname("/tmp/test.txt");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-0605bc6c455363b4a2d28bd46b838dbe4b033e24%2FScreenshot_20260114_234128.png?alt=media" alt="" width="434"><figcaption></figcaption></figure>

</details>

***

### file\_exists

Checks if a file exists

```javascript
bool ax.file_exists(string path);
```

* `path` - full filename

<details>

<summary>Example</summary>

```javascript
ax.file_exists("/tmp/test.txt");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-e8c83a24776823fe3f90c47362c39ddcca116316%2FScreenshot_20250727_011950.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### file\_extension

Checks if a file exists

```javascript
string ax.file_extension(string path);
```

* `path` - full filename

<details>

<summary>Example</summary>

```javascript
ax.file_extension("/tmp/test.txt");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-e9ed907e264de7dd32156c8861a47cf1de9d2991%2FScreenshot_20260114_234136.png?alt=media" alt="" width="457"><figcaption></figcaption></figure>

</details>

***

### file\_read

Reads a file and returns the raw bytes. The teamserver returns `null` when the file is missing or outside the sandbox. The client returns an empty `ArrayBuffer` in those cases.

```javascript
ArrayBuffer|null ax.file_read(string path);
```

* `path` - full filename

<details>

<summary>Example</summary>

```javascript
ax.file_read("/tmp/test.txt");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-305d28ed07e08b508d3cb30d48edecdb04baef47%2FScreenshot_20250727_113427.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### file\_size

Return the file size

```javascript
int ax.file_size(string path);
```

* `path` - full filename. The client returns `-1` when the path is rejected. The teamserver returns `0` when the path is missing or outside the sandbox.

<details>

<summary>Example</summary>

```javascript
ax.file_size("/tmp/file.txt");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-5fc082dbfd4077e89068456750556fde0f2cfb1e%2FScreenshot_20260114_234642.png?alt=media" alt="" width="403"><figcaption></figcaption></figure>

</details>

***

### file\_write

Writes bytes to a file and returns true on success.

```javascript
bool ax.file_write(string path, data, bool append = false);
```

* `path` - full filename. On the server the path must stay inside the script sandbox.
* `data` - `ArrayBuffer`, typed array, or string (written as UTF-8).
* `append` - append instead of truncate.

<details>

<summary>Example</summary>

```javascript
ax.file_write("/tmp/test.txt", "this is text");
let buf = ax.file_read("/tmp/in.bin");
ax.file_write("/tmp/out.bin", buf);
```

</details>

***

### format\_time

Convert UNIX Epoch Time to date/time string value.

```javascript
string ax.format_time(string format, int unixtime);
```

* `format` - datetime format (e.g. "dd/MM/yyyy hh:flag\_mm:ss")
* `unixtime` - UNIX Epoch Time value

<details>

<summary>Example</summary>

```javascript
ax.format_time("dd/MM hh:mm", ax.ticks());
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-4ceba71cd2da16b5146469bff31f833ac0dfc7c8%2FScreenshot_20250727_113727.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### format\_size

Converts bytes into a convenient format

```javascript
string ax.format_size(int bytes);
```

<details>

<summary>Example</summary>

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-b14b774258cbe714be403a248ff7c559d321e390%2FScreenshot_20250828_145219.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### get\_commands

Returns a list of available commands for the agent.

```javascript
string[] get_commands(int id);
```

* `id` - agent ID

<details>

<summary>Example</summary>

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-132a367a6dcd955003a5909ccca9ad2b83fac91d%2FScreenshot_20250828_143514.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### get\_project

Returns the name of the current project.

```javascript
string ax.get_project();
```

***

### hash

Returns a hash string in hex format.

```javascript
string ax.hash(string algorithm, int length, string data)
```

* `algorithm` — `md5`, `sha1`, `sha256`, or `sha512` (case-insensitive). Unknown names return an empty string.
* `length` — how many hex characters to return. `0` returns the full digest.
* `data` — string, `ArrayBuffer`, or typed array. The argument order is `(algorithm, length, input)`.

<details>

<summary>Example</summary>

```javascript
ax.hash("sha1", 8, "data-for-hash");
ax.hash("md5", 32, "data-for-hash");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-525ef86b25484906b544f5d3e0c3bb8c69cd9af8%2FScreenshot_20250926_201942.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### interfaces

Returns a list of network interfaces of the teamserver

```javascript
string[] ax.interfaces()
```

<details>

<summary>Example</summary>

```javascript
ax.interfaces()
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-4267b60a6c4da63cd80e0558b03b282e23b72ead%2FScreenshot_20250727_194836.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### ids

Returns a list of agent ids

```javascript
bool ax.is64(int id);
```

<details>

<summary>Example</summary>

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-24029a3caa430b53718118f8617fbca504df6ba2%2FScreenshot_20250828_132900.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### is64

Check if a session is on an x64 system or not

```javascript
bool ax.is64(string id);
```

* `id` - agent ID

<details>

<summary>Example</summary>

```javascript
ax.is64("47ca27cf");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-d7901985827e287f3fd8712485f0c207217d351f%2FScreenshot_20250727_114654.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### isactive

Returns true if the agent is active

```javascript
bool ax.isactive(int id);
```

`id` - agent ID

<details>

<summary>Example</summary>

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-33c186b7becb2729d61981b113d8ef90bfb5e321%2FScreenshot_20250828_143237.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### isadmin

Check if a session has admin rights

```javascript
bool ax.isadmin(int id);
```

* `id` - agent ID

<details>

<summary>Example</summary>

```javascript
ax.isadmin("47ca27cf");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-456825ab2eb2d282553888accf22d767199349ba%2FScreenshot_20250727_114813.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### log / log\_error

Print `text` to AxScript Console.

```javascript
void ax.log(string text);
void ax.log_error(string text);
```

<details>

<summary>Example</summary>

```javascript
ax.log("log");
ax.log_error("log");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-abe5bbadfdaf7b7b3509c782ab55a40224bf1d43%2FScreenshot_20250727_115052.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### open\_agent\_console

Open the console to interact with a agent

```javascript
void ax.open_agent_console(int id);
```

* `id` - agent ID

***

### open\_access\_tunnel

Open the tunnel creation dialog window

```javascript
void ax.open_access_tunnel(int id, bool socks4, bool socks5, bool lportfwd, bool rportfwd);
```

* `id` - agent ID
* `socks4` - is agent support socks4
* `socks5` - is agent support socks5
* `lportfwd` - is agent support local port forwarding
* `rportfwd` - is agent support reverse port forwarding

<details>

<summary>Example</summary>

```javascript
ax.open_access_tunnel("47ca27cf", true, true, false, false);
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-839ae27616f320d602705069877b9d5d444c3e60%2FScreenshot_20250727_115836.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### open\_browser\_files

Open the File Browser for a agent

```javascript
void ax.open_browser_files(int id, zone);
```

* `id` - agent ID
* `zone` — optional dock zone. Omit it to use the default placement

***

### open\_browser\_process

Open the Process Browser for a agent

```javascript
void ax.open_browser_process(int id, zone);
```

* `id` - agent ID
* `zone` — optional dock zone. Omit it to use the default placement

***

### open\_code\_editor

Opens the code editor. No arguments opens an empty editor. A number first argument is an agent id, and the second argument is a zone string or an options object (`profiles`, `profile`, `zone`). An object first argument is those options alone. Client only.

```javascript
void ax.open_code_editor(arg1, arg2);
```

***

### open\_remote\_terminal

Open the Interactive Terminal for a agent

```javascript
void ax.open_remote_terminal(int id, zone);
```

* `id` - agent ID
* `zone` — optional dock zone. Omit it to use the default placement

***

### plugin\_agent\_command

Calls `PluginAgent.Call` for one session.

```javascript
void ax.plugin_agent_command(int agentId, string command, object args);
```

***

### plugin\_listener\_command

Calls `PluginListener.Call`.

```javascript
void ax.plugin_listener_command(string listenerName, string command, object args);
```

***

### plugin\_service\_command

Calls `PluginService.Call`. `args` is a JSON object.

```javascript
void ax.plugin_service_command(string service, string command, object args);
```

***

### plugin\_service\_wait

Calls `PluginService.CallRPC` and returns the JSON result. `timeoutMs` is optional.

```javascript
any ax.plugin_service_wait(string service, string command, object args, int timeoutMs);
```

***

### process

Runs a local process from the code editor, and only when Settings allows process execution for scripts.

```javascript
any process.exec(string command, int timeoutMs = 30000);
string process.workdir();
void process.set_workdir(string path);
```

***

### open\_remote\_shell

Open the I/O remote shell for a agent

```javascript
void ax.open_remote_shell(int id, zone);
```

* `id` - agent ID
* `zone` — optional dock zone. Omit it to use the default placement

***

### prompt\_confirm

Show a confirm dialog. Returns true when the operator presses Yes. The teamserver always returns false.

```javascript
bool ax.prompt_confirm(string title, string text);
```

* `caption` - title of the dialog
* `text` - Text question

<details>

<summary>Example</summary>

```javascript
ax.prompt_confirm(" ", "Exit main windows?");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-c5811694d7f6ee6fa1ea5036a55d460316068f8c%2FScreenshot_20250828_145826.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### prompt\_open\_file

Show a file open dialog.

```javascript
string prompt_open_file(string caption = "Select file", string filter = "");
```

* `caption` - title of the dialog
* `filter` - filter for selecting files

<details>

<summary>Example</summary>

```javascript
ax.prompt_open_file("Select AxScript", "AxScript Files (*.axs)");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-5e077b8b3d10cdbb24d2904793d245ff5678fabd%2FScreenshot_20250727_120613.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### prompt\_open\_dir

Show a directory open dialog.

```javascript
string prompt_open_dir(string caption = "Select directory");
```

* `caption` - title of the dialog

<details>

<summary>Example</summary>

```javascript
ax.prompt_open_dir("Open directory");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-80810cfe6f9fa4a644235de7058b9e48e9838775%2FScreenshot_20250727_121200.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### prompt\_save\_file

Show a file save dialog.

```javascript
string prompt_save_file(string filename, string caption = "Select file", string filter = "");
```

* `filename` - default filename
* `caption` - title of the dialog
* `filter` - filter for selecting files

<details>

<summary>Example</summary>

```javascript
ax.prompt_save_file("/tmp/creds.txt", "Save file");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-175c68219d817c70c6e0eba549aebe2fb9c3f9f1%2FScreenshot_20250727_121514.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### random\_string

Generates a random string of length `len` from a set of characters `set`.

```javascript
string random_string(int len, string set);
```

* `set` — client: `alphanumeric`, `alphabetic`, `numeric`. Any other name, including `hex`, uses `0-9a-f`. Teamserver: `hex`, `alpha`, `numeric`, `lower`, `upper`. Any other name uses letters and digits. Length is capped at 4096 on the teamserver

<details>

<summary>Example</summary>

```javascript
ax.random_string(10, "hex")
ax.random_string(36, "alphanumeric")
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-36425429f074ddd77fec1946bbcbc152653700d8%2FScreenshot_20250926_231359.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### random\_int

Generates a random int value.

```javascript
int random_int(int min, int max);
```

* `min`, `max` — the client range includes `max`. The teamserver range is `[min, max)`.

<details>

<summary>Example</summary>

```javascript
ax.random_int(2, 1024)
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-5fe7d3aa717b5f4e588993783f4e3201f538e952%2FScreenshot_20250926_231725.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### register\_commands\_group

[See here](/adaptix-framework/development/axscript/axcommand-type.md#registering-commands)

***

### script\_import

Import AxScript script into current script's env.

```javascript
void ax.script_import(string path);
```

* `path` - path to script file

***

### script\_load

Load a new script to AxScript Manager

```javascript
string script_load(string path);
```

* `path` - path to script file

***

### script\_unload

Unload a script from the AxScript Manager

```javascript
string script_unload(string path);
```

* `path` - path to script file

***

### script\_dir

Returns the directory where the script is located.

```javascript
string script_dir();
```

***

### show\_message

Shows a message to the user in a dialog box. Use this function to relay information.

```javascript
void show_message(string title, string text);
```

* `title` - title of the dialog
* `text` - the message text

<details>

<summary>Example</summary>

```javascript
ax.show_message("Info", "This is text");
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-11b21d160e67707c8eed04ef74dd32e0ca49631a%2FScreenshot_20250727_124650.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***

### targets\_add

Save the specified target in Targets Manager

```javascript
void ax.targets_add(string computer, string domain, string address, string os = "unknown", string osDesc = "", string tag = "", string info = "", bool alive = true);
```

* `computer` - computer name
* `domain` - domain name
* `address` - IP address
* `os` - OS type (possible "windows", "linux", "macos")
* `osDesc` - detailed information about OS
* `tag` - tag
* `info` - info
* `alive` - true if the host is alive

<details>

<summary>Example</summary>

```javascript
ax.targets_add("DC", "dom.local", "dom.local", "192.168.1.10", "windows");
```

</details>

***

### targets\_add\_list

Save a list of targets in the Targets Manager

```javascript
void ax.targets_add_list(target[] array);
```

<pre class="language-javascript"><code class="lang-javascript">// target STRUCT
<strong>string target.computer
</strong>string target.domain
string target.address
string target.tag
string target.info
string target.os_desc
string target.os            ["windows", "linux", "macos"]
bool   target.alive
</code></pre>

<details>

<summary>Example</summary>

```javascript
var obj = {};
obj.computer = "DC";
obj.domain = "DOM.LOCAL";
obj.os_desc = "Windows Server 2019";
obj.os = "windows";
obj.alive = true;
obj.tag = "";
obj.info = "from axscript";

var arr = [];
arr.push(obj);

ax.targets_add_list(arr);
```

</details>

***

### ticks

UNIX Epoch Time value

```javascript
int ticks();
```

***

### tokenize

Splits a command line with quote and backslash rules. Teamserver only. The client has the same splitter internally but does not expose `ax.tokenize`.

```javascript
string[] ax.tokenize(string cmdline);
```

***

### validate\_command

Checks the validity of the entered command and returns full information

```javascript
cmd_info ax.validate_command(int id, string command);
```

* `id` - agent ID
* `command` - agents command

```javascript
// cmd_info STRUCT
bool   info["valid"]
string info["message"]
bool   info["is_pre_hook"]
bool   info["has_output"]
bool   info["has_post_hook"]
bool   info["has_handler"]
map{}  info["parsed"]
```

<details>

<summary>Example</summary>

```javascript
let cmd = ax.validate_command("551757de", "socks start 1080");
cmd.valid

let cmd = ax.validate_command("551757de", "socks start");
cmd.message
```

<figure><img src="https://2104178602-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS8p8XLFtLmf0NkofQvoa%2Fuploads%2Fgit-blob-d726bcb97b7ca72e3b0c35d73a2e49fa26ef3736%2FScreenshot_20250828_144547.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

***
