TeleChat is an enterprise-level, TCP-based secure chat room application built with Python, featuring cutting-edge PyQt5 GUI, high-grade encryption, advanced cybersecurity features, intelligent file sharing, and real-time security monitoring. This application showcases advanced programming concepts including Object-Oriented Programming (OOP), Data Structures & Algorithms (DSA), and comprehensive cybersecurity implementation.
Softwarica College of IT and E-Commerce
"Coursework 2"
Programming and Algorithm 2 (Python) - Lecturer: Suman Shrestha
Telechat - 26th June (3rd Semester)
๐ Complete security verification:
cd Main-PyQT-GUI
python comprehensive_security_test.py๐ฅ๏ธ Start the secure server:
cd Main-PyQT-GUI
python Main_Server.py๐ป Start the client:
cd Main-PyQT-GUI
python Main_Client.py| ๐ Password Protection Server authentication challenges |
๐ก๏ธ Real-time Security Live threat detection |
๐ซ XSS Blocking Dangerous content warnings |
| ๐ Rate Limiting Spam & DoS protection |
๐ File Security Malware detection |
๐ Audit Logging Security event tracking |
Live Alerts Security notifications |
๐ฎ Admin Controls User management |
๐ Modern UI Professional interface |
๐ Advanced Authentication & Access Control
- ๐ Password Authentication: Military-grade server access with brute-force protection
- ๐ก๏ธ Session Management: Secure session handling with intelligent timeout protection
- ๐ซ Brute-force Protection: Smart rate limiting on authentication attempts
- ๐ Session Tracking: Real-time monitoring of user sessions and activities
๐ก๏ธ Real-time Threat Detection & Prevention
- ๐จ XSS Detection: Advanced real-time blocking of malicious script injections
- ๐ Content Filtering: Intelligent detection of dangerous content patterns
- โก Live Monitoring: Instant threat detection with immediate response
- ๐ Threat Intelligence: Comprehensive analysis of security threats
๐ Intelligent Rate Limiting & DoS Protection
- ๐ฏ Smart Filtering: Multi-tier rate limiting (5 msg/min, 3 auth/min, 10 conn/min)
- ๐ซ DoS Prevention: Advanced protection against denial of service attacks
- โ๏ธ Load Balancing: Intelligent message throttling and queue management
- ๐ Analytics: Real-time monitoring of usage patterns and anomalies
๐ Advanced File Security & Malware Detection
- ๐ฆ Malware Scanning: Advanced file content analysis and threat detection
- ๐ Size Validation: Intelligent file size limits with security considerations
- ๐ Type Validation: Comprehensive file type analysis and filtering
- โ Transfer Confirmation: Explicit success/failure notifications with detailed feedback
| ๐ Network | ๐จ Interface | ๐ Security | ๐ File System |
|---|---|---|---|
| Multi-client TCP server | Modern PyQt5 GUI | AES-256 encryption | Intelligent file sharing |
| Concurrent connections | Professional dark theme | PBKDF2 key derivation | Malware detection |
| Authentication handling | Responsive design | Message validation | Size validation |
| Thread-safe operations | Real-time updates | Security monitoring | Auto-download system |
graph TB
A[๐ Security Dashboard] --> B[๐ Real-time Monitoring]
A --> C[๐ Multi-tier Rate Limiting]
A --> D[๐ก๏ธ Session Management]
B --> E[โ ๏ธ Threat Detection]
B --> F[๐ Security Events]
C --> G[๐ฌ Message Limits]
C --> H[๐ Auth Limits]
C --> I[๐ Connection Limits]
D --> J[โ
File Validation]
D --> K[๐ Thread-safe Ops]
D --> L[๐จ Modern UI]
- ๐ฅ๏ธ Security Dashboard: Real-time monitoring of connections, threats, and security events
- ๐ Multi-tier Rate Limiting: Intelligent limits for messages, authentication, and connections
- ๐ Session Management: Advanced session handling with timeout protection
- โ File Transfer Validation: Server-side acceptance/rejection with detailed client feedback
- ๐ Thread-safe Operations: Bulletproof concurrent access protection
- ๐ฏ Error Handling: Comprehensive error management with graceful degradation
- ๐ Modern UI Design: Professional interface with security-focused color coding
Advanced modular design with inheritance, encapsulation, and polymorphism
๐ Click to view detailed implementation
- ๐ Multi-tier Rate Limiting: Separate FIFO queues for different operation types
- ๐๏ธ User Management: Thread-safe HashMaps for efficient user lookup and session management
- ๐ Security Events: Ordered lists with efficient searching and filtering algorithms
- ๐ Authentication Tracking: Binary search trees for lightning-fast session validation
- โก Thread-safe Collections: Advanced concurrent access protection with proper synchronization
- ๐ File Transfer Tracking: Dictionary-based tracking of transfer states and confirmations
- ๐๏ธ Observer Pattern: Real-time security monitoring and event handling
- ๐ญ Factory Pattern: Dynamic message creation and processing
- ๐ฏ Singleton Pattern: Centralized security manager for system-wide protection
| Layer | Technology | Purpose |
|---|---|---|
| ๐ Encryption | AES-256 with Fernet | Military-grade message protection |
| ๐ Key Derivation | PBKDF2-HMAC-SHA256 (100k iterations) | Quantum-resistant key generation |
| ๐ก๏ธ Threat Detection | Advanced regex + ML patterns | XSS, injection, malware detection |
| ๐ Authentication | Password + session management | Multi-factor access control |
| ๐ Network Security | Rate limiting + protocol filtering | DoS protection + traffic analysis |
| Component | Requirement | Status |
|---|---|---|
| ๐ Python | 3.12+ | |
| ๐ป OS | Windows/Linux/MacOS | |
| ๐ง RAM | 4GB minimum | |
| ๐ Network | TCP connectivity |
# ๐จ GUI Framework
PyQt5>=5.15.0
# ๐ผ๏ธ Image Processing
pillow>=9.0.0
# ๐ Cryptography
cryptography>=3.4.8
# ๐ Built-in Modules
socket threading jsongit clone https://github.com/Makkkiiii/Coursework2-Tele-ChatRoom.git
cd Tele-ChatRoompip install PyQt5 pillow cryptographycd Main-PyQT-GUI
python comprehensive_security_test.pyโจ If you see green checkmarks, you're ready to go! โจ
cd Main-PyQT-GUI
python Main_Server.pycd Main-PyQT-GUI
python Main_Client.py๐ก๏ธ Complete Security Testing Suite
cd Main-PyQT-GUI
python comprehensive_security_test.pyThis will test:
- โ Password authentication systems
- โ XSS detection and blocking
- โ Rate limiting effectiveness
- โ File malware detection
- โ Encryption/decryption integrity
- โ Session management security
๐ฎ Legacy Demo & Testing
cd Tests
python demo_usage.pyFor legacy compatibility and testing:
- ๐ Basic functionality verification
- ๐ Performance benchmarking
- ๐งช Unit test execution
|
๐ Server Startup
|
๐ Password Protection
|
๐ Security Dashboard
|
๐ฅ User Management & Monitoring
- ๐ Connected Users: View all active users with authentication status
- โก Real-time Actions: Kick problematic users with one-click
- ๐ Session Tracking: Monitor user activity and connection duration
- ๐ Behavior Analysis: Track user patterns and security events
๐ฌ Message & Communication Control
- ๐ Message Monitoring: View all server communications with filtering
- ๐ก๏ธ Security Filtering: Automatic XSS and malware detection
- ๐ Audit Trail: Comprehensive logging of all security events
โ ๏ธ Threat Alerts: Real-time notifications of security incidents
๐ซ Rate Limiting & DoS Protection
- ๐ Smart Throttling: Automatic protection against spam attacks
- โ๏ธ Load Balancing: Intelligent message queue management
- ๐ฏ Custom Limits: Configurable rate limits per operation type
- ๐ Usage Analytics: Real-time monitoring of system performance
flowchart LR
A[๐ Connect] --> B[๐ Authenticate]
B --> C[๐ฌ Chat Safely]
C --> D[๐ Share Files]
D --> E[โ ๏ธ Security Alerts]
E --> C
|
๐ Step 1: Connect
|
๐ Step 2: Authenticate
|
๐ฌ Step 3: Communicate
|
| ๐ XSS Detection | ๐ Rate Limiting | ๐ File Security | ๐ Authentication |
|---|---|---|---|
| Dangerous content blocked | Message throttling | Malware detection | Password protection |
| Real-time warnings | Spam prevention | Size validation | Session management |
| Security notifications | DoS protection | Type filtering | Access control |
| ๐ Feature | ๐ Specification | ๐ก๏ธ Security Level |
|---|---|---|
| Supported Types | PNG, JPG, GIF, PDF, TXT, ZIP | โ Type Validation |
| Size Limit | 50MB with server validation | ๐ Size Monitoring |
| Security Scanning | Advanced malware detection | ๐ก๏ธ Threat Analysis |
| Storage | received_files/ (client-only) |
๐ No Server Storage |
| Encryption | AES-256 during transmission | ๐ Military Grade |
| Feedback | Success/failure notifications | โ Real-time Status |
sequenceDiagram
participant C1 as ๐ค Client (Sender)
participant S as ๐ฅ๏ธ Secure Server
participant C2 as ๐ฅ Other Clients
C1->>S: ๐ Send Encrypted File
S->>S: ๐ Malware Scan
S->>S: ๐ Size Validation
S->>S: ๐ก๏ธ Type Check
alt โ
File Approved
S->>C1: โ
Transfer Success
S->>C2: ๐ Relay to Others
C2->>C2: ๐พ Auto-save to folder
else โ File Rejected
S->>C1: โ ๏ธ Security Warning
S->>S: ๐ Log Security Event
end
๐ค Client Side (Sender)
- ๐ File Selection: User selects file via intuitive GUI
- ๐ Encryption: File encoded to base64 and encrypted with AES-256
- ๐ก Transmission: Secure data sent to server with metadata
- โ Confirmation: Wait for explicit server success/failure response
๐ฅ๏ธ Server Side (Security & Relay)
- ๐ Security Validation: File size and type verification
- ๐ฆ Malware Detection: Advanced content and metadata scanning
- ๐ Response Generation: Explicit success/failure notification to sender
- ๐ Relay Operation: Immediate forwarding of approved files to all clients
- ๐๏ธ No Storage: Server never stores files locally (relay-only architecture)
๐ฅ Client Side (Receivers)
- ๐ก File Reception: Receive file data only if server-approved
- ๐พ Auto-save: Decode and save to
received_files/folder โ ๏ธ Security Notifications: Receive alerts if files are blocked- ๐ Validation: Each client performs additional security validation
| ๐ก๏ธ Security | โก Performance | ๐ฏ User Experience |
|---|---|---|
| Server never stores files | Constant memory usage | Clear success/failure feedback |
| Advanced malware detection | Reduced attack surface | Real-time security notifications |
| File validation layers | Scalable architecture | Automatic file organization |
| Comprehensive audit logging | No cleanup required | Professional UI feedback |
- Client Side (Receivers):
- Clients receive the file data from server (only if approved)
- Clients decode and save file to
received_files/folder - Receive security notifications if files are blocked
- Each client manages their own file storage with validation
- Privacy: Server never stores user files
- Security: Advanced malware detection and file validation
- Storage Efficiency: Server doesn't need file storage space
- Attack Surface: Reduces security risks on server
- Scalability: Server memory usage remains constant
- Simplicity: No file cleanup or management needed on server
- User Feedback: Clear success/failure notifications for all file operations
{
"type": "message_type",
"data": {
"id": "message_id",
"sender": "username",
"content": "message_content",
"type": "text|file|system",
"file_data": {...},
"timestamp": "ISO_timestamp"
}
}text: Regular chat message (subject to XSS detection)file: File sharing message (subject to malware detection)system: Server notifications and security alertserror: Error messages and warningsserver_message: Server announcementswarning: Security warnings (XSS/malware detection)file_success: File transfer confirmation messagesauth_challenge: Password authentication requestsauth_response: Authentication responses
- Rate Limiting Queues: Multi-tier FIFO queues for different operation types (messages, auth, connections)
- User Management Dictionary: Thread-safe HashMap for user lookup and session management
- Security Event Lists: Ordered message history with efficient searching and filtering
- Authentication Tracking: Binary search trees for efficient session validation
- Thread-safe Collections: Concurrent access protection with proper synchronization
- File Transfer Tracking: Dictionary-based tracking of file transfer states and confirmations
Run the comprehensive security test suite:
cd Main-PyQT-GUI
python comprehensive_security_test.pyComplete Security Verification:
cd Main-PyQT-GUI
python comprehensive_security_test.pyLegacy Test Suite:
cd Tests
python Main_Test.py- โ Password authentication and session management
- โ XSS detection and dangerous message blocking
- โ Rate limiting and DoS protection
- โ Malicious file detection and blocking
- โ Encryption/Decryption functionality
- โ Message serialization/deserialization
- โ Thread-safe queue operations
- โ User management and kick functionality
- โ File encoding/decoding with security validation
- โ Security event logging and audit trails
- โ Error handling scenarios
- Default Host:
localhost - Default Port:
12345 - Max Connections:
5(configurable) - Message Buffer:
4096bytes
- Password Protection: Server requires password authentication (configurable)
- Encryption: AES-256 with Fernet implementation
- Key Derivation: PBKDF2-HMAC-SHA256 with 100,000 iterations
- Rate Limiting: Configurable limits for messages (5/min), auth (3/min), connections (10/min)
- XSS Detection: Advanced regex patterns for dangerous content detection
- File Security: Malware detection, size limits (50MB), type validation
- Session Management: Secure session handling with timeout protection
- Audit Logging: Comprehensive security event logging with timestamps
- Max File Size: 50MB with server-side validation
- Supported Types: All file types with security scanning
- Storage Location:
received_files/(client-side only) - Security Scanning: Advanced malware detection and validation
- Transfer Confirmation: Explicit success/failure notifications
- Password Authentication: Server requires password for access with brute-force protection
- Advanced Threat Detection: Real-time XSS, injection, and malicious content blocking
- Smart Rate Limiting: Prevents spam and DoS attacks with intelligent message filtering
- Malicious File Detection: Advanced file scanning with size and type validation
- Security Audit Logging: Comprehensive logging of all security events and threats
- Real-time Security Alerts: Live monitoring with instant threat notifications
- Input Validation: Complete sanitization of all user inputs and data
- Admin Controls: Server administrator can kick users and monitor all activities
- Session Management: Secure session handling with timeout protection
- End-to-End Encryption: All messages encrypted with AES-256
- Authentication Failures: Clear feedback for incorrect passwords
- Security Violations: Immediate warnings for XSS/malicious content
- File Rejection: Detailed notifications for blocked files
- Rate Limiting: Clear messages when limits are exceeded
- Invalid Messages: Graceful error display with security logging
- File Errors: Size/type validation with user feedback and server notifications
- Encryption Errors: Secure fallback handling with audit logging
- Network Issues: Timeout handling and user notification with reconnection support
The project is organized into logical folders to make navigation easier:
๐ ProgrammingAlgo2/
โโโ ๐ Main-PyQT-GUI/ # Core PyQt Application Files
โ โโโ Main_Client.py # ๐ฅ๏ธ Main PyQt5 Client Application with Security
โ โโโ Main_Server.py # ๐ Advanced Secure Server with Admin GUI
โ โโโ core.py # ๐๏ธ Core classes (Message, User, Security)
โ โโโ security.py # ๐ก๏ธ Enterprise security features
โ โโโ launcher.py # ๐ Application launcher
โ โโโ comprehensive_security_test.py # ๐งช Complete security test suite
โ โโโ received_files/ # ๐ฅ Client downloaded files
โ
โโโ ๐ Main-Tkinter-GUI/ # Legacy Tkinter Implementation
โ โโโ Main_Client.py # ๐ฅ๏ธ Tkinter Client (Legacy)
โ โโโ Main_Server.py # ๐ Tkinter Server (Legacy)
โ โโโ core.py # ๐๏ธ Core classes for Tkinter
โ โโโ security.py # ๐ก๏ธ Security features for Tkinter
โ โโโ received_files/ # ๐ฅ Client downloaded files
โ
โโโ ๐ Tests/ # Testing & Verification Tools
โ โโโ Main_Test.py # ๐งช Legacy test suite
โ โโโ verify_encryption.py # โ
Encryption verification
โ โโโ demo_usage.py # ๐ฎ Usage demonstration
โ โโโ chat_core.py # ๐๏ธ Core classes for testing
โ โโโ advanced_security_fixed.py # ๐ก๏ธ Security features for testing
โ โโโ debug_client.py # ๐ชฒ Debug client for testing
โ
โโโ ๐ Read/ # Documentation & Guides
โ โโโ SECURITY_FEATURES.md # ๐ Detailed security documentation
โ โโโ ENCRYPTION_VERIFICATION.md # ๐ How to verify encryption works
โ
โโโ ๐ received_files/ # ๐ฅ Global file storage
โโโ requirements.txt # ๐ฆ Python dependencies
โโโ README.md # ๐ This documentation
What it contains: The main PyQt5 applications with full security features
Main_Server.py- Advanced server with admin GUI, security monitoring, password protection, and user managementMain_Client.py- Modern PyQt5 client with security features, file sharing, and threat detectioncore.py- Core classes (Message, User, SecurityManager, FileManager) with advanced featuressecurity.py- Enterprise-grade security (encryption, rate limiting, XSS detection, malware scanning)launcher.py- Application launcher for easy startupcomprehensive_security_test.py- Complete security verification suite
How to use:
- First run
python Main_Server.py - Then run
python Main_Client.py(can run multiple instances) - Use
python comprehensive_security_test.pyto verify all security features
What it contains: Legacy Tkinter version (for compatibility)
- Similar structure but with Tkinter GUI instead of PyQt5
- Basic security features without advanced monitoring
What it contains: Tools to test and verify everything works
Main_Test.py- Legacy test suiteverify_encryption.py- Encryption verificationdemo_usage.py- Usage demonstration exampleschat_core.py- Core classes for testingadvanced_security_fixed.py- Security features for testing
How to use:
cd Tests
python Main_Test.py # Legacy test suite
python verify_encryption.py # Encryption verification
python demo_usage.py # Usage demoWhat it contains: Detailed documentation and guides
SECURITY_FEATURES.md- Complete security documentationENCRYPTION_VERIFICATION.md- Step-by-step encryption verification
How to use: Open these files to understand specific features in detail
What they contain: File storage for client downloads
received_files/- Files downloaded by clientsMain-PyQT-GUI/received_files/- PyQt client file storageMain-Tkinter-GUI/received_files/- Tkinter client file storage
How to use: These folders are automatically created and managed by the client applications. The server acts as a relay and does not store files.
-
๐ฅ Install Dependencies:
pip install PyQt5 pillow cryptography
-
๐ Quick Security Demo:
cd Main-PyQT-GUI python comprehensive_security_test.py -
๐ฅ๏ธ Run the PyQt Application:
cd Main-PyQT-GUI python Main_Server.py # Terminal 1 python Main_Client.py # Terminal 2 (new terminal)
-
๐ Read Documentation:
- Open
Read/SECURITY_FEATURES.mdfor security details - Open
Read/ENCRYPTION_VERIFICATION.mdfor encryption verification
- Open
-
โ Complete Security Verification:
cd Main-PyQT-GUI python comprehensive_security_test.py -
๐ฎ Usage Demo:
cd Tests python demo_usage.py -
๐ Legacy Test Suite:
cd Tests python Main_Test.py -
๐ฅ๏ธ Try the Application:
cd Main-PyQT-GUI python Main_Server.py # Start server with password protection python Main_Client.py # Start client and test security features
- Start one server instance with password protection
- Run multiple client instances (each needs server password)
- Each client connects with unique username and authentication
- All clients can communicate simultaneously with security monitoring
- Server admin can monitor all connections and security events
- Client selects file using "Share File" button
- File is encoded to base64 and encrypted with AES-256
- Server receives and performs security validation (malware detection, size limits)
- Server sends explicit success/failure notification to sender
- Server broadcasts approved files to all connected clients
- Clients automatically decode and save secure files
- All file transfers are logged for security audit
- Monitor real-time connection status and authentication events
- View security dashboard with threat detection and rate limiting
- Review comprehensive security logs and audit trails
- Kick problematic users with one click
- Monitor XSS/malware detection events
- Graceful server shutdown with client notification
Authentication Failed
- Ensure you have the correct server password
- Check if server is configured with password protection
- Verify server is running and accepting connections
Connection Refused
- Ensure server is running first
- Check host/port configuration
- Verify firewall settings
- Confirm server password is set correctly
Security Warnings
- XSS/dangerous content warnings are normal security features
- File blocking indicates malware detection is working
- Rate limiting messages show DoS protection is active
Files Not Sharing
- Check file size (max 50MB)
- Ensure file passes malware detection
- Verify network connectivity
- Check server security logs for rejection reasons
GUI Not Responding
- Close and restart application
- Check system resources
- Update Python and PyQt5 dependencies
- Verify no conflicting processes
This project is created for educational purposes as part of the Programming & Algorithm 2 coursework. Feel free to use and modify for learning purposes.
Programming & Algorithm 2 - Enterprise Security Chat Application Built with Python โข Featuring PyQt5 GUI, Enterprise Security, OOP, DSA, Encryption, and Advanced Cybersecurity
- Download the zip file.
- Unzip the zip file.
- Run it on your machine.
- Mousepad
- Vim
- Nano
- Gedit
git clone https://github.com/Makkkiiii/Coursework2-Tele-ChatRoom.git
You can just make the script executable by adding the following command
#!/usr/bin/env python
Give permissions
chmod +x Main_Server.py
chmod +x Main_Client.py
cd Main-PyQT-GUI
python3 Main_Server.py
python3 Main_Client.py
Or for legacy Tkinter version:
cd Main-Tkinter-GUI
python3 Main_Server.py
python3 Main_Client.py
It is similar to Linux and Windows.
You can use coding software, a terminal, or just clone it.
Use the desired text editor.
Follow the given instructions inside the program
This program was written in Python using Visual Studio Code.
- ๐ Password Protection: Server requires authentication for access
- ๐ก๏ธ Security Monitoring: Real-time threat detection and prevention
- ๐ซ XSS Protection: Dangerous messages are blocked with warnings
- ๐ Rate Limiting: Automatic spam and DoS protection
- ๐ File Security: Malware detection and validation
- ๐ Audit Logging: Comprehensive security event tracking
- ๐ป Modern GUI: Professional PyQt5 interface with dark theme
- ๐ Encrypted Data: All communications secured with AES-256
โ ๏ธ Security Alerts: Live notifications of security events









