mirror of
https://github.com/moloch--/sliver-script
synced 2026-06-08 16:08:26 +00:00
222 lines
11 KiB
HTML
222 lines
11 KiB
HTML
<!doctype html>
|
|
<html class="default no-js">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<title>sliver-script</title>
|
|
<meta name="description" content="Documentation for sliver-script">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="assets/css/main.css">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="tsd-page-toolbar">
|
|
<div class="container">
|
|
<div class="table-wrap">
|
|
<div class="table-cell" id="tsd-search" data-index="assets/js/search.json" data-base=".">
|
|
<div class="field">
|
|
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
|
|
<input id="tsd-search-field" type="text" />
|
|
</div>
|
|
<ul class="results">
|
|
<li class="state loading">Preparing search index...</li>
|
|
<li class="state failure">The search index is not available</li>
|
|
</ul>
|
|
<a href="index.html" class="title">sliver-script</a>
|
|
</div>
|
|
<div class="table-cell" id="tsd-widgets">
|
|
<div id="tsd-filter">
|
|
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
|
|
<div class="tsd-filter-group">
|
|
<div class="tsd-select" id="tsd-filter-visibility">
|
|
<span class="tsd-select-label">All</span>
|
|
<ul class="tsd-select-list">
|
|
<li data-value="public">Public</li>
|
|
<li data-value="protected">Public/Protected</li>
|
|
<li data-value="private" class="selected">All</li>
|
|
</ul>
|
|
</div>
|
|
<input type="checkbox" id="tsd-filter-inherited" checked />
|
|
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
|
|
<input type="checkbox" id="tsd-filter-externals" checked />
|
|
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
|
|
<input type="checkbox" id="tsd-filter-only-exported" />
|
|
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
|
|
</div>
|
|
</div>
|
|
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="tsd-page-title">
|
|
<div class="container">
|
|
<ul class="tsd-breadcrumb">
|
|
<li>
|
|
<a href="globals.html">Globals</a>
|
|
</li>
|
|
</ul>
|
|
<h1>sliver-script</h1>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<div class="container container-main">
|
|
<div class="row">
|
|
<div class="col-8 col-content">
|
|
<div class="tsd-panel tsd-typography">
|
|
<a href="#sliver-script" id="sliver-script" style="color: inherit; text-decoration: none;">
|
|
<h1>Sliver Script</h1>
|
|
</a>
|
|
<p>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 <a href="https://www.learnrxjs.io/">RxJS</a> abstractions for easy interactions with real-time components.</p>
|
|
<p><a href="https://www.gnu.org/licenses/gpl-3.0"><img src="https://img.shields.io/badge/License-GPLv3-blue.svg" alt="License: GPL v3"></a></p>
|
|
<a href="#install" id="install" style="color: inherit; text-decoration: none;">
|
|
<h3>Install</h3>
|
|
</a>
|
|
<p>For best compatibility use Node v14+ this package is available via npm:</p>
|
|
<p><code>npm install sliver-script</code></p>
|
|
<a href="#typescript-example" id="typescript-example" style="color: inherit; text-decoration: none;">
|
|
<h3>TypeScript Example</h3>
|
|
</a>
|
|
<a href="#basic" id="basic" style="color: inherit; text-decoration: none;">
|
|
<h4>Basic</h4>
|
|
</a>
|
|
<pre><code class="language-typescript"><span class="hljs-keyword">import</span> { SliverClient, ParseConfigFile } <span class="hljs-keyword">from</span> <span class="hljs-string">'sliver-script'</span>
|
|
|
|
(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
|
|
|
|
<span class="hljs-keyword">const</span> config = <span class="hljs-keyword">await</span> ParseConfigFile(<span class="hljs-string">'./moloch_localhost.cfg'</span>)
|
|
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> SliverClient(config)
|
|
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Connecting to <span class="hljs-subst">${client.host()}</span> ...`</span>)
|
|
<span class="hljs-keyword">await</span> client.connect()
|
|
|
|
<span class="hljs-keyword">const</span> sessions = <span class="hljs-keyword">await</span> client.sessions()
|
|
<span class="hljs-built_in">console</span>.log(sessions)
|
|
|
|
})()</code></pre>
|
|
<a href="#monitor-events-in-real-time" id="monitor-events-in-real-time" style="color: inherit; text-decoration: none;">
|
|
<h4>Monitor Events in Real-time</h4>
|
|
</a>
|
|
<pre><code class="language-typescript"><span class="hljs-keyword">import</span> { SliverClient, ParseConfigFile } <span class="hljs-keyword">from</span> <span class="hljs-string">'sliver-script'</span>
|
|
|
|
(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
|
|
|
|
<span class="hljs-keyword">const</span> config = <span class="hljs-keyword">await</span> ParseConfigFile(<span class="hljs-string">'./moloch_localhost.cfg'</span>)
|
|
|
|
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> SliverClient(config)
|
|
<span class="hljs-keyword">await</span> client.connect()
|
|
client.event$.subscribe(<span class="hljs-function">(<span class="hljs-params">event</span>) =></span> {
|
|
<span class="hljs-built_in">console</span>.log(event)
|
|
})
|
|
|
|
})()</code></pre>
|
|
<a href="#automatically-interact-with-new-sessions" id="automatically-interact-with-new-sessions" style="color: inherit; text-decoration: none;">
|
|
<h4>Automatically Interact with New Sessions</h4>
|
|
</a>
|
|
<pre><code class="language-typescript"><span class="hljs-keyword">import</span> { SliverClient, ParseConfigFile } <span class="hljs-keyword">from</span> <span class="hljs-string">'sliver-script'</span>
|
|
|
|
|
|
(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
|
|
|
|
<span class="hljs-keyword">const</span> config = <span class="hljs-keyword">await</span> ParseConfigFile(<span class="hljs-string">'moloch_localhost.cfg'</span>)
|
|
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> SliverClient(config);
|
|
<span class="hljs-keyword">await</span> client.connect()
|
|
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Waiting for new sessions ...'</span>)
|
|
client.session$.subscribe(<span class="hljs-keyword">async</span> (event) => {
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`New session #<span class="hljs-subst">${event.getSession().getId()}</span>!`</span>)
|
|
<span class="hljs-keyword">const</span> session = <span class="hljs-keyword">await</span> client.interactWith(event.getSession())
|
|
<span class="hljs-keyword">const</span> ls = <span class="hljs-keyword">await</span> session.ls()
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Path: <span class="hljs-subst">${ls.getPath()}</span>`</span>)
|
|
ls.getFilesList().forEach(<span class="hljs-function"><span class="hljs-params">file</span> =></span> {
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Name: <span class="hljs-subst">${file.getName()}</span> (Size: <span class="hljs-subst">${file.getSize()}</span>)`</span>)
|
|
})
|
|
})
|
|
|
|
})()</code></pre>
|
|
<a href="#javascript-example" id="javascript-example" style="color: inherit; text-decoration: none;">
|
|
<h3>JavaScript Example</h3>
|
|
</a>
|
|
<pre><code class="language-javascript"><span class="hljs-keyword">const</span> sliver = <span class="hljs-built_in">require</span>(<span class="hljs-string">'sliver-script'</span>)
|
|
|
|
(<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
|
|
|
|
<span class="hljs-keyword">const</span> config = <span class="hljs-keyword">await</span> sliver.ParseConfigFile(<span class="hljs-string">'./moloch_localhost.cfg'</span>)
|
|
<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> sliver.SliverClient(config)
|
|
<span class="hljs-keyword">await</span> client.connect()
|
|
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Waiting for new sessions ...'</span>)
|
|
|
|
client.session$.subscribe(<span class="hljs-keyword">async</span> (event) => {
|
|
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`New session #<span class="hljs-subst">${event.getSession().getId()}</span>!`</span>)
|
|
|
|
<span class="hljs-keyword">const</span> session = <span class="hljs-keyword">await</span> client.interactWith(event.getSession())
|
|
<span class="hljs-keyword">const</span> ls = <span class="hljs-keyword">await</span> session.ls()
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Path: <span class="hljs-subst">${ls.getPath()}</span>`</span>)
|
|
ls.getFilesList().forEach(<span class="hljs-function"><span class="hljs-params">file</span> =></span> {
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Name: <span class="hljs-subst">${file.getName()}</span> (Size: <span class="hljs-subst">${file.getSize()}</span>)`</span>)
|
|
})
|
|
|
|
})
|
|
|
|
})()</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
|
<nav class="tsd-navigation primary">
|
|
<ul>
|
|
<li class="globals ">
|
|
<a href="globals.html"><em>Globals</em></a>
|
|
</li>
|
|
<li class=" tsd-kind-module">
|
|
<a href="modules/_client_.html">"client"</a>
|
|
</li>
|
|
<li class=" tsd-kind-module">
|
|
<a href="modules/_config_.html">"config"</a>
|
|
</li>
|
|
<li class=" tsd-kind-module">
|
|
<a href="modules/_events_index_.html">"events/index"</a>
|
|
</li>
|
|
<li class=" tsd-kind-module">
|
|
<a href="modules/_index_.html">"index"</a>
|
|
</li>
|
|
<li class=" tsd-kind-module">
|
|
<a href="modules/_tests_config_test_.html">"tests/config.test"</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
<nav class="tsd-navigation secondary menu-sticky">
|
|
<ul class="before-current">
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<footer class="with-border-bottom">
|
|
<div class="container">
|
|
<h2>Legend</h2>
|
|
<div class="tsd-legend-group">
|
|
<ul class="tsd-legend">
|
|
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
|
|
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
|
|
</ul>
|
|
<ul class="tsd-legend">
|
|
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
|
|
</ul>
|
|
<ul class="tsd-legend">
|
|
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
|
|
</ul>
|
|
<ul class="tsd-legend">
|
|
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
<div class="container tsd-generator">
|
|
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
|
|
</div>
|
|
<div class="overlay"></div>
|
|
<script src="assets/js/main.js"></script>
|
|
</body>
|
|
</html> |