PEP 561 stub-only package for the Tuoni internal Python scripting
Project description
Tuoni Script Engine type stubs
Type hints for Python scripts run by Tuoni. Install this package locally to get
editor completion, API documentation, and static type checking for
tuoni_script_engine.
The package contains type information only. Tuoni provides the actual
tuoni_script_engine module when it runs a server-side script.
Python 3.12 or newer is required.
Installation
python -m pip install tuoni-script-engine-stubs
To check a script with Pyright:
python -m pip install pyright
python -m pyright path/to/script.py
Quick example
import tuoni_script_engine as tse
for agent in tse.agents.list(status=tse.AgentStatus.ACTIVE):
print(agent.guid, agent.metadata.hostname)
tse.discovery.services.create(
"10.10.20.15",
445,
protocol="tcp",
banner="SMB",
)
API overview
| API | What it provides |
|---|---|
agents |
Find agents, inspect metadata and listeners, change status, and queue commands. |
commands |
Queue, inspect, update, or cancel commands and register dynamic aliases. |
command_templates |
Inspect available commands, schemas, and example configurations. |
command_aliases |
Create and manage saved aliases with fixed configurations. |
discovery |
Create, search, update, archive, and restore hosts, services, and credentials. |
events |
Subscribe to live events and query recorded events. |
files |
Upload and access files stored by Tuoni. |
listeners |
Create, inspect, start, stop, reconfigure, and delete listeners. |
payloads |
Create, inspect, generate, and archive payloads. |
payload_templates |
Inspect available payload types and their configuration schemas. |
plugins |
Inspect loaded listener, command, and payload plugins. |
jobs |
Inspect jobs and pause, resume, or restart supported jobs. |
settings |
Read server and plugin settings. |
ips |
List server IP addresses detected by Tuoni. |
APIs that accept configuration use one of these types:
tuoni_script_engine.JsonConfiguration({"key": "value"})
tuoni_script_engine.BinaryConfiguration(b"content")
tuoni_script_engine.MultipartConfiguration(
files={"payload.bin": b"content"},
json={"key": "value"},
)
Dynamic command aliases
A dynamic alias adds a command to Tuoni for as long as its script is loaded. Register an object that implements these methods:
configuration_schema()returns the command configuration as JSON Schema.can_send_to_agent(agent)decides whether the command is available for an agent.validate_config(config, agent)performs any additional validation. RaiseValidationErrorwhen the input should be rejected.execute(ctx, config, agent)runs the alias. Usectxto queue child commands, publish results, and finish or fail the alias.
The following alias exposes the native ps command under a new name:
import tuoni_script_engine as tse
class ProcessListAlias(tse.DynamicAlias):
description = "List running processes"
def configuration_schema(self) -> str:
return '{"type":"object","properties":{},"additionalProperties":false}'
def can_send_to_agent(self, agent: tse.Agent) -> bool:
return agent.type is tse.AgentType.SHELLCODE_AGENT
def validate_config(
self,
config: tse.Configuration,
agent: tse.Agent,
) -> None:
pass
def execute(
self,
ctx: tse.AliasContext,
config: tse.Configuration,
agent: tse.Agent,
) -> None:
command = ctx.queue_command("ps", tse.JsonConfiguration({}))
if not command.wait_for_completion(timeout=300):
command.cancel()
ctx.fail("Process listing timed out")
return
if command.is_failed():
error = command.result.error_message if command.result else None
ctx.fail(error or "Process listing failed")
return
if command.result:
ctx.set_result(command.result.entries)
ctx.finish()
tse.commands.register_dynamic_alias("script-ps", ProcessListAlias())
An alias must eventually call ctx.finish() or ctx.fail(). It may call
ctx.set_result(...) before completion to publish ongoing or final result
entries.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tuoni_script_engine_stubs-0.15.0.tar.gz.
File metadata
- Download URL: tuoni_script_engine_stubs-0.15.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e0aa1125536ee80497f5c0e39ba6c34bdf8edae4c7e92977e66c3ead4cdc729
|
|
| MD5 |
72b0db066212d5def6f763442a2f4515
|
|
| BLAKE2b-256 |
6e88bcb68201eb6bb8ccdb2b3b776a62fdd567826c5aa762e26f445867457d5c
|
File details
Details for the file tuoni_script_engine_stubs-0.15.0-py3-none-any.whl.
File metadata
- Download URL: tuoni_script_engine_stubs-0.15.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7fe58fa25b096a6349220e59c81166d4f4064ef115dcf9eb560dabd027e7db8
|
|
| MD5 |
e142d994c8d08185eefdb2220c3814f1
|
|
| BLAKE2b-256 |
2d861a1cc1829f4443b8a1e9e4b1d0c0e4b22b53050599dec69a0a3b304414b7
|