Clients

This module is used to connect to client gRPC APIs. Users should only need to use the SliverClient class. The BaseClient class is not intended to be directly but can be inherited by other Client classes.

BaseClient

class sliver.client.BaseClient(config)[source]
CERT_COMMON_NAME = 'multiplayer'
KEEP_ALIVE_TIMEOUT = 10000
MAX_MESSAGE_LENGTH = 2147483647
property credentials: ChannelCredentials
Return type

ChannelCredentials

is_connected()[source]
Return type

bool

property options
property target: str
Return type

str

SliverClient

class sliver.SliverClient(config)[source]

Bases: BaseClient

Asyncio client implementation

async add_website_content(name, web_path, content_type, content, timeout=60)[source]

Add content to a specific website

Parameters
  • name (str) – Name of the website to add the content to

  • web_path (str) – Bind content to web path

  • content_type (str) – Specify the Content-type response HTTP header

  • content (bytes) – The raw response content

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Website object

Return type

client_pb2.Website

async beacon_by_id(beacon_id, timeout=60)[source]

Get the beacon information from a beacon ID

Parameters
  • beacon_id (str) – Beacon ID

  • timeout – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Beacon object

Return type

Union[client_pb2.Beacon, None]

beacon_event_types = ['beacon-registered']
async beacon_task_content(task_id, timeout=60)[source]

Get a list of tasks for a beacon

Parameters
  • task_id (sts) – Task ID get contents for

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of protobuf Task objects

Return type

List[client_pb2.Task]

async beacon_tasks(beacon_id, timeout=60)[source]

Get a list of tasks for a beacon

Parameters
  • beacon_id (str) – Beacon ID to get tasks for

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of protobuf Task objects

Return type

List[client_pb2.Task]

async beacons(timeout=60)[source]

Get a list of active beacons

Parameters

timeout – gRPC timeout, defaults to 60 seconds

Return type

List[client_pb2.Beacon]

async canaries(timeout=60)[source]

Get a list of canaries that have been generated during implant builds, includes metadata about those canaries

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of Protobuf DNSCanary objects

Return type

List[client_pb2.DNSCanary]

canary_event_types = ['canary']
async connect()[source]

Establish a connection to the Sliver server

Returns

Protobuf Version object, containing the server’s version information

Return type

client_pb2.Version

async delete_implant_build(implant_name, timeout=60)[source]

Delete a historical implant build from the server by name

Parameters
  • implant_name (str) – The name of the implant build to delete

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Return type

None

async delete_implant_profile(profile_name, timeout=60)[source]

Delete an implant configuration profile by name

Parameters
  • profile_name (str) – Name of the profile to delete

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Return type

None

async events()[source]

All events

Yield

A stream of events

Return type

client_pb2.Event

async generate_implant(config, timeout=360)[source]

Generate a new implant using a given configuration

Parameters
  • config (client_pb2.ImplantConfig) – Protobuf ImplantConfig object

  • timeout (int, optional) – gRPC timeout, defaults to 360

Returns

Protobuf Generate object containing the generated implant

Return type

client_pb2.Generate

async generate_msf_stager(arch, format, host, port, os, protocol, badchars, timeout=60)[source]

Create a Metasploit stager (if available on the server)

Parameters
  • arch (str) – CPU architecture

  • format (str) – Binary format (MSF)

  • host (str) – LHOST (MSF)

  • port (int) – LPORT (MSF)

  • os (str) – Operating System (MSF)

  • protocol (client_pb2.StageProtocol) – Stager protocol (Protobuf StageProtocol object)

  • badchars (list, optional) – Bad characters, defaults to []

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf MsfStager object

Return type

client_pb2.MsfStager

async generate_wg_client_config(timeout=60)[source]

Generate a new WireGuard client configuration files

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf WGClientConfig object

Return type

client_pb2.WGClientConfig

async generate_wg_ip(timeout=60)[source]

Generate a unique IP address for use with WireGuard

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf UniqueWGIP object

Return type

client_pb2.UniqueWGIP

async implant_builds(timeout=60)[source]

Get information about historical implant builds

Returns

Protobuf Map object, the keys are implant names the values are implant configs

Return type

Dict[str, client_pb2.ImplantConfig]

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

async implant_profiles(timeout=60)[source]

Get a list of all implant configuration profiles on the server

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of Protobuf ImplantProfile objects

Return type

List[client_pb2.ImplantProfile]

async interact_beacon(beacon_id, timeout=60)[source]

Interact with a beacon, returns an InteractiveBeacon

Parameters
  • beacon_id (str) – Beacon ID

  • timeout – gRPC timeout, defaults to 60 seconds

Returns

An interactive beacon

Return type

Optional[AsyncInteractiveBeacon]

async interact_session(session_id, timeout=60)[source]

Interact with a session, returns an InteractiveSession

Parameters
  • session_id (str) – Session ID

  • timeout – gRPC timeout, defaults to 60 seconds

Returns

An interactive session

Return type

Optional[InteractiveSession]

async job_by_id(job_id, timeout=60)[source]

Get job by id

Parameters
  • job_id (str) – Beacon ID to get tasks for

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of protobuf Job objects

Return type

List[client_pb2.Job]

async job_by_port(job_port, timeout=60)[source]

Get job by port

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of protobuf Job objects

Return type

List[client_pb2.Job]

job_event_types = ['job-started', 'job-stopped']
async jobs(timeout=60)[source]

Get a list of active jobs

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of protobuf Job objects

Return type

List[client_pb2.Job]

async kill_beacon(beacon_id, timeout=60)[source]

Kill a beacon

Parameters
  • beacon_id (str) – Numeric beacon ID to remove

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Return type

None

async kill_job(job_id, timeout=60)[source]

Kill a job

Parameters
  • job_id (int) – Numeric job ID to kill

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf KillJob object

Return type

client_pb2.KillJob

async kill_session(session_id, force=False, timeout=60)[source]

Kill a session

Parameters
  • session_id (str) – Session ID to kill

  • force (bool, optional) – Force kill the session, defaults to False

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Return type

None

async on(event_types)[source]

Iterate on a specific event or list of events

Parameters

event_types (Union[str, List[str]]) – An event type or list of event types

Yield

A stream of events of the given type(s)

Return type

client_pb2.Event

async operators(timeout=60)[source]

Get a list of operators and their online status

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of protobuf Operator objects

Return type

List[client_pb2.Operator]

async regenerate_implant(implant_name, timeout=60)[source]

Regenerate an implant binary given the implants “name”

Parameters
  • implant_name (str) – The name of the implant to regenerate

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Generate object

Return type

client_pb2.Generate

async remove_website(name, timeout=60)[source]

Remove an entire website and its content

Parameters
  • name (str) – The name of the website to remove

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Return type

None

async remove_website_content(name, paths, timeout=60)[source]

Remove content from a specific website

Parameters
  • name (str) – The name of the website from which to remove the content

  • paths (List[str]) – A list of paths to content that should be removed from the website

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Website object

Return type

client_pb2.Website

async rename_beacon(beacon_id, name, timeout=60)[source]

Rename a beacon

Parameters
  • beacon_id (str) – Beacon ID to update

  • name (str) – Rename beacon to this value

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

None

Return type

None

async rename_session(session_id, name, timeout=60)[source]

Rename a session

Parameters
  • session_id (str) – Session ID to update

  • name (str) – Rename session to this value

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

None

Return type

None

async save_implant_profile(profile, timeout=60)[source]

Save an implant configuration profile to the server

Parameters
  • profile (client_pb2.ImplantProfile) – An implant configuration profile (a Protobuf ImplantProfile object)

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf ImplantProfile object

Return type

client_pb2.ImplantProfile

async session_by_id(session_id, timeout=60)[source]

Get the session information from a session ID

Parameters
  • session_id (str) – Session ID

  • timeout – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Session object

Return type

Optional[client_pb2.Session]

session_event_types = ['session-connected', 'session-disconnected']
async sessions(timeout=60)[source]

Get a list of active sessions

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of protobuf Session objects

Return type

List[client_pb2.Session]

async shellcode(data, function_name, arguments='', timeout=60)[source]

Generate Donut shellcode

Parameters
  • data (bytes) – The DLL file to wrap in a shellcode loader

  • function_name (str) – Function to call on the DLL

  • arguments (str) – Arguments to the function called

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf ShellcodeRDI object

Return type

client_pb2.ShellcodeRDI

async start_dns_listener(domains, host='0.0.0.0', port=53, canaries=True, persistent=False, enforce_otp=True, timeout=60)[source]

Start a DNS C2 listener

Parameters
  • domains (List[str]) – C2 domains to listen for

  • canaries (bool) – Enable/disable DNS canaries

  • host (str) – Host interface to bind the listener to, an empty string will bind to all interfaces

  • port (int) – TCP port number to start listener on

  • persistent (bool, optional) – Register the listener as a persistent job (automatically start with server), defaults to False

  • enforce_otp (bool, optional) – Enforce OTP auth for DNS C2, defaults to True

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf DNSListener object

Return type

client_pb2.DNSListener

async start_http_listener(host='0.0.0.0', port=80, website='', domain='', persistent=False, timeout=60)[source]

Start an HTTP C2 listener

Parameters
  • host (str) – Host interface to bind the listener to, an empty string will bind to all interfaces

  • port (int) – TCP port number to start listener on

  • website (str) – Name of the “website” to host on listener

  • domain (str) – Domain name for HTTP server (one domain per listener)

  • persistent (bool, optional) – Register the listener as a persistent job (automatically start with server), defaults to False

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf HTTPListener object (NOTE: HTTP/HTTPS both return HTTPListener objects)

Return type

client_pb2.HTTPListener

async start_http_stager_listener(host, port, data, timeout=60)[source]

Start an HTTP stager listener

Parameters
  • host (str) – Host interface to bind the listener to, an empty string will bind to all interfaces

  • port (int) – TCP port number to start listener on

  • data (bytes) – Binary data of stage to host on listener

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf StagerListener object

Return type

client_pb2.StagerListener

async start_https_listener(host='0.0.0.0', port=443, website='', domain='', cert=b'', key=b'', acme=False, persistent=False, enforce_otp=True, randomize_jarm=True, long_poll_timeout=1, long_poll_jitter=2, timeout=60)[source]

Start an HTTPS C2 listener

Parameters
  • domain (str) – Domain name for HTTPS server (one domain per listener)

  • host (str) – Host interface to bind the listener to, an empty string will bind to all interfaces

  • port (int) – TCP port number to start listener on

  • website (str) – Name of the “website” to host on listener

  • cert (bytes) – TLS certificate (leave blank to generate self-signed certificate)

  • key (bytes) – TLS private key (leave blank to generate self-signed certificate)

  • acme (bool) – Automatically provision TLS certificate using ACME (i.e., Let’s Encrypt)

  • persistent (bool, optional) – Register the listener as a persistent job (automatically start with server), defaults to False

  • enforce_otp (bool, optional) – Enforce OTP auth for HTTPS C2, defaults to True

  • randomize_jarm (bool, optional) – Randomize JARM fingerprint for HTTPS C2, defaults to True

  • long_poll_timeout (int, optional) – Long poll timeout for HTTPS C2, defaults to 1

  • long_poll_jitter (int, optional) – Long poll jitter for HTTPS C2, defaults to 2

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf HTTPListener object (NOTE: HTTP/HTTPS both return HTTPListener objects)

Return type

client_pb2.HTTPListener

async start_https_stager_listener(host, port, data, cert, key, acme, timeout=60)[source]

Start an HTTPS stager listener

Parameters
  • host (str) – Host interface to bind the listener to, an empty string will bind to all interfaces

  • port (int) – TCP port number to start listener on

  • data (bytes) – Binary data of stage to host on listener

  • cert (bytes) – TLS certificate, leave blank to start listener as HTTP

  • key (bytes) – TLS key, leave blank to start listener as HTTP

  • acme (bool) – Automatically provision TLS certificate using ACME (i.e., Let’s Encrypt)

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf StagerListener object

Return type

client_pb2.StagerListener

async start_mtls_listener(host='0.0.0.0', port=8888, persistent=False, timeout=60)[source]

Start a mutual TLS (mTLS) C2 listener

Parameters
  • host (str) – Host interface to bind the listener to, an empty string will bind to all interfaces

  • port (int) – TCP port number to start listener on

  • persistent (bool, optional) – Register the listener as a persistent job (automatically start with server), defaults to False

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf MTLSListener object

Return type

client_pb2.MTLSListener

async start_tcp_stager_listener(host, port, data, timeout=60)[source]

Start a TCP stager listener

Parameters
  • host (str) – Host interface to bind the listener to, an empty string will bind to all interfaces

  • port (int) – TCP port number to start listener on

  • data (bytes) – Binary data of stage to host on listener

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf StagerListener object

Return type

client_pb2.StagerListener

async start_wg_listener(tun_ip=None, host='0.0.0.0', port=53, n_port=8888, key_port=1337, persistent=False, timeout=60)[source]

Start a WireGuard (wg) C2 listener

Parameters
  • tun_ip (str) – Virtual TUN IP listen address

  • port (int) – TCP port number to start listener on

  • port – UDP port to start listener on

  • n_port (int) – Virtual TUN port number

  • key_port (int) – Virtual TUN port number for key exchanges

  • persistent (bool, optional) – Register the listener as a persistent job (automatically start with server), defaults to False

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf WGListener object

Return type

client_pb2.WGListener

async update_website(website, timeout=60)[source]

Update an entire website object on the server

Parameters
  • website (client_pb2.Website) – The updated Protobuf Website object

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Website object

Return type

client_pb2.Website

async update_website_content(name, web_path, content_type, content, timeout=60)[source]

Update content on a specific website / web path

Parameters
  • name (str) – Name of the website to add the content to

  • web_path (str) – Bind content to web path

  • content_type (str) – Specify the Content-type response HTTP header

  • content (bytes) – The raw response content

  • timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Website object

Return type

client_pb2.Website

async version(timeout=60)[source]

Get server version information

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

Protobuf Version object

Return type

client_pb2.Version

async websites(timeout=60)[source]

Get a list of websites

Parameters

timeout (int, optional) – gRPC timeout, defaults to 60 seconds

Returns

List of Protobuf Website objects

Return type

List[client_pb2.Website]