Skip to main content

Secure communication on terminal.

Project description

Terminal Chat Application

Secure communication on terminal.

Requirements

  1. Python 3+
  2. Python websockets
  3. Python cryptography

Installation

By the main repo:

$ git clone https://github.com/clediscover/terminal_chatapp/
$ cd terminal_chatapp
$ sudo python3 setup.py install

By pip:

$ pip install terminal_chatapp

What is Terminal Chat Application? What does it have? and How does it work?

This project has two program, server and client. The server is used to open a connection. The client is the one that will connect to the server. All the client that is connected to the server can receive a message from any other client. The server only accepts a connection if its authorized and will reject the request if not. It authorized the request using the authorization header, by checking if its value is the same with the password that is used to run the server. Also it checks the username header, if the username is already registered on the server (meaning other client is using the username and is connected), the server will reject the request.

The client connects with an encrypted authorization and username header. Those headers are encrypted because the server will decrypt it before the client can connect and to be safe from Man In The Middle (MITM) Attack even if the server don't have Secure Socket Layer (SSL). If its not encrypted, the server will know it and will reject the request of the client.

Authorization header is used as authentication on the server. Username header is used to give an identity to the client. For instance, if the client sends a message to the server. The client username is used to know where the message comes from.

Important

Running the server program with port of lower than 1024 requires root or administrator previledged.

Basic Usage

Run the program as server

Run this on terminal to start running the server.

$ sudo python3 -m terminal_chatapp server

By default it runs the server on ws://localhost:1719/. The server will give you a key on console after you run the server. Make sure that you save the key since you will need that to connect to the server. You can choose your own port by using the -p flag. Example: $ sudo python3 -m terminal_chatapp server -p 123. This example will open the server on ws://localhost:123/. Also it is important to know that by default, the password of the server is top_secret. You should change it if you don't want an unathorized person to connect to your server. You can change it by using the --password flag. Example: $ sudo python3 -m terminal_chatapp server --password mysupertoppass.

Run the program as client

Run this on terminal to connect to the server.

$ python3 -m terminal_chatapp client [key_of_server]

The [key_of_server] is the key that server prints out when you run the server. It is needed because you will not be able to connect to the server if you don't have that and it is used for cryptography of the conversation between server and client. By default the client program will connect to ws://localhost:1719/ with an encrypted authorization and username header. The authorization header value is "top_secret", while, username header is "user_1234", the number of username header is randomly selected.

If you want to change the value of the username header, you can use the --username flag from server program. Example: $ python3 -m terminal_chatapp client [key_of_server] --url myusername

If you want to change where you want to connect, use --url flag. Example: $ python3 -m terminal_chatapp client [key_of_server] --url ws://mychatapp.com:123/. This will connect to ws://mychatapp.com:123/.

For more information on the Command Line Interface (CLI) of server and client program, just run python3 -m terminal_chatapp -h, python3 -m terminal_chatapp server -h, or python3 -m terminal_chatapp client -h. This will show all the available and valid arguments for both client and server program.

Basic Usage With Picture

  1. We have three console opened here that we will use for showing how to use the server and client program.

  2. We run the server as root on the first console. It prints out the key that you will use for connecting the client. Also remember that you can change the password of the server using --password flag. But in this case, we will use the default password.

  3. We use the second console to connect to the server with given key from the server. It shows that the client program create its own username which is "user_4410" since we did not specify a username on the command and it shows from the server whose usename is connected and which path did the it go.

  4. We connect the third console to the server and give it a username as "ace". The server shows again who connects and on both client, it shows how many client is connected to the server.

  5. We send "Hello" message from the first client (user_4410) and it shows the message to second client (ace). Keep in mind that, all message are encrypted before it sends to the websocket server.

  6. We send a "World" message using the second client (ace) and the first client receive it (user_4410).

  7. Last, we disconnect the second client by pressing CTRL + C and it can be seen from all the client that is connected to the server.

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

terminal-chatapp-1.0.2.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

terminal_chatapp-1.0.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file terminal-chatapp-1.0.2.tar.gz.

File metadata

  • Download URL: terminal-chatapp-1.0.2.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for terminal-chatapp-1.0.2.tar.gz
Algorithm Hash digest
SHA256 376546bba7837b5846d6a79d1184d2575265b91b8eefc7f32d869400a5cdb315
MD5 3ff565c75750f944cf04f80eb33e4b55
BLAKE2b-256 93b0757d4cccfd96a4e09c96e5d4177b84a350272dfc14ffe6fbc2f66310835c

See more details on using hashes here.

File details

Details for the file terminal_chatapp-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: terminal_chatapp-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for terminal_chatapp-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f4eb60b3cf4722794307bb03fbbd256ffa3e4c5bd3412d7335f9a1a74fe02d33
MD5 09df7286131635ac660557b78c9d91c0
BLAKE2b-256 d80da7f080e31e9431d73d94ca54537b564cfc90d3de052c09c8baf68a5dec4d

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