Package: sliver-py
SliverPySliverPy is a Python gRPC client library forSliver. 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.InstallInstall the package using pip, for best compatibility use Sliver Server v1.5.29 or later:pip3 install sliver-pyExamplesFor more examples and details please read theproject documentation.Interact with Sessions#!/usr/bin/env python3importosimportasynciofromsliverimportSliverClientConfig,SliverClientCONFIG_DIR=os.path.join(os.path.expanduser("~"),".sliver-client","configs")DEFAULT_CONFIG=os.path.join(CONFIG_DIR,"default.cfg")asyncdefmain():config=SliverClientConfig.parse_config_file(DEFAULT_CONFIG)client=AsyncSliverClient(config)print('[*] Connected to server ...')awaitclient.connect()sessions=awaitclient.sessions()print('[*] Sessions:%r'%sessions)iflen(sessions):print('[*] Interacting with session%s',sessions[0].ID)interact=awaitclient.interact_session(sessions[0].ID)ls=awaitinteract.ls()print('[*] ls:%r'%ls)if__name__=='__main__':asyncio.run(main())Interact with Beacons#!/usr/bin/env python3importosimportasynciofromsliverimportSliverClientConfig,SliverClientCONFIG_DIR=os.path.join(os.path.expanduser("~"),".sliver-client","configs")DEFAULT_CONFIG=os.path.join(CONFIG_DIR,"default.cfg")asyncdefmain():config=SliverClientConfig.parse_config_file(DEFAULT_CONFIG)client=SliverClient(config)print('[*] Connected to server ...')awaitclient.connect()version=awaitclient.version()print('[*] Server version:%s'%version)beacons=awaitclient.beacons()print('[*] Beacons:%r'%beacons)iflen(beacons):print('[*] Interacting with beacon:%r'%beacons[0].ID)interact=awaitclient.interact_beacon(beacons[0].ID)ls_task=awaitinteract.ls()print('[*] Created ls task:%r'%ls_task)print('[*] Waiting for task results ...')ls=awaitls_taskprint('[*] ls:%r'%ls)if__name__=='__main__':asyncio.run(main())DevelopmentThe development environment has migrated tohatchand the installation instructions can be foundhere.Note on VS CodeUnfortunately, 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 updateSetting up Hatch environmentOnce installed, runhatch -e dev shellto 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-- runsblackandisortfor formattingDocker/WSL2A 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.shcontains a modified version of the official Sliver installation script that does not create asystemdbased 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'smulti-player mode. Thesliver_installscript is purely for local development convenience.Updating protobufsThis should only be necessary when changes are made to Sliver's protobuf. Runningscripts/protobufgen.pywill updatesliver-pyprotobuf files. Ensure that the.pyitype hints are generated also.Running testsTo 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 usingWard. 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 testsward --tags client: Client tests onlyward --tags interactive: InteractiveObject tests