# AxFunction

## Data Model

### agents

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

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

```javascript
// AGENT STRUCT
string 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_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="/files/OXAfE7TVffthYoO8JWkA" alt=""><figcaption></figcaption></figure>

</details>

***

### credentials

Returns a list of credentials.

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

```javascript
// CRED STRUCT
cred["id"]
cred["username"]
cred["password"]
cred["realm"]
cred["type"]
cred["tag"]
cred["date"]
cred["storage"]
cred["agent_id"]
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="/files/8tsqasFVdrK1h58FF8wG" alt=""><figcaption></figcaption></figure>

</details>

***

### downloads

Returns a list of downloads.

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

```javascript
// DOWNLOAD STRUCT
download["id"]
download["agent_id"]
download["agent_name"]
download["user"]
download["computer"]
download["filename"]
download["recv_size"]
download["total_size"]
download["date"]
download["state"]
```

<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="/files/mNrwELmnPBlBFRfy2hjZ" alt=""><figcaption></figcaption></figure>

</details>

***

### screenshots

Returns a list of screenshots.

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

```javascript
// SCREEN STRUCT
screen["id"]
screen["user"]
screen["computer"]
screen["note"]
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="/files/t8L7CDyAuTe3NoUDSC6s" alt=""><figcaption></figcaption></figure>

</details>

***

### targets

Returns a list of targets.

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

```javascript
// TARGET STRUCT
target["id"]
target["computer"]
target["domain"]
target["address"]
target["tag"]
target["date"]
target["info"]
target["alive"]
target["owned"]
target["os"]
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="/files/WYCybMMrdf9ttz9m4XAA" alt=""><figcaption></figcaption></figure>

</details>

***

### tunnels

Returns a list of tunnels.

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

```javascript
// TUNNEL STRUCT
tunnel["id"]
tunnel["agent_id"]
tunnel["username"]
tunnel["computer"]
tunnel["process"]
tunnel["type"]
tunnel["info"]
tunnel["interface"]
tunnel["port"]
tunnel["client"]
tunnel["f_port"]
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="/files/l6sCIDjqOrLXMVZG6XXV" alt=""><figcaption></figcaption></figure>

</details>

***

## Functions

The following is a list of AxScript's functions:

### agents

[See here](#agents)

***

### agent\_info

Get information from a agent session's metadata.

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

* `id` - agent ID
* `property` - CRED property ([see here](/adaptix-framework/development/axscript/axfunction.md#agents))

<details>

<summary>Example</summary>

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

<figure><img src="/files/2DrnVuD8Wy47nanAN6UJ" alt=""><figcaption></figcaption></figure>

</details>

***

### agent\_hide

Hide agents from Sessions Table.

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

* `ids` - array of agent ids

***

### agent\_remove

Remove agents from server.

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

* `ids` - array of agent ids

***

### agent\_set\_color

Set color for agent's item in Session Table

```javascript
void ax.agent_set_color(string[] 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
* `reser` - if true, reset the color to default

<details>

<summary>Example</summary>

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

</details>

***

### agent\_set\_impersonate

Set impersonate for agent's item in Session Table

```javascript
void ax.agent_set_impersonate(string 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("47ca27cf", "SYSTEM", true);
```

</details>

***

### agent\_set\_mark

Set mark for agent's item in Session Table

```javascript
void ax.agent_set_mark(string id, string mark);
```

* `id` - agent ID
* `mark` - agent's mark ("Terminated", "Inactive", "Disconnect", empty "" for active).

<details>

<summary>Example</summary>

```javascript
ax.agent_set_mark("47ca27cf", "Inactive");
```

</details>

***

### agent\_set\_tag

Set tag for agent's item in Session Table

```javascript
void ax.agent_set_tag(string id, string tag);
```

* `id` - agent ID
* `tag` - agent's tag

<details>

<summary>Example</summary>

```javascript
ax.agent_set_tag("47ca27cf", "long");
```

</details>

***

### agent\_update\_data

Update/set agent data

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

* `id` - agent ID
* `json_property` - CRED property ([see here](/adaptix-framework/development/axscript/axfunction.md#agents))

<details>

<summary>Example</summary>

```javascript
ax.agent_update_data("aa26e9d4", {
    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(string id);
```

* `id` - agent ID

<details>

<summary>Example</summary>

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

<figure><img src="/files/QA3vzmptGOKbomH868BV" alt=""><figcaption></figcaption></figure>

</details>

***

### bof\_pack

Pack arguments in a way that's suitable for BOF APIs to unpack. To transmit binary data to the server, the function will encode it in base64.

```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="/files/JUDhCGLl1k3qb4R3AqIK" 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(string 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="/files/VQfs5kG2H9wEkRLTQMIO" alt=""><figcaption></figcaption></figure>

</details>

***

### convert\_to\_code

Convert base64 binary data to code format.

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

* `languaage` - programming language ("c", "csharp", "python", "golang", "vbs", "nim", "rust", "powershell")
* `base64data` - base64 data for converting
* `varName` - var's name in code

<details>

<summary>Example</summary>

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

<figure><img src="/files/R33VMyeH5IuE6iX89IQI" alt="" width="563"><figcaption></figcaption></figure>

</details>

***

### credentials

[See here](#credentials)

***

### credentials\_add

Save the specified credentials in Credentials Manager

```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

```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

Return decoded base64 data from algorithm ("hex", "base64", "base32", "zip" or "xor") in base64.

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

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

<details>

<summary>Example</summary>

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

<figure><img src="/files/o02lD2MzxIi8QRC634yG" alt="" width="533"><figcaption></figcaption></figure>

</details>

***

### decode\_file

Return decoded base64 data from algorithm ("hex", "base64", "base32", "zip" or "xor") in base64.

```javascript
string ax.decode_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.decode_data("xor", "/tmp/encfile.txt", "key123");
```

</details>

***

### encode\_data

Return encoded data ("hex", "base64", "base32", "zip" or "xor") in base64.

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

* `algorithm` - "hex", "base64", "base32", "zip" or "xor".
* `data` - data  for encoding
* `key` - encrypt key (for `xor`)

<details>

<summary>Example</summary>

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

<figure><img src="/files/C12cjDI7zIljiCNQTAfj" alt="" width="502"><figcaption></figcaption></figure>

</details>

***

### encode\_file

Return encoded data ("hex", "base64", "base32", "zip" or "xor") in base64.

```javascript
string ax.encode_data(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>

***

### 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="/files/udCpRqBC1k6tmdJqFpnd" 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="/files/7xXrBHXjGHuJJOBPU7sl" 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="/files/nI2krSwPUxKbWt7dSkDF" 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="/files/eJMnMweLEUTMz1w1sEoO" alt="" width="457"><figcaption></figcaption></figure>

</details>

***

### file\_read

Reads a file and returns base64 encoded contents

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

* `path` - full filename

<details>

<summary>Example</summary>

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

<figure><img src="/files/Jv1dvt8vvqtCdQOew9uH" alt=""><figcaption></figcaption></figure>

</details>

***

### file\_size

Return the file size

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

* `path` - full filename

<details>

<summary>Example</summary>

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

<figure><img src="/files/NK6iQXAZ0IBTW2Sz7buS" alt="" width="403"><figcaption></figcaption></figure>

</details>

***

### file\_write\_text

Writes text data to a file and returns true if the write is successful.

```javascript
bool ax.file_write_text(string path, string text);
```

* `path` - full filename
* `text` - text data

<details>

<summary>Example</summary>

```javascript
ax.file_write_text("/tmp/test.txt", "this is text");
```

</details>

***

### file\_write\_binary

Writes base64 data to a file and returns true if the write is successful.

```javascript
bool ax.file_write_binary(string path, string b64text);
```

* `path` - full filename
* `b64text` - base64 data &#x20;

<details>

<summary>Example</summary>

```javascript
ax.file_write_binary("/tmp/file2.txt", "dGVzdCBtZXNzYWdlCg==");
```

</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:mm:ss")
* `unixtime` - UNIX Epoch Time value

<details>

<summary>Example</summary>

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

<figure><img src="/files/bDR8xABYCXmPszj70EJN" 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="/files/gx3ZPJmpvia7eVKf5hkA" alt=""><figcaption></figcaption></figure>

</details>

***

### get\_commands

Returns a list of available commands for the agent.

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

* `id` - agent ID

<details>

<summary>Example</summary>

<figure><img src="/files/wJ0C18ffjXfoCiZbijsI" alt=""><figcaption></figcaption></figure>

</details>

***

### get\_project

Returns the name of the current project.

```javascript
string get_project();
```

***

### hash

Returns a hash string in hex format.

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

* `algorithm` - hash "sha1" or "md5";
* `length` - length of the returned string
* `data` - data to be hashed

<details>

<summary>Example</summary>

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

<figure><img src="/files/ZcclqRvZJzOVFkjJqxPg" 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="/files/YfDlbjAt8WKHJMHBA8e1" alt=""><figcaption></figcaption></figure>

</details>

***

### ids

Returns a list of agent ids

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

<details>

<summary>Example</summary>

<figure><img src="/files/zV5hHspWC5q3NehPducn" 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="/files/i97EsyB9XWZEdirCJXMu" alt=""><figcaption></figcaption></figure>

</details>

***

### isactive

Returns true if the agent is active

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

`id` - agent ID

<details>

<summary>Example</summary>

<figure><img src="/files/XjzhhWwv6g8AO52DzKys" alt=""><figcaption></figcaption></figure>

</details>

***

### isadmin

Check if a session has admin rights

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

* `id` - agent ID

<details>

<summary>Example</summary>

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

<figure><img src="/files/OTZWYu80i5MpwXjTzrwy" 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="/files/jC7xxnPl1N88Tn6NSdec" alt=""><figcaption></figcaption></figure>

</details>

***

### open\_agent\_console

Open the console to interact with a agent

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

* `id` - agent ID

***

### open\_access\_tunnel

Open the tunnel creation dialog window

```javascript
void ax.open_access_tunnel(string 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="/files/EOpjbYVd5Yx8CXwNaprN" alt=""><figcaption></figcaption></figure>

</details>

***

### open\_browser\_files

Open the File Browser for a agent

```javascript
void ax.open_browser_files(string id);
```

* `id` - agent ID

***

### open\_browser\_process

Open the Process Browser for a agent

```javascript
void ax.open_browser_process(string id);
```

* `id` - agent ID

***

### open\_remote\_terminal

Open the Interactive Terminal for a agent

```javascript
void ax.open_remote_terminal(string id);
```

* `id` - agent ID

***

### open\_remote\_shell

Open the I/O remote shell for a agent

```javascript
void ax.open_remote_shell(string id);
```

* `id` - agent ID

***

### prompt\_confirm

Show a confirm dialog.

```javascript
string prompt_confirm(string caption, string text);
```

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

<details>

<summary>Example</summary>

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

<figure><img src="/files/oKSjM3kOG1Go9gn4Z6af" 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="/files/dPAVamNE33KLD0pEYzMh" 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="/files/WdyVpXOrPf6hjDfnLVgz" 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="/files/9h8e0dYGMs1u8dNmu1SR" 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` -  set of characters (`alphanumeric`, `alphabetic`, `numeric` or `hex`)

<details>

<summary>Example</summary>

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

<figure><img src="/files/ok4HEcZ0Lbzum4Ao2HqJ" alt=""><figcaption></figcaption></figure>

</details>

***

### random\_int

Generates a random int value.

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

* `min` -  min value
* `max` - max value

<details>

<summary>Example</summary>

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

<figure><img src="/files/Gwb3OxmpPyG26Z8tdkct" 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
string 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="/files/kDkbUGZTOtSlVdxWI5lx" 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();
```

***

### validate\_command

Checks the validity of the entered command and returns full information

```javascript
cmd_info ax.validate_command(string 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"]
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="/files/xPB2RZ285E4A6sDp0Jbv" alt=""><figcaption></figcaption></figure>

</details>

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://adaptix-framework.gitbook.io/adaptix-framework/development/axscript/axfunction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
