-
Notifications
You must be signed in to change notification settings - Fork 2
Usage
An usage example can be found here: https://r4ulcl.com/posts/using-ntask-to-distributed-tasks/
I recommend the following configuration:
- Manager:
- Execute the manager in a docker compose in the manager sever.
- Worker:
- Create a new Dockerfile installing the needed tools in the docker for the workers.
- Create a VPS, install all the tools and nTask and execute it there.
- If you want to execute external tools in docker you cant share the docker.sock with this docker and execute any docker from the nTask docker.
-
-c
,--configFile
string Path to the config file (default: manager.conf) -
-f
,--configSSHFile
string Path to the config SSH file (default empty) -
-s
,--swagger
: Enables the Swagger endpoint (/swagger) to access API documentation and interact with the API using its UI.
Once the configuration files have been modified. To run nTask in manager mode the easiest way is to run the docker compose manager as follows.
docker compose up manager -d
To start the manager, run the executable:
$ ./nTask manager
The manager will read the configuration file, connect to the database, and start listening for incoming connections on the specified port.
The best way to deploy workers is to close a base image and duplicate it as needed. The easiest option to modify later is to install nTask and the tools directly on the VPS.
-
-c
,--configFile
string Path to the config file (default: worker.conf)
Once the manager is up, we can run the following docker compose on each worker instance
docker compose up worker -d
$ ./nTask worker
Edit the ./worker/Dockerfile
file adding the needed tools for the modules. You can also modify the docker image, the default one is Kali.
To use the API, you can access the Swagger web interface by using the --swagger
flag on the manager. This allows you to manually perform queries and interact with the API.
The Status
endpoint provides general information about the nTask status. This includes the number of pending, running, completed, and deleted tasks, as well as the number of workers that are up and down.
To retrieve the status, you can use the following curl
command:
curl -X 'GET' \
'https://$IP:$PORT/status' \
-H 'accept: application/json' \
-H 'Authorization: $AUTH'
To add a task, you need to make a POST request to the /task
endpoint. The request should include the necessary fields, such as the command, name, and priority.
Here is an example curl
command for adding a task:
curl -X 'POST' \
'https://$IP:$PORT/task' \
-H 'accept: application/json' \
-H 'Authorization: $AUTH' \
-H 'Content-Type: application/json' \
-d '{
"command": [
{
"args": "Hello world",
"module": "echo"
}
],
"name": "example Task",
"priority": 0
}'
You should receive a response confirming that the task has been successfully added.
To retrieve a list of tasks based on certain criteria, you can use the Get Tasks
endpoint. The endpoint allows you to filter tasks by name, status, and limit the number of results.
Here is an example curl
command for retrieving tasks filtering any tasks which contains example
and status is done
:
curl -X 'GET' \
'https://$IP:$PORT/task?name=%25example%25&status=done&limit=10' \
-H 'accept: application/json' \
-H 'Authorization: $AUTH'
You will receive a response containing the tasks that match the specified criteria.