Skip to main content

Reverse PTY shell over WebSocket

Project description

revpty

Reverse PTY shell over WebSocket with web GUI, file transfer, and HTTP tunneling.

Installation

pip install revpty

Quick Start

1. Start server:

revpty-server --host 0.0.0.0 --port 8765

2. Start client (on target machine):

revpty-client --server ws://your-server:8765 --session my-session

3. Attach to PTY (from your machine):

revpty-attach --server ws://your-server:8765 --session my-session

Or use the Web GUI:

http://your-server:8765/gui?session=my-session

CLI Reference

revpty-server

revpty-server --host 0.0.0.0 --port 8765 [--secret YOUR_SECRET] [--cache-size 131072]
Option Default Description
--host 0.0.0.0 Listen address
--port 8765 Listen port
--secret - Authentication secret
--cache-size 131072 Output cache size (bytes)
--install - Install as systemd service
--user - Install as user-level service

revpty-client

revpty-client --server ws://server:8765 --session NAME [options]
Option Description
--server Server URL (required)
--session Session name (required)
--secret Authentication secret
--exec Shell to execute (default: /bin/bash)
--proxy HTTP proxy URL
--cf-client-id Cloudflare Access Client ID
--cf-client-secret Cloudflare Access Client Secret
--install Install as systemd service
--user Install as user-level service

revpty-attach

revpty-attach --server ws://server:8765 --session NAME [options]

Options same as revpty-client (except --exec).

Features

Web GUI

Access the web-based terminal at:

http://your-server:8765/gui?session=my-session&secret=YOUR_SECRET

Features:

  • Terminal emulator with resize support
  • File browser (upload/download)
  • Multiple shell sessions
  • HTTP tunnel management
  • Share links (read-only or read-write)

Cloudflare Access Authentication

For servers protected by Cloudflare Zero Trust:

revpty-client --server wss://your-server:8765 --session my-session \
    --cf-client-id YOUR_CLIENT_ID.access \
    --cf-client-secret YOUR_CLIENT_SECRET

File Transfer

Via Web GUI:

  • Browse files in the file panel
  • Upload: click upload button or drag & drop
  • Download: click file name
  • Large files use chunked transfer with CRC32 verification

Chunked transfer features:

  • Automatic resume on reconnect
  • Adaptive chunk size based on RTT
  • Progress bar display

HTTP Tunneling

Forward HTTP requests to services on the client machine:

Via Web GUI:

  1. Click "Tunnel" button
  2. Enter local service port (e.g., 8080)
  3. Access via /tunnel/{tunnel_id}/

Via API:

# Create tunnel
curl -X POST http://server:8765/api/tunnels \
  -H "Content-Type: application/json" \
  -H "X-Revpty-Secret: YOUR_SECRET" \
  -d '{"session_id":"my-session","local_port":8080}'

# Response: {"tunnel_id":"a1b2c3d4","url":"/tunnel/a1b2c3d4/"}

# Access tunnel
curl http://server:8765/tunnel/a1b2c3d4/

Multiple Shell Sessions

From the Web GUI, click "+" to create additional shell sessions. Each runs independently with its own PTY.

Reconnect & Output Buffer

  • Client-side buffer: Output during network disconnect is buffered and sent on reconnect
  • Server-side cache: Recent output cached for replay when attaching
  • Auto-reconnect: Exponential backoff with immediate first retry
  • Dead connection detection: 10s heartbeat, reconnect after 2 missed pongs

Systemd Service

Install as a system service:

# Server (as root)
revpty-server --host 0.0.0.0 --port 8765 --install

# Client (user-level)
revpty-client --server ws://server:8765 --session my-session --install --user

HTTP Proxy Support

Client can connect via HTTP proxy:

revpty-client --server ws://server:8765 --session my-session --proxy http://proxy:8080

Architecture

┌─────────────┐     WebSocket      ┌─────────────┐
│   Server    │◄──────────────────►│   Client    │
│  (revpty)   │                    │  (target)   │
└─────────────┘                    └─────────────┘
       │                                  │
       │                                  │
       ▼                                  ▼
  ┌─────────┐                        ┌─────────┐
  │Web GUI /│                        │   PTY   │
  │  Attach │                        │  Shell  │
  └─────────┘                        └─────────┘

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

revpty-0.5.16.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

revpty-0.5.16-py3-none-any.whl (48.5 kB view details)

Uploaded Python 3

File details

Details for the file revpty-0.5.16.tar.gz.

File metadata

  • Download URL: revpty-0.5.16.tar.gz
  • Upload date:
  • Size: 48.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for revpty-0.5.16.tar.gz
Algorithm Hash digest
SHA256 a6d7f25953d370a18758aed848b189ede76b6e9138a39bd847eb0a8adfe12609
MD5 a6b390d0370b13e2bb702928bd9ecbcb
BLAKE2b-256 73b10228b5ec72bf59c49059233edb39d13559adcbec56ae05d4e089f6555036

See more details on using hashes here.

File details

Details for the file revpty-0.5.16-py3-none-any.whl.

File metadata

  • Download URL: revpty-0.5.16-py3-none-any.whl
  • Upload date:
  • Size: 48.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for revpty-0.5.16-py3-none-any.whl
Algorithm Hash digest
SHA256 b8b3effbf8a5e403bc44c6a0a49549c56bb65090c2f24940da7bb3fa3d89f1d9
MD5 87c5772593809b4623eafe2ac1372fb3
BLAKE2b-256 a58ac4dec5b3a9d3d031cabc9c7d019de942c78c69bd62e4d7dbc22b9494b524

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page