Ncurses TCP Chat

Overview

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

  1. Motivation and Disclaimer
  2. Description
  3. Usage
  4. Dependencies
  5. Installation
  6. References
  7. 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

  1. ncurses sudo apt install libncurses5-dev libncursesw5-dev
  2. Open SSL sudo apt-get install libssl-dev
  3. 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,

  1. 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
  2. To encryt the messages, I took the this code snippet from ProgrammerSought as an example
  3. Finally, to generate the key pairs I used this code snippet from Dynamsoft

More references can be found inside the code.

Author

Edgar Hernandez

You might also like...
bviplusplus (bvi++) is an ncurses-based hex editor derived from bviplus

bviplusplus (bvi++) Overview bviplusplus (bvi++) is an ncurses-based hex editor derived from bviplus Links Other bviplus derivatives bviplus by Barano

A simple terminal-based solitaire game written in C using Ncurses
A simple terminal-based solitaire game written in C using Ncurses

Solitaire A simple terminal-based solitaire game written in C using Ncurses Dependencies Requires an installation of ncursesw as unicode is used exten

A Gemini client, written in C using ncurses
A Gemini client, written in C using ncurses

Gemcurses A Gemini client, written in C using ncurses KEY ACTION arrows up/down go down or up on the page PgUp/PgDn go page up or page down q change t

A C++ commandline for use in servers and chat software. Provides very simple asynchronous input/output.
A C++ commandline for use in servers and chat software. Provides very simple asynchronous input/output.

commandline A C++ commandline for use in servers and terminal chat software. Provides very simple asynchronous input/output. Supports reading and writ

Mumble is an Open Source, low-latency, high quality voice chat software
Mumble is an Open Source, low-latency, high quality voice chat software

Mumble is an Open Source, low-latency and high-quality voice-chat program written on top of Qt and Opus.

Unlocks the chat in Among Us

Among us external chat unlocker Among us external chat unlocker written in c++ Build flags for gcc -O2 -s -static-libstdc++ -static-libgcc Download Yo

The tiniest chat servers on earth!

yoctochat The tiniest chat servers on earth! Here will be a collection of the simplest possible TCP chat servers, to demonstrate how to write multiuse

A Google Chat protocol plugin for libpurple/Pidgin/bitlbee/whatever

Google Chat Plugin for libpurple A WORK IN PROGRESS replacement prpl for Google Chat in Pidgin/libpurple to support the proprietary protocol that Goog

📃 Export WeChat chat histories to HTML files.
📃 Export WeChat chat histories to HTML files.

wechat-export Export WeChat chat histories to HTML files. Preview This script generates a HTML file for each contact's chat history. Currently it supp

This is new projec based in apps to chat or messages people to people

Stranger This is new projec based in apps to chat or messages people to people Esta aplicacion tendra las siguientes caracteristicas: 1* Es 100% segur

A cross-platform SDK enabling developers to integrate real-time chat technology into their projects

4Players ODIN SDK ODIN is a cross-platform software development kit (SDK) that enables developers to integrate real-time chat technology into multipla

server secure chat

nem server api Register Login GetList Handshake Message Feed StatusOnline HandshakeKey HandshakeNotice FileAdd StorageFile GetFile Register { "type":

(bad) decentralized chat app

ircreborn what is this well. ircreborn was created because i felt that all the good platforms had too many paywalled features. (also because discord h

Simple local P2P chat on UDP sockets
Simple local P2P chat on UDP sockets

Local P2P Chat This is a fully decentralized chat. To communicate, simply run it on computers in a single local network (using one port). All messages

Arduino library to connect your project to IRC (Internet Relay Chat)

IRC Client Library for Arduino Connects your arduino project to an IRC server. Features Easy connection to an IRC server through a Client implementati

An app to enable fluent, cross-language video chat.

project_vouvos A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started i

Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution

CppServer Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and

A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.

evpp Introduction 中文说明 evpp is a modern C++ network library for developing high performance network services using TCP/UDP/HTTP protocols. evpp provid

Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket,  MQTT built-in protocols, async DNS resolver, and non-blocking API.
Mongoose Embedded Web Server Library - a multi-protocol embedded networking library with TCP/UDP, HTTP, WebSocket, MQTT built-in protocols, async DNS resolver, and non-blocking API.

Mongoose - Embedded Web Server / Embedded Networking Library Mongoose is a networking library for C/C++. It implements event-driven non-blocking APIs

Comments
  • string.data when string.c_str does not work

    string.data when string.c_str does not work

    Regarding https://github.com/edghyhdz/silver-sniffle/blob/main/src/Client.cpp#L463

    Would string.data() work? Otherwise, I suppose memcpy would be more efficient as well.

    opened by undisputed-seraphim 0
Owner
Edgar Hernandez
Edgar Hernandez
A Tcp/Ip stack implementation on top of Solarflare ef_vi, and a C++ headers only framework for tcp multiplexing client/server.

Efvitcp Efvitcp is a tcp library using Solarflare ef_vi interface on linux, and also a tcp multiplexing framework for both C++ client and server progr

Meng Rao 23 Nov 26, 2022
an easy implementation of a multi-process tcp server and a multi-thread tcp client

一个TCP多进程服务器-多线程客户端的简单实现。 客户端类似Apache ab的测试功能,能够通过向某一个ip端口发送指定并发量和总数量的tcp短连接;服务端处理tcp短连接,每来一条消息就打印一条log。 使用cmake编译,建议在vscode里编译,或者命令行 # 终端进入目录 mkdir bu

adin 1 Nov 28, 2021
River Rade game written in C using Ncurses library

river-rade Move your plane with arrow keys or A-D keys To install Ncurses library(on debian based): sudo apt-get install libncurses5-dev libncursesw5-

Narges Najian 3 Dec 1, 2021
ntd is a nCurses based to-do list application written in C.

nCurses ToDo A simple, lightweight todo list creation/management application Explore the docs » Report Bug · Request Feature Table of Contents About T

Preston Bridgers 1 Nov 5, 2021
Ncurses based omok game, execute omok game in your terminal

omok_game execute omok game in your terminal Omok game played by two people. 한국어 버전(korean version)

SunjungAn 1 Dec 3, 2022
AGE is a simple 2D console game engine runs in UNIX using third library Ncurses.

AGE-Game-Engine AGE is a simple 2D console game engine runs in UNIX using third library Ncurses. How-To-Run You need to install ncurses using the foll

SIHAN LI 1 Dec 16, 2021
yedit - A text editor made with ncurses and C++

yedit A text editor made with ncurses and C++ dependencies ∙ ncurses in Debian you can install dependencies with this command: # apt install libncurse

MESYETI 14 Oct 5, 2022
ncurses Git mirror

------------------------------------------------------------------------------- -- Copyright 2020,2021 Thomas E. Dickey

Repo mirrors 307 Dec 24, 2022
NCURSES-Programming-HOWTO examples

NCURSES-Programming-HOWTO examples

Tony Narlock 109 Nov 15, 2022
Ncurses based audio tracker program inspired by goattracker and milkytracker

PLEBTracker PLEBTracker is a linux console based audio tracker program inspired by goattracker and milkytracker. Pattern editor, main song editor wind

Dan Frazier 96 Dec 21, 2022