This is an advanced Python-based chat room with secure login. The project is entirely based on the socket programming done using Python. The server is set to the listening mode, with a specific port number (asked at runtime). Client are made to connect to the server, prompted to enter a nickname and password. The messages are then broadcasted to all the connected clients.
First login will register nickname and password on the server.
It is also possible to ensure traffic by wrapping TCP packet into TOR full-encrypted connection, creating hidden service and using torsocks.
Sockets and the socket API are used to send messages across a network. They provide a form of inter-process communication (IPC). The network can be a logical, local network to the computer, or one that’s physically connected to an external network, with its own connections to other networks. The obvious example is the Internet, which you connect to via your ISP.
Image Credit:Real Python
In the diagram below, given the sequence of socket API calls and data flow for TCP:
- We will have to start our server first.
python3 server.py
- Run the client file, to start the conversation.
python3 client.py
3. enter a nickname, password and server address for start your chatting.
- Install TOR typing (under Linux):
sudo apt install tor
- Create hidden service editing '/etc/tor/torrc' with:
HiddenServiceDir /var/lib/tor/ChatRoom/
HiddenServicePort 8080 127.0.0.1:8080
- Restart TOR:
$ systemctl restart tor
- Find onion address:
$ cat /var/lib/tor/ChatRoom/hostname
- Start server.py entering the port;
binding host = '127.0.0.1' by editing server code, we will receive only tor connections, being able to leave the ports of the firewall and the router closes.
- Then start client.py typing:
$ torsocks python3 client.py
and compile entries 'Host' and 'Port' with onion address and port (8080) used before in tor setup.
Server-side:
Client-side: