Skip to content

prathaaaaaaam/SFS-System

Repository files navigation

Secure File Sharing System with Advanced Threat Protection

A comprehensive client-server Java application that provides secure file sharing with end-to-end encryption, self-destructing files, honeypot security, and file integrity verification.

🔐 Features

Core Security Features

  • AES-256 Encryption: All files are encrypted using Advanced Encryption Standard
  • RSA Key Exchange: 2048-bit RSA encryption for secure key distribution
  • SHA-256 Hashing: File integrity verification using cryptographic hashes
  • End-to-End Encryption: Files remain encrypted in transit and at rest

Advanced Features

  1. Self-Destructing Files

    • Time-based expiration (files auto-delete after set hours)
    • Download-count-based deletion (limit number of downloads)
    • Automatic cleanup of expired files
  2. Honeypot Security

    • Decoy files to trap unauthorized users
    • Automatic logging of suspicious activity
    • IP tracking for security analysis
  3. File Integrity Verification

    • SHA-256 hash generation on upload
    • Automatic verification before download
    • Tamper detection and alerts
  4. Secure Authentication

    • Password hashing using SHA-256
    • RSA key pair generation for each user
    • Session management and activity logging

📋 Prerequisites

  • Java Development Kit (JDK) 11 or higher
  • SQLite JDBC Driver (included in lib/)

🚀 Installation & Setup

1. Download SQLite JDBC Driver

cd SecureFileSharing/lib
wget https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.44.1.0/sqlite-jdbc-3.44.1.0.jar

Or manually download from: https://github.com/xerial/sqlite-jdbc/releases

2. Compile the Project

# Navigate to project directory
cd SecureFileSharing

# Compile all source files
javac -d bin -cp "lib/*" src/common/*.java src/database/*.java src/server/*.java src/client/*.java

3. Create Required Directories

mkdir -p secure_storage
mkdir -p downloads

🎮 Running the Application

Start the Server

# From the SecureFileSharing directory
java -cp "bin:lib/*" server.Server

The server will start on port 5555 and display:

═══════════════════════════════════════════════════
   SECURE FILE SHARING SERVER
═══════════════════════════════════════════════════
Server started on port: 5555
Security features enabled:
  ✓ AES-256 Encryption
  ✓ RSA Key Exchange
  ✓ File Integrity Verification (SHA-256)
  ✓ Self-Destructing Files
  ✓ Honeypot Security
═══════════════════════════════════════════════════

Start the Client

Open a new terminal:

# From the SecureFileSharing directory
java -cp "bin:lib/*" client.Client

📖 Usage Guide

Registration

  1. Choose option 1 from the login menu
  2. Enter desired username and password
  3. IMPORTANT: Save your private key securely! You'll need it to decrypt your files
  4. Optionally save the private key to a file

Login

  1. Choose option 2 from the login menu
  2. Enter username and password
  3. Provide your private key (paste it or provide file path ending in .key)

Upload File

  1. From main menu, choose option 1
  2. Enter the full path to the file you want to upload
  3. Set expiry time in hours (0 for no expiry)
  4. Set max download count (-1 for unlimited)
  5. File will be encrypted and uploaded

Download File

  1. From main menu, choose option 2
  2. Enter the file ID (get from List Files)
  3. Specify download directory
  4. File will be decrypted and saved locally

List Files

  1. From main menu, choose option 3
  2. View all your uploaded files with:
    • File ID
    • File name
    • Download count (current/max)
    • Expiry time

Delete File

  1. From main menu, choose option 4
  2. Enter file ID to delete
  3. Confirm deletion
  4. File will be permanently removed

🏗️ Project Structure

SecureFileSharing/
├── src/
│   ├── common/
│   │   ├── User.java                 # User data model
│   │   ├── FileMetadata.java         # File metadata model
│   │   └── Protocol.java             # Communication protocol
│   ├── database/
│   │   └── DatabaseManager.java      # Database operations
│   ├── server/
│   │   ├── Server.java               # Main server class
│   │   ├── ClientHandler.java        # Client connection handler
│   │   ├── EncryptionModule.java     # Encryption/decryption operations
│   │   ├── FileManager.java          # File upload/download management
│   │   └── HoneypotModule.java       # Security monitoring
│   └── client/
│       └── Client.java               # Client application
├── lib/
│   └── sqlite-jdbc-*.jar             # SQLite JDBC driver
├── secure_storage/                    # Encrypted file storage
├── downloads/                         # Downloaded files location
└── secure_file_sharing.db            # SQLite database (auto-created)

🗄️ Database Schema

Users Table

  • user_id (Primary Key)
  • username (Unique)
  • password_hash
  • public_key

Files Table

  • file_id (Primary Key)
  • owner_id (Foreign Key)
  • file_name
  • encrypted_path
  • encrypted_key
  • upload_time
  • expiry_time
  • max_downloads
  • download_count
  • file_hash

Security Logs Table

  • log_id (Primary Key)
  • user_id (Foreign Key)
  • activity
  • timestamp
  • ip_address

File Shares Table

  • share_id (Primary Key)
  • file_id (Foreign Key)
  • shared_with_user_id (Foreign Key)

🔒 Security Architecture

Encryption Flow

Upload Process:

  1. User selects file
  2. System generates random AES-256 key
  3. File encrypted with AES key
  4. AES key encrypted with user's RSA public key
  5. SHA-256 hash generated for integrity
  6. Encrypted file stored on server
  7. Metadata saved to database

Download Process:

  1. Server verifies user authorization
  2. Checks file expiry and download limits
  3. Verifies file integrity using stored hash
  4. Returns encrypted file + encrypted AES key
  5. Client decrypts AES key using RSA private key
  6. Client decrypts file using AES key

Self-Destruct Mechanism

  • Server checks expiry time before every download
  • Tracks download count per file
  • Automatically deletes files that meet deletion criteria
  • Hourly cleanup task removes expired files

Honeypot System

  • Generates fake decoy files
  • Monitors failed login attempts
  • Logs unauthorized access attempts
  • Triggers when suspicious behavior detected

⚡ Advanced Configuration

Modify Server Port

Edit Server.java:

private static final int PORT = 5555; // Change to desired port

Adjust Thread Pool Size

Edit Server.java:

private static final int THREAD_POOL_SIZE = 10; // Increase for more concurrent clients

Change Encryption Settings

Edit EncryptionModule.java:

private static final int AES_KEY_SIZE = 256;  // 128, 192, or 256
private static final int RSA_KEY_SIZE = 2048; // 1024, 2048, or 4096

🧪 Testing the System

Test Self-Destructing Files

  1. Upload a file with 1-hour expiry
  2. Wait 1 hour
  3. Try to download - should get "FILE_EXPIRED" error

Test Download Limits

  1. Upload a file with max 2 downloads
  2. Download twice successfully
  3. Third download attempt should fail

Test Honeypot

  1. Make 3+ failed login attempts
  2. Successfully login
  3. List files - may see decoy files

🔧 Troubleshooting

"Class not found" error

Make sure SQLite JDBC driver is in the lib/ directory and included in classpath.

Connection refused

Ensure the server is running before starting the client.

File not found during download

File may have expired or reached download limit.

"Unable to decrypt" error

Verify you're using the correct private key for your account.

📊 Monitoring & Logs

All security events are logged in the database:

  • User registrations
  • Login attempts (success/failure)
  • File uploads/downloads
  • Unauthorized access attempts
  • Honeypot triggers

Query logs:

SELECT * FROM security_logs ORDER BY timestamp DESC LIMIT 20;

🚧 Limitations

  • Requires server to be running continuously
  • Large files may take longer to encrypt/decrypt
  • Private key must be stored securely by user
  • No built-in cloud storage integration
  • Single server instance (no load balancing)

🎯 Future Enhancements

  • Two-Factor Authentication (2FA)
  • Web-based GUI using JavaFX
  • Cloud storage integration (AWS S3, Google Cloud)
  • Mobile application support
  • Blockchain-based file tracking
  • Advanced access control (read-only, time-limited)
  • File versioning
  • Encrypted chat functionality
  • Multi-server clustering
  • REST API support

📄 License

This project is created for educational purposes. Use at your own risk.

🤝 Contributing

This is an academic project. For improvements:

  1. Test thoroughly
  2. Follow existing code structure
  3. Document all changes
  4. Ensure security features remain intact

⚠️ Security Notice

  • Never share your private key
  • Store private keys in a secure location
  • Use strong passwords
  • Regular backups recommended
  • This is an educational project - additional security auditing recommended for production use

📞 Support

For issues or questions:

  1. Check the troubleshooting section
  2. Review the database logs
  3. Verify all prerequisites are met
  4. Ensure proper file permissions

Built with ❤️ for secure file sharing

About

Multi-threaded Java client-server file sharing system with AES-256/RSA-2048 hybrid encryption, per-file key isolation, SHA-256 tamper detection, self-destructing files, and an active honeypot layer for intrusion detection.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors