snitun


Namesnitun JSON
Version 0.39.1 PyPI version JSON
download
home_pageNone
SummarySNI proxy with TCP multiplexer
upload_time2024-05-13 07:21:26
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseGPL v3
keywords sni proxy multiplexer tls
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

```json
{
  "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.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "snitun",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "sni, proxy, multiplexer, tls",
    "author": null,
    "author_email": "\"Nabu Casa, Inc.\" <opensource@nabucasa.com>",
    "download_url": "https://files.pythonhosted.org/packages/74/ff/2b7499dbfea2fa748620f8181aebdff26e24b6f78026516760e73d11a319/snitun-0.39.1.tar.gz",
    "platform": "any",
    "description": "# SniTun\n\nEnd-to-End encryption with SNI proxy on top of a TCP multiplexer\n\n## Connection flow\n\n```\n                   [ CLIENT ] --AUTH/CONFIG--> [ SESSION MASTER ] (Trusted connection)\n                   [ CLIENT ] <--FERNET-TOKEN- [ SESSION MASTER ]\n                   [ CLIENT ] --------FERNET-TOKEN---------------------> [ SNITUN ] (Unsecure connection)\n                   [ CLIENT ] <-------CHALLENGE-RESPONSE-(AES/CBC)-----> [ SNITUN ]\n\n\n             <--->                                                                  <------------------------------>\n[ ENDPOINT ] <---> [ CLIENT ] <---------MULTIPLEXER---(AES/CBC)--------> [ SNITUN ] <------EXTERNAL-CONECTIONS-----> [ DEVICE ]\n    |        <--->                                                                  <------------------------------>     |\n    |                                                                                                                    |\n    | <--------------------------------------------------END-TO-END-SSL------------------------------------------------->|\n                                                      (Trusted connection)\n```\n\n## Fernet token\n\nThe 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.\n\n```json\n{\n  \"valid\": 1923841,\n  \"hostname\": \"myname.ui.nabu.casa\",\n  \"aes_key\": \"hexstring\",\n  \"aes_iv\": \"hexstring\"\n}\n```\n\nThe 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.\n\nNote: SniTun server does not perform any user authentication!\n\n### Challenge/Response\n\nThe 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.\n\n## Multiplexer Protocol\n\nThe 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.\n\nThe extra information could include the caller IP address for a new message. Otherwise, it is random bits.\n\n\n```\n|________________________________________________________|\n|-----------------HEADER---------------------------------|______________________________________________|\n|------ID-----|--FLAG--|--SIZE--|---------EXTRA ---------|--------------------DATA----------------------|\n|   16 bytes  | 1 byte | 4 bytes|       11 bytes         |                  variable                    |\n|--------------------------------------------------------|----------------------------------------------|\n```\n\nMessage Flags/Types:\n\n- `0x01`: New | The extra data includes the first byte as an ASCII value of 4 or 6, followed by the caller IP in bytes.\n- `0x02`: DATA\n- `0x04`: Close\n- `0x05`: Ping | The extra data is a `ping` or `pong` response to a ping.\n",
    "bugtrack_url": null,
    "license": "GPL v3",
    "summary": "SNI proxy with TCP multiplexer",
    "version": "0.39.1",
    "project_urls": {
        "Homepage": "https://www.nabucasa.com/",
        "Repository": "https://github.com/NabuCasa/snitun.git"
    },
    "split_keywords": [
        "sni",
        " proxy",
        " multiplexer",
        " tls"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48c31fd863e859a91d9087613195012d96e03c09063718b53deac610b4fd86b4",
                "md5": "3d720b8605678be02bea5f4d0f058596",
                "sha256": "6ff55f6ba21d463877f9872de7d632fc18e400c8b42f8115c42d17e51075f674"
            },
            "downloads": -1,
            "filename": "snitun-0.39.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3d720b8605678be02bea5f4d0f058596",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 39089,
            "upload_time": "2024-05-13T07:21:24",
            "upload_time_iso_8601": "2024-05-13T07:21:24.598931Z",
            "url": "https://files.pythonhosted.org/packages/48/c3/1fd863e859a91d9087613195012d96e03c09063718b53deac610b4fd86b4/snitun-0.39.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74ff2b7499dbfea2fa748620f8181aebdff26e24b6f78026516760e73d11a319",
                "md5": "2d4ed187fd7658bfd6b8a0a32ffaeca0",
                "sha256": "fadbe447eea786291d5c52e67eae0658f53a1f68c4b97425e17a9579df503d7e"
            },
            "downloads": -1,
            "filename": "snitun-0.39.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2d4ed187fd7658bfd6b8a0a32ffaeca0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 33073,
            "upload_time": "2024-05-13T07:21:26",
            "upload_time_iso_8601": "2024-05-13T07:21:26.409910Z",
            "url": "https://files.pythonhosted.org/packages/74/ff/2b7499dbfea2fa748620f8181aebdff26e24b6f78026516760e73d11a319/snitun-0.39.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-13 07:21:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NabuCasa",
    "github_project": "snitun",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "snitun"
}
        
Elapsed time: 0.25625s