Security
API Security
CSRF token
Usage
./create.sh 123123123 "test sh"
node create.mjs 123123123 "test js"
python3 create.py 123123123 "test py"Linux shell
#!/bin/sh
# $TOKEN is imported from the environment, it is the API token
ardexa_cloud=app.ardexa.com
arch="Linux 64 bit (x86_64)"
workgroup_id=$1
device_name=$2
# Needs an XSRF token to use POST
xsrf_token=$(curl -s --cookie-jar /tmp/ardexa-cookie.txt -i https://$ardexa_cloud/api/v1/version | grep '^set-cookie: XSRF-TOKEN' | sed -e 's/.*TOKEN=\([^;]*\).*/\1/' -e 's/%2f/\//gi' -e 's/%2b/+/gi' -e 's/%3d/=/gi')
# Create the agent
curl -s -H "X-XSRF-TOKEN: $xsrf_token" -H "authorization: Bearer $TOKEN" -H "content-type: application/json" --cookie /tmp/ardexa-cookie.txt -X POST --output /tmp/agent-sh.zip "https://$ardexa_cloud/api/v1/devices/$workgroup_id" -d "{\"name\": \"$device_name\", \"arch\": \"$arch\"}"
echo "Agent zip file can be found at /tmp/agent-sh.zip"Javascript
Python
Last updated
Was this helpful?