This project implements a secure, end-to-end encrypted messaging system using Python sockets, VPN-style tunneling concepts, GUI clients, a relay server, a hacker/MITM simulation, and a packet sniffer. It demonstrates how encrypted communication protects users from packet sniffing and interception, aligning with core topics of the Computer Networks course.
The system enables two clients to communicate securely over a TCP network using Fernet (AES + HMAC) encryption. A relay server forwards encrypted packets without decrypting them. A hacker module and a packet sniffer attempt to capture messages but only receive ciphertext, proving end-to-end confidentiality. This project visually demonstrates VPN tunneling, encrypted communication, and real-world network attack scenarios.
- End-to-end encrypted messaging
- VPN-style secure tunneling simulation
- User authentication (client-side + server-side)
- GUI chat application using Tkinter
- Custom JSON-based packet structure
- Sender-side encryption & receiver-side decryption
- Relay server that forwards ciphertext only
- Hacker client for MITM demonstration
- Packet sniffer using Scapy to view raw encrypted traffic
- Multi-threaded communication for real-time chatting
Client A (Encrypt) → Relay Server (Forward Ciphertext) → Client B (Decrypt)
↘
Hacker Client (Ciphertext Only)
Packet Sniffer (Scapy) ←——————————— Network Traffic
- Authenticates users using a simple database
- Forwards encrypted packets to the correct user
- Mirrors packets to the hacker client for demonstration
- Operates as a zero-knowledge server (never decrypts messages)
- Login screen with username, password, and key configuration
- Fernet key derived using PBKDF2 or provided directly
- Encrypts outgoing packets
- Decrypts incoming ciphertext
- Displays messages with timestamps in a GUI
- Connects as an unauthorized listener
- Receives mirrored encrypted packets
- Attempts to decrypt (fails without correct key)
- Shows ciphertext-only interception
- Captures TCP packets on port 9000
- Displays raw packet payloads
- Confirms that intercepted data is unreadable ciphertext
- Algorithm: Fernet (AES-128 + HMAC-SHA256)
- Key Derivation: PBKDF2 with salt (390,000 iterations)
- Data Integrity: Every encrypted packet contains authentication tags
- Zero Plaintext Exposure: Server and attacker never see decrypted messages
All messages are converted into a JSON packet and then encrypted:
{ "header": "VPNv1", "src": "", "dst": "", "type": "MSG", "timestamp": , "len": <data_length>, "data": "" }
The entire packet is encrypted before transmission.
- Socket programming (TCP)
- Client-server architecture
- Packet forwarding & routing
- Encapsulation & tunneling
- Application-layer encryption
- Man-in-the-middle (MITM) attack simulation
- Packet sniffing using Scapy
- Multi-threading for full-duplex communication
-
Start the relay server: python server.py
-
Start Client 1: python gui_client.py
-
Start Client 2: python gui_client.py
-
(Optional) Start Hacker client: python hacker_client.py
-
(Optional) Run the packet sniffer (admin required): python sniffer.py
- Secure chat applications
- VPN tunnel simulation
- Cybersecurity demonstration
- CN laboratories & networking projects
- Encrypted communication research
✅ Fully Working
✅ Tested across devices
✅ Demonstrates encryption, routing, and network-level security
Aatman Doshi - 24BCE1285 Harshit Verma - 24BCE1663