Skip to content

sliverarmory/sliver-script

Repository files navigation

Sliver Script

Sliver-script is a TypeScript/JavaScript client library for Sliver, it can be used to automate any operator interaction with Sliver. Sliver-script uses existing Sliver client configuration files and connects to servers using gRPC over Mutual-TLS. It also provides RxJS abstractions for easy interactions with real-time components.

This library targets modern Sliver protobuf/gRPC APIs and provides a strongly-typed TypeScript-first client.

Publish npm version License: GPL v3

Install

Node v24 or later is required for this package, and it can be installed via npm:

npm install sliver-script

TypeScript Example

Basic

import { SliverClient, ParseConfigFile } from 'sliver-script'

(async function() {
    
    const config = await ParseConfigFile('./localhost.cfg')
    const client = new SliverClient(config)

    await client.connect()

    const version = await client.getVersion()
    console.log(version)

    const sessions = await client.sessions()
    console.log(`Sessions: ${sessions.length}`)

    await client.disconnect()

})()

Monitor Events in Real-time

import { SliverClient, ParseConfigFile } from 'sliver-script'

(async function() {

    const config = await ParseConfigFile('./localhost.cfg')

    const client = new SliverClient(config)
    await client.connect()
    client.event$.subscribe((event) => {
        console.log(event)
    })

})()

Automatically Interact with New Sessions

import { SliverClient, ParseConfigFile } from 'sliver-script'


(async function() {

    const config = await ParseConfigFile('./localhost.cfg')
    const client = new SliverClient(config);
    await client.connect()

    console.log('Waiting for new sessions ...')
    client.session$.subscribe(async (event) => {
        console.log(`New session #${event.Session.ID}!`)
        const session = client.interactSession(event.Session.ID)
        const ls = await session.ls('.')
        console.log(`Path: ${ls.Path}`)
        ls.Files.forEach(file => {
            console.log(`Name: ${file.Name} (Size: ${file.Size})`)
        })
    })

})()

JavaScript Example

const sliver = require('sliver-script')

(async function() { 

    const config = await sliver.ParseConfigFile('./localhost.cfg')
    const client = new sliver.SliverClient(config)
    await client.connect()

    console.log('Waiting for new sessions ...')

    client.session$.subscribe(async (event) => {

        console.log(`New session #${event.Session.ID}!`)

        const session = client.interactSession(event.Session.ID)
        const ls = await session.ls('.')
        console.log(`Path: ${ls.Path}`)
        ls.Files.forEach(file => {
            console.log(`Name: ${file.Name} (Size: ${file.Size})`)
        })
        
    })

})()

About

TypeScript/JavaScript client libraries for Sliver

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors