# sockz

> Fun with sockets

Latest version **4.1.2** (published 2022-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install sockz
pnpm add sockz
yarn add sockz
bun add sockz
```

Provides the commands `sockz`, `sockz-agent`, `sockz-creds`, `sockz-server`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.2 |
| Published | 2022-03-12 |
| First published | 2022-03-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 20 |
| Unpacked size | 372 KB |
| Known vulnerabilities | 0 (+3 in 3 direct dependencies) |
| Install scripts | no |
| Author | CMR1 |
| Maintainers | charliemcclung |

## Links

- npm: https://www.npmjs.com/package/sockz
- npm.io page: https://npm.io/package/sockz

## Dependencies (20)

- [ws](https://npm.io/package/ws.md) ^8.5.0
- [pem](https://npm.io/package/pem.md) ^1.14.6
- [pug](https://npm.io/package/pug.md) ^3.0.2
- [cors](https://npm.io/package/cors.md) ^2.8.5
- [jose](https://npm.io/package/jose.md) ^4.6.0
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [colors](https://npm.io/package/colors.md) ^1.4.0
- [dotenv](https://npm.io/package/dotenv.md) ^16.0.0
- [stripe](https://npm.io/package/stripe.md) ^8.208.0
- [express](https://npm.io/package/express.md) ^4.17.3
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.5
- [firebase](https://npm.io/package/firebase.md) ^9.6.8
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.1
- [jwks-rsa](https://npm.io/package/jwks-rsa.md) ^2.0.5
- [express-jwt](https://npm.io/package/express-jwt.md) ^6.1.1
- [ansi-to-html](https://npm.io/package/ansi-to-html.md) ^0.7.2
- [express-session](https://npm.io/package/express-session.md) ^1.17.2
- [express-jwt-authz](https://npm.io/package/express-jwt-authz.md) ^2.4.1
- [express-openid-connect](https://npm.io/package/express-openid-connect.md) ^2.7.1
- [@google-cloud/firestore](https://npm.io/package/@google-cloud/firestore.md) ^5.0.2

## Recent versions

- 4.1.2 (latest) — 2022-03-12
- 4.1.1 — 2022-03-12
- 4.1.0 — 2022-03-12
- 4.0.0 — 2022-03-12
- 3.1.2 — 2022-03-09
- 3.1.1 — 2022-03-09
- 3.1.0 — 2022-03-09
- 3.0.0 — 2022-03-09
- 2.1.0 — 2022-03-06
- 2.0.0 — 2022-03-06
- 1.3.0 — 2022-03-05
- 1.2.1 — 2022-03-05
- 1.2.0 — 2022-03-05
- 1.1.1 — 2022-03-05
- 1.1.0 — 2022-03-05
- … 5 more at https://npm.io/package/sockz/versions

## README

# ts-sockz

TypeScript - Fun with sockets

### Contents
- [Simple](#simple)
- [Options](#options)
- [Defaults](#defaults)
- [Advanced](#advanced)
- [Environment](#environment)
- [WebClient](#webclient)
- [Documentation](https://cmr1.github.io/ts-sockz)

## Simple

```bash
# Start a local control server
npx sockz
```

```bash
# Start a local control agent
npx sockz agent
```

```bash
# Connect to control panel (netcat)
netcat localhost 2222
# Other TCP connection (telnet)
telnet localhost 2222
```

Visit the web client console:

- [localhost:4040](http://localhost:4040)

## Options

```bash
npx sockz <role> <host> <agentPort> <clientPort> <webPort> <prompt>
```

Allowed values:

- role: `server | agent`
- host: `any<hostname | ipaddress>`
- agentPort: `number`
- clientPort: `number`
- webPort: `number`
- prompt: `string`


## Defaults

- role: `server`
- host: `127.0.0.1`
- agentPort: `1111`
- clientPort: `2222`
- webPort: `4040`
- prompt: `"sockz> "`


## Advanced

To be able to connect remotely, use host `0.0.0.0`

```bash
# Start remote control server
npx sockz server 0.0.0.0
```

To customize agent & client ports:

```bash
# Start control server with custom ports
npx sockz server 0.0.0.0 7331 1337
# Connect agent
npx sockz agent <host> 7331
# Connect session
netcat <host> 1337
```

To customize the session prompt:

```bash
# Start a server and use poop for client prompt
npx sockz server 0.0.0.0 1111 2222 4040 "💩 "

# Connect an authorized client
ncat --ssl --ssl-cert certs/client_cert.pem --ssl-key certs/client_key.pem localhost 2222
# Authorized client connection output
Authorized: Client
[id] SockzClient is ready
sockz> help
HELP: Commands: reg, whoami, exit, ping, info, help, ls, use
sockz>

# Connect an unauthorized client (use agent key)
ncat --ssl --ssl-cert certs/agent_cert.pem --ssl-key certs/agent_key.pem localhost 2222
# Unuthorized client connection output
Unauthorized: Agent (DEPTH_ZERO_SELF_SIGNED_CERT)
```

Install globally to run without `npx`

```bash
npm install --global sockz
# Or shortcut (same as above)
npm i -g sockz
```

```bash
# Start a server
sockz server
# Start an agent
sockz agent
```

*Supports all the same options*

Also available from docker:

https://github.com/cmr1/docker-sockz

```
docker run cmr1/sockz
```

## Environment

**Additional configuration options available as env vars:**

- *All cert/key paths are resolved from `certs/` directory*

```bash
# Server environment variables
SERVER_HOST_NAME = 'localhost'
SERVER_CERT_NAME = 'server_cert.pem'
SERVER_KEY_NAME = 'server_key.pem'
# Comma separated list of ca cert names (required for auth)
SERVER_CA_NAME = 'server_cert.pem'

# Agent environment variables
AGENT_CERT_NAME = 'agent_cert.pem'
AGENT_KEY_NAME = 'agent_key.pem'
# Comma separated list of ca cert names (optional)
AGENT_CA_LIST = ''
```

## WebClient

Visit [https://localhost:4040/](https://localhost:4040/) in your browser

*Self-signed cert, will have a warning*

---
_Source: https://npm.io/package/sockz · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
