[OC] terminal TCP Chat with encryption end to end C++

Author : JONSON
Publish Date : 2021-03-21 10:29:45
[OC] terminal TCP Chat with encryption end to end C++

NCURSES Encrypted TCP Chat

This is an encrypted chat via the command line! It was done using ncurses to build the whole user interface. I wanted to do a client-server example of a chat, were also the messages would be encrypted from end to end.

Upon accepting the connection of a new client, the first message the server gets is the public key from the client, which is later sent to all listening sockets (clients). The messages are first encrypted using logged client's public keys before being sent to back to the server. Other listening clients will unencrypt their messages by using their private key.

The project consists of 3 main parts,

    TCP Server -> you could use ngrok to accept network trafic on a dedicated port, and be like a real chat!
    Client
    Terminal user interface

In the gifs below, the right terminal was opened using telnet (install on linux) to showcase how a person not using the client would see the messages from users using this project's client.
Official Client     Connected using telnet
    

The example below showcases two clients, were the messages are encrypted end to end.
Official Client A     Official Client B
    

Conntact me on twitter Tweet | Create an issue
Table of Contents

    Motivation and Disclaimer
    Description
    Usage
    Dependencies
    Installation
    References
    Author

Motivation and Disclaimer

What can I say, I love ncurses and I wanted to do an example of something that required encryption, the idea of a TCP Chat was the first thing that came into my mind.

This was just a project made out of curiosity, the use that you might give to this tool is at your own risk.
Description

This command line TCP Chat was built using ncurses.
Server

The server is running constantly, and could also be used on a raspberry pi in combination with ngrok. By doing so, you could open your chat to other peers and have a secure way of messaging.
Client

The client has a nice UI to be used on the terminal. The client first connects to the server and sends its public key to the server. The server retrieves this information and sends it to all users using this client.

Every client will then encrypt their messages with the other listening clients' public keys. The server will then get each corresponding listening client's message and send it accordingly.

Once the encrypted message is received on the other clients' side, it is unencrypted using the user's private key.

The client renews its key pairs everytime you start it.
Usage

Once the installation has been done,

As per default, the port to which the server is connecting to is 54000

Starting the Server (In case you are running the server)

source silver_server

Starting the Client

source silver_sniffle -a 127.0.0.1 54000

127.0.0.1 and the port 54000 could be changed for example to your own TCP address if you've got one. Of course, the server would have to be running on that address.
Dependencies

    ncurses sudo apt install libncurses5-dev libncursesw5-dev
    Open SSL sudo apt-get install libssl-dev
    cmake sudo apt-get -y install cmake

Installation

Clone this repository like so,

git clone https://github.com/edghyhdz/silver-sniffle.git

Once inside the root project folder silver-sniffle,

# Lets start by creating the build directory
mkdir build && cd build

# cmake that guy
cmake ..

# Finally
source install.sh

install.sh will run the final installation that will create a terimal shortcut named silver_server and silver_sniffle.

The final project folder structure is the following,

.
├── ...
├── build                     # Directory were project was built
│   ├──silver_server          # Server executable
│   ├── executable            # Client executable location
│   │   └─── silver_sniffle   # Client executable
│   └── certificates          # key pair location
└── ...

If everything was done allright, you should be able to run the server by doing the following,

source silver_server

Once the server is up and running, you should be able to run the client like so,

source silver_sniffle -a 127.0.0.1 54000

You can always re-route the client to another address.
References

The most relevant references are the following,

    Part of this code was taken from user Sloan Kelly, and adapted to this script to run on linux and work with Ncurses link to his repo here
    To encryt the messages, I took the this code snippet from ProgrammerSought as an example
    Finally, to generate the key pairs I used this code snippet from Dynamsoft

More references can be found inside the code.

 

https://belarus.expatreporter.com/advert/watch-free-wisconsin-vs-northeastern-live-stream-ncaa-womens-ice-hockey-final-2021-free/


https://www.telerealrd.com/advert/northeastern-vs-wisconsin-live-stream-ncaa-womens-ice-hockey-championship-2021-free/


https://belarus.expatreporter.com/advert/watch-free-womens-ice-hockey-national-championship-live-stream-ncaa-womens-ice-hockey-final-2021-free/


https://belarus.expatreporter.com/advert/watch-tv-free-womens-ice-hockey-national-championship-2021-live-stream-wisconsin-vs-northeastern-final-free/


https://belarus.expatreporter.com/advert/watch-free-ucla-vs-usc-live-stream-mens-water-polo-final-2021-free/

 

https://belarus.expatreporter.com/advert/watch-tv-usc-vs-ucla-live-stream-mens-water-polo-championship-2021-free/


https://belarus.expatreporter.com/advert/watch-free-mens-water-polo-championship-2021-live-stream-ucla-vs-usc-final-free/

https://belarus.expatreporter.com/advert/watch-free-ncaa-mens-ice-hockey-selection-show-2021-live-stream-free/

https://www.deviantart.com/gdsffds/journal/Building-a-Lightweight-Command-Line-Newsletter-873890873

https://blog.goo.ne.jp/lifetvs/e/d5a44866ab6127b6320f1f890dbed3fc

https://paiza.io/projects/S9ZUUCVgaxkeLb4svS_vxQ


https://caribbeanfever.com/photo/albums/newsletter

https://www.thewyco.com/general/building-a-lightweight-command-line-newsletter-program-21-03-2021

https://www.guest-articles.com/others/building-a-lightweight-command-line-newsletter-program-21-03-2021



Category : general

Who needs what to go through from EURO 2020 groups

Who needs what to go through from EURO 2020 groups

- Who is through already, who can join them in the round of 16, qualifying rules, tiebreakers and what each team need to reach the round of 16


Claim Home Office Expenses and Increase Your Tax Refund

Claim Home Office Expenses and Increase Your Tax Refund

- These valuable tax deductions generally cover the costs associated with working from home or running a business from home


Best Mobile app development company Dubai expertise in IoT technologies

Best Mobile app development company Dubai expertise in IoT technologies

- Android Mobile phone’s and versatile figuring have prompted new company possibility, for example, customized administrat


Prepare For Yourself Linux Foundation LFCS Dumps - LFCS Practice Test Questions

Prepare For Yourself Linux Foundation LFCS Dumps - LFCS Practice Test Questions

- To avoid time-wasting, the specialists give essential and direct LFCS practice test questions that are clear. In like manner, these specialists help