D2 agent scripting commands, including Windows specific functions. Cortex XSOAR provides example agent scripts.
The following are the D2 agent script commands. Each command is followed by its description, its syntax, and an example where applicable.
Note
Cortex XSOAR server comes with a few example agent scripts. These help you get more acquainted with the functions. You can copy the scripts, change them and check the results.
Command | Syntax | Description |
---|---|---|
env | | Holds environment variables. Example: |
pwd | | Returns the absolute path of the working folder. |
which | | Returns the absolute path for a given path or executable. Example: |
execute | | Executes the given command. Returns: Example: |
pack | | Returns the content as an entry on the investigation. Content can be a JSON object or when specified as a value. If not provided, the format will be determined according the type of content. |
pack_file | | Returns the |
files | | Retrieves a list of files from the folder. If recurse is true, sub-folders are included. If hashes are true, it computes hashes for each file. If regex is provided, it returns only file names matching the regex. Returns an array of: Example: |
copy | | Copies the source Returns the number of items copied. |
move | | Same as copy, but also deletes the source files. |
del | | Deletes the file. If the file is a folder, and regex is not empty, it removes only the files matching regex from that folder. |
grep | | Searches the given path for files matching regex. If recursive is true, it will dive into the sub folders. Returns an array of: Example: |
strings | | Searches strings contained in the file provided by path. Use Example: |
bytes | | Returns a Example: |
mkdir | | Returns 'true' if a folder was created. Throws an exception otherwise. |
rmdir | | Removes the folder provided by *path. Returns: 'true' if a folder was removed. Throws an exception otherwise. |
join_path | | Joins the paths provided by Returns: Path string. Example: |
http | | Performs HTTP GET call to URL with the provided arg as a request body. Returns object: Example: |
read_file | | Returns the entire content of the path. Throws an exception if it does not exist. |
wait | | Sleeps for the number of defined seconds. |
Windows Specific Functions
Command | Syntax | Description |
---|---|---|
processes | | Returns a list of processes. |
services | | Returns a list of services. |
wmi_query | | Executes a WMI query. Returns an array in JSON representing the results. |
registry | | Gets all values under the registry path provided by the The key name must start with one of the following: |
ifconfig | | Returns a list of all interface adapters and their configurations. |
fsconfig | | Returns a list of all file systems. |
accounts | | Returns a list of all defined user accounts. |