Skip to main content

SNI proxy with TCP multiplexer

Project description

SniTun

End-to-End encryption with SNI proxy on top of a TCP multiplexer

Connection flow

                   [ CLIENT ] --AUTH/CONFIG--> [ SESSION MASTER ] (Trusted connection)
                   [ CLIENT ] <--FERNET-TOKEN- [ SESSION MASTER ]
                   [ CLIENT ] --------FERNET-TOKEN---------------------> [ SNITUN ] (Unsecure connection)
                   [ CLIENT ] <-------CHALLENGE-RESPONSE-(AES/CBC)-----> [ SNITUN ]


             <--->                                                                  <------------------------------>
[ ENDPOINT ] <---> [ CLIENT ] <---------MULTIPLEXER---(AES/CBC)--------> [ SNITUN ] <------EXTERNAL-CONECTIONS-----> [ DEVICE ]
    |        <--->                                                                  <------------------------------>     |
    |                                                                                                                    |
    | <--------------------------------------------------END-TO-END-SSL------------------------------------------------->|
                                                      (Trusted connection)

Fernet token

The session master creates a Fernet token from the client's configuration (AES/whitelist) and attaches the hostname and a UTC timestamp until which the token is valid.

{
  "valid": 1923841,
  "hostname": "myname.ui.nabu.casa",
  "aes_key": "hexstring",
  "aes_iv": "hexstring"
}

The SniTun server must be able to decrypt this token to validate the client's authenticity. SniTun then initiates a challenge-response handling to validate the AES key and ensure that it is the same client that requested the Fernet token from the session master.

Note: SniTun server does not perform any user authentication!

Challenge/Response

The SniTun server creates a SHA256 hash from a random 40-bit value. This value is encrypted and sent to the client, who then decrypts the value and performs another SHA256 hash with the value and sends it encrypted back to SniTun. If it is valid, the client enters the Multiplexer mode.

Multiplexer Protocol

The header is encrypted using AES/CBC. The payload should be SSL. The ID changes for every TCP connection and is unique for each connection. The size is for the data payload.

The extra information could include the caller IP address for a new message. Otherwise, it is random bits.

|________________________________________________________|
|-----------------HEADER---------------------------------|______________________________________________|
|------ID-----|--FLAG--|--SIZE--|---------EXTRA ---------|--------------------DATA----------------------|
|   16 bytes  | 1 byte | 4 bytes|       11 bytes         |                  variable                    |
|--------------------------------------------------------|----------------------------------------------|

Message Flags/Types:

  • 0x01: New | The extra data includes the first byte as an ASCII value of 4 or 6, followed by the caller IP in bytes.
  • 0x02: DATA
  • 0x04: Close
  • 0x05: Ping | The extra data is a ping or pong response to a ping.

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

snitun-0.37.1.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

snitun-0.37.1-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file snitun-0.37.1.tar.gz.

File metadata

  • Download URL: snitun-0.37.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for snitun-0.37.1.tar.gz
Algorithm Hash digest
SHA256 83fec55b233ba66fdc1f7f3966a6a0631fb9de5c2c95eea627d6c7bd76092c8a
MD5 438b39af531439c60b54e8f28ec56e48
BLAKE2b-256 29ef5aebd6f86f6f10b0a02302accb6d5652ad7124ee2491979bf84874c37abb

See more details on using hashes here.

File details

Details for the file snitun-0.37.1-py3-none-any.whl.

File metadata

  • Download URL: snitun-0.37.1-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for snitun-0.37.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5e2e1fbb84ad637e821d518f0660fa17b4da5f317657d69a6fc700a95d291f6
MD5 60687eeb896736d00ca86c1c2fc9a96e
BLAKE2b-256 f17e9de103542e995c56bd66ccb7dffb959278417276f99c8a75cd59fcbfbe0b

See more details on using hashes here.

Supported by

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