Skip to content

lok77chan/Secure_G9

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5a7a858b",
   "metadata": {},
   "source": [
    "# Advanced Secure Protocol Design, Implementation\n",
    "\n",
    "## Overview\n",
    "\n",
    "#### This project implements an advanced secure protocol for communication with WebSockets. The server is written in Python, asyncio and websockets libraries, while the client is written in Node.js. The protocol includes authentication, encryption to ensure secure communication.\n",
    "\n",
    "## Prerequisites\n",
    "\n",
    "- Python 3.7 or higher\n",
    "- Websocket\n",
    "\n",
    "### Client (Node.js)\n",
    "\n",
    "- Node.js 12+\n",
    "- `ws` package\n",
    "- `readline` package\n",
    "- `node-jsencrypt` package\n",
    "\n",
    "## Installation\n",
    "\n",
    "### Server\n",
    "\n",
    "1. **Install Python Packages:**\n",
    "   Utlize `pip` to install the required Python packages: `websockets` for WebSocket in terminal shell:\n",
    "      ```sh\n",
    "pip install websockets\n",
    "\n",
    "\n",
    "2. **Generate Server Keys:**\n",
    "   The Python script generates the server's public and private keys. This script will use the `JSEncrypt`  to generate an RSA key pair. The private key will be saved in a file as `server_private_key.pem`, and the public key will be stored in a file as `server_public_key.pem`.\n",
    "\n",
    "\n",
    "3. **IP Configuration:**\n",
    "   A JSON configuration file saved as `new_ip_config.json` in the same directory as your server script should contain the local server's IP address, port, and name, likewise a list of other servers it needs to connect to.\n",
    "\n",
    "### Client\n",
    "\n",
    "1. **Install Node.js Packages:**\n",
    "   Utlize `npm` to install Node.js packages: `ws` for WebSocket communication and `readline` for reading user input from the command line in terminal shell:\n",
    "   ```sh\n",
    "npm install ws\n",
    "npm install readline\n",
    "npm install jsencrypt\n",
    "\n",
    "   Tip: If you have not got `npm` commond, please go to `Node.js official website` and download the Node.js.\n",
    "   \n",
    "2. **Generate Client Keys:**\n",
    "   A Node.js script generates the client's public and private keys. This script will utlize the `cryptography` module to generate an RSA key. The private key will be stored in a file named `client_private_key.pem`, and the public key will be stored in a file named `client_public_key.pem`.\n",
    "\n",
    "##  Operation of the Code\n",
    "\n",
    "### Ipconfig\n",
    "\n",
    "1. **Initial the IP:**\n",
    "   The NODE.JS IPconfig file will be stored for utlized on next operation:\n",
    "   - Find the NODE.JS file named `new_ip_config.json`.\n",
    "   - Change the ip address of currently\n",
    "\n",
    "### Server\n",
    "\n",
    "1. **Start the Server:**\n",
    "   The Python script will start the server:\n",
    "   - Load the server's private key for decrypting incoming messages.\n",
    "   - Read the IP configuration from `new_ip_config.json`.\n",
    "   - Use the `websockets` library to handle incoming WebSocket connections from clients and other servers.\n",
    "   - Implement authentication by decrypting the token sent by clients and verifying it.\n",
    "   - Send a response to the client indicating whether the authentication was successful.\n",
    "   - Handle other types of messages, such as broadcasting presence information and forwarding messages to other servers.\n",
    "   - Use TLS to encrypt the WebSocket connection.\n",
    "\n",
    "2. **Run the Server:**\n",
    "   Execute the server script to start the server. The server will listen for incoming WebSocket connections and handle them according to the implemented protocol.\n",
    "\n",
    "### Client\n",
    "\n",
    "1. **Start the Client:**\n",
    "   Create a Node.js script to start the client. This script will:\n",
    "   - Read the IP configuration from `new_ip_config.json`.\n",
    "   - Use the `ws` library to connect to the server via WebSocket.\n",
    "   - Encrypt a token with the server's public key and send it to the server for authentication.\n",
    "   - Handle the server's response to the authentication request.\n",
    "   - Allow the user to send messages to specific recipients or broadcast to all connected clients.\n",
    "   - Display incoming messages and presence updates.\n",
    "\n",
    "2. **Run the Client:**\n",
    "   Execute the client script to start the client. The client will connect to the server, authenticate itself, and allow the user to interact with other clients.\n",
    "\n",
    "### Expectation for Other Groups\n",
    "\n",
    "1. **Customisation:**\n",
    "   - Feel free to optimise any functions in this project. \n",
    "   - Wisdom inspires wisdom!\n",
    "2. **Commendation:**\n",
    "   - Feel free to highlight any part similar to your group and any part of your pleasure. Take the essence and discard the dross!\n",
    " \n",
    "3. **Criticization:**\n",
    "   - Feel free to highlight any part that is optimizable and put it in the comment. Knowing the shortage is the first step to improving!\n",
    "   \n",
    "4. **Synchronisation:**\n",
    "   - This project hopes you will follow the steps mentioned above and synchronise the package and environment as mentioned. One of us!\n",
    "   \n",
    "   \n",
    "### Hope your group will achieve the expected marks!"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}

About

Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 71.8%
  • Python 28.2%