Skip to main content

SliverPy

SliverPy is a Python gRPC client library for Sliver. SliverPy can be used to automate any operator interaction with Sliver and connects to servers using gRPC over Mutual TLS (i.e., multiplayer) using Sliver operator configuration files. For more details, please see the project documentation.

⚠️ Not all features in Sliver v1.5+ are supported yet.

SliverPy Documentation Status License: GPL v3

Install

Install the package using pip, for best compatibility use Sliver Server v1.5.29 or later:

pip3 install sliver-py

Examples

For more examples and details please read the project documentation.

Interact with Sessions

#!/usr/bin/env python3

import os
import asyncio
from sliver import SliverClientConfig, SliverClient

CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".sliver-client", "configs")
DEFAULT_CONFIG = os.path.join(CONFIG_DIR, "default.cfg")

async def main():
    config = SliverClientConfig.parse_config_file(DEFAULT_CONFIG)
    client = AsyncSliverClient(config)
    print('[*] Connected to server ...')
    await client.connect()
    sessions = await client.sessions()
    print('[*] Sessions: %r' % sessions)
    if len(sessions):
        print('[*] Interacting with session %s', sessions[0].ID)
        interact = await client.interact_session(sessions[0].ID)
        ls = await interact.ls()
        print('[*] ls: %r' % ls)

if __name__ == '__main__':
    asyncio.run(main())

Interact with Beacons

#!/usr/bin/env python3

import os
import asyncio
from sliver import SliverClientConfig, SliverClient

CONFIG_DIR = os.path.join(os.path.expanduser("~"), ".sliver-client", "configs")
DEFAULT_CONFIG = os.path.join(CONFIG_DIR, "default.cfg")

async def main():
    config = SliverClientConfig.parse_config_file(DEFAULT_CONFIG)
    client = SliverClient(config)
    print('[*] Connected to server ...')
    await client.connect()
    version = await client.version()
    print('[*] Server version: %s' % version)

    beacons = await client.beacons()
    print('[*] Beacons: %r' % beacons)
    if len(beacons):
        print('[*] Interacting with beacon: %r' % beacons[0].ID)
        interact = await client.interact_beacon(beacons[0].ID)
        ls_task = await interact.ls()
        print('[*] Created ls task: %r' % ls_task)
        print('[*] Waiting for task results ...')
        ls = await ls_task
        print('[*] ls: %r' % ls)

if __name__ == '__main__':
    asyncio.run(main())

Development

The development environment has migrated to hatch and the installation instructions can be found here.

Note on VS Code

Unfortunately, VS Code does not automatically detect hatch virtual environments yet due to how it structures environments. However, you can make setting the Python interpreter path easier by including the virtual environment directly in the folder by running these commands before setting up the virtual environment:

hatch config set dirs.env.virtual .venv
hatch config update

Setting up Hatch environment

Once installed, run hatch -e dev shell to enter the development environment. Hatch allows for scripts to be defined as well. These scripts are executed in the context of the defined environment. The current scripts defined are:

  • hatch run dev:fmt -- runs black and isort for formatting

Docker/WSL2

A Dockerfile is included if you wish to develop inside a container. This may be preferable for development on any operating system to keep the dev environment isolated. Windows developers may choose to develop inside WSL2.

In either case, scripts/sliver_install.sh contains a modified version of the official Sliver installation script that does not create a systemd based service. After running this script, you may start a local Sliver server in your container or WSL2 instance by running:

sudo /root/sliver-server daemon &

Alternatively, you can still choose to set up an external Sliver instance to connect to via Sliver's multi-player mode. The sliver_install script is purely for local development convenience.

Updating protobufs

This should only be necessary when changes are made to Sliver's protobuf. Running scripts/protobufgen.py will update sliver-py protobuf files. Ensure that the .pyi type hints are generated also.

Running tests

To run tests, you should have at least one beacon implant and one session implant connected to you Sliver instance. Currently, it is ok to only have them running on a Linux system (implants running on your sliver server works fine). In the future, you may need to have a session implant on the type of operating system the test is for, particularly for Windows.

Tests are implemented using Ward. The tests have been tagged so you can run all the tests or just the tests you need. Recommendation is to run all tests when making a major change.

  • ward : All tests
  • ward --tags client: Client tests only
  • ward --tags interactive: InteractiveObject tests

Metadata

Release files for sliver-py 0.0.19

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

Source distribution (sdist)

Source distribution for sliver-py 0.0.19
File Size Uploaded
sliver_py-0.0.19.tar.gz 81.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sliver-py 0.0.19
File Interpreter ABI Platform
sliver_py-0.0.19-py3-none-any.whl Python 3 none any Details

Total release size: 169.4 kB

Release files / sliver_py-0.0.19.tar.gz

Download URL sliver_py-0.0.19.tar.gz
Size 81.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8145a4b1c9961e4704a98dd1f0ece2e975fdfed79e7f73a24b4e3fc9b5a84c42
BLAKE2b-256 checksum
How to use checksums
5ae55134ee25cd601344516700e7b7ab076f8572dc955b7672048645fa17bfd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / sliver_py-0.0.19-py3-none-any.whl

Download URL sliver_py-0.0.19-py3-none-any.whl
Size 88.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a1c4a8428d25a2a5d000d3e73f510bd65910bfbbe928738061be79ee0ea17e0
BLAKE2b-256 checksum
How to use checksums
a3efbfe88124fd526af4ac633975a1a7dfbf62ed3fb8f9a9706fc778a3a504f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.0.19 This release

2 release files

0.0.18

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.12

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

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