TuoniCommand

class tuoni.TuoniCommand(conf, c2)[source]

A class that provides data and functionality for a sent command.

command_id

The unique identifier of the command.

Type:

int

commandTemplateId

The unique identifier of the command template used to create the command.

Type:

str

commandTemplateName

The name of the command template used to create the command.

Type:

str

configuration

The configuration settings for the command.

Type:

dict

execConf

The execution configuration for the command.

Type:

dict

status

Top-level lifecycle status from the server: one of CREATED, SENT, ONGOING, CANCELED, FAILED, COMPLETE. May be None on older servers.

Type:

str

created

The time, as a string, indicating when the command was created.

Type:

str

sent

The time, as a string, indicating when the command was sent.

Type:

str

result

The result data returned from the command execution.

Type:

TuoniResult

get_result(reload=True)[source]

Retrieve the result object of the command.

Parameters:

reload (bool) – If True, reload the command result data from the server.

Returns:

The result object containing the data from the command execution.

Return type:

TuoniResult

get_template()[source]

Retrieve the command template used to create this command.

Returns:

The command template object, or None if the template could not be found.

Return type:

TuoniCommandTemplate

is_done(reload_from_server=False)[source]

Checks has the command done/finished

Parameters:

reload_from_server (bool) – Should command data be reloaded from server.

Returns:

Is command done

Return type:

bool

is_failed(reload_from_server=False)[source]

Checks did the command fail or get canceled

Parameters:

reload_from_server (bool) – Should command data be reloaded from server.

Returns:

Did command fail

Return type:

bool

is_ongoing(reload_from_server=False)[source]

Checks is the command running as ongoing command

Parameters:

reload_from_server (bool) – Should command data be reloaded from server.

Returns:

Is command ongoing

Return type:

bool

is_sent(reload_from_server=False)[source]

Checks was the command sent to the agent

Parameters:

reload_from_server (bool) – Should command data be reloaded from server.

Returns:

Is command sent to agent

Return type:

bool

is_success(reload_from_server=False)[source]

Checks was the command successful

Parameters:

reload_from_server (bool) – Should command data be reloaded from server.

Returns:

Was command successful

Return type:

bool

reload()[source]

Reload the command data from the C2 server.

result_status_done(reload=True)[source]

Check if the command has completed.

Parameters:

reload (bool) – If True, reload the command data from the server to verify the current status.

result_status_ongoing(reload=True)[source]

Check if the command is still ongoing.

Parameters:

reload (bool) – If True, reload the command data from the server to verify the current status.

send_update(config: dict, files: dict = None, persistence_type: str = 'TRANSIENT')[source]

Send an update to a running command (e.g. additional data for an ongoing operation).

Parameters:
  • config (dict) – The update configuration to send (wrapped server-side as updateConfiguration).

  • files (dict) – Optional files to include with the update. Same format as the files parameter of TuoniAgent.send_command().

  • persistence_type (str) – "TRANSIENT" (default) or "PERSISTENT".

Examples

>>> command.send_update({"input": "yes"})
stop()[source]

Stops the command execution on the agent or if it is not yet sent then cancel it.

wait_done(interval=1, maxWait=0)[source]

Wait for the command to be done (success, failed, or canceled).

Parameters:
  • interval (int) – The interval, in seconds, to reload the data from the server.

  • maxWait (int) – The maximum time to wait, in seconds, before giving up. A value of 0 means wait indefinitely.

Returns:

The result object containing the data from the command execution, if available within the specified time. For commands that finish without a result (e.g. canceled before send), returns None once the terminal status is reached.

Return type:

TuoniResult

wait_result(interval=1, maxWait=0)[source]

Wait for the command result object to be available (command done or in case of ongoing result, the initial results)

Parameters:
  • interval (int) – The interval, in seconds, to reload the data from the server.

  • maxWait (int) – The maximum time to wait, in seconds, before giving up. A value of 0 means wait indefinitely.

Returns:

The result object containing the data from the command execution, if available within the specified time.

Return type:

TuoniResult

wait_sent(interval=1, maxWait=0)[source]

Wait for the command to be sent

Parameters:
  • interval (int) – The interval, in seconds, to reload the data from the server.

  • maxWait (int) – The maximum time to wait, in seconds, before giving up. A value of 0 means wait indefinitely.

Returns:

Was command sent

Return type:

bool