Skip to content

km/File-Server-Public

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

File-Server

A secure file storage server with client-server architecture that provides encrypted file transfer and storage. Written in C using OpenSSL for encryption and SQLite for user management.

Table of Contents

Features

  • Secure Authentication: Uses Argon2 for password hashing
  • Encrypted File Transfer: All files are encrypted with AES-256-CBC before transfer
  • Multi-user Support: Each user has isolated file storage
  • Threaded Server: Handles multiple clients simultaneously
  • Command-line Interface: Easy-to-use menu system
  • Secure Storage: Files are stored encrypted on the server

Libraries and Dependencies

Required Libraries:

  • OpenSSL (for encryption and TLS)
  • SQLite3 (for user database)
  • Argon2 (for password hashing)
  • pthread (for threading)

Installation:

Linux (Debian/Ubuntu):

sudo apt-get update
sudo apt-get install libssl-dev libsqlite3-dev libargon2-dev

macOS (using Homebrew):

brew install openssl sqlite argon2

Windows:

  1. Install vcpkg: https://vcpkg.io/en/getting-started.html
  2. Then install dependencies:
vcpkg install openssl:x64-windows sqlite3:x64-windows argon2:x64-windows

Server Documentation

Configuration:

  1. Generate SSL certificates:
    openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -days 365 -nodes

Commands:

The following is the protocol the client-server implements for communication

  • auth username:password - Authenticate a user
  • regi username:password - Register a new user
  • list - List all user files
  • dele filename - Delete a file
  • upld filesize filename - Upload a file
  • dwld filename - Download a file

Starting the Server:

./server

The server will prompt for a port number (default: 8080)

Client Documentation

Connection:

When starting the client, you'll need to provide:

  • Server host (default: 127.0.0.1)
  • Server port (default: 8080)

Menu Options:

  1. Create Account: Register a new user
  2. Login: Authenticate with existing credentials
  3. Delete File: Remove a file from server
  4. List Files: View all your files on server
  5. Upload File: Send a file to the server (automatically encrypted)
  6. Download File: Retrieve a file from server (automatically decrypted)
  7. Exit: Close the connection

File Encryption:

  • Files are encrypted with AES-256-CBC before upload
  • The encryption key is derived from your password
  • Files remain encrypted on the server, and are only decrypted client side

Usage

Server:

  1. Compile:
    gcc -o server main.c user.c socket.c -lsqlite3 -lssl -lcrypto -largon2 -lpthread
  2. Run:
    ./server

Client:

  1. Compile:
    gcc -o client client.c -lssl -lcrypto
  2. Run:
    ./client

Security

Implemented Protections:

  • TLS 1.3 for all communications
  • Argon2id for password hashing
  • AES-256-CBC for file encryption
  • Secure memory handling
  • Protection against buffer overflows
  • Per-user file isolation

Best Practices:

  1. Use strong passwords
  2. Keep your SSL certificates secure
  3. Run server on trusted networks only
  4. Regularly backup the database directory

File Structure

file-server/
│
├── server/
│   ├── main.c           - Main server logic
│   ├── user.c           - User authentication and management
│   ├── user.h           - User function declarations
│   ├── socket.c         - SSL/TLS and network operations
│   └── socket.h         - Socket function declarations
│
├── client/
│   └── client.c         - Client implementation
│   └── socket.c         - SSL/TLS and network operations
├── database/            - Automatically created
│   ├── users.db         - SQLite user database
│   └── [user_id]/       - Per-user encrypted files
│
├── server.crt           - your SSL certificate
├── server.key           - your SSL private key
└── README.md            - This file

Notes

  • The server creates a directory structure automatically
  • First run will create the SQLite database
  • Each user gets their own directory under database/
  • Files are stored with their original names but encrypted contents
  • The server must be restarted to change ports

About

Encrypted File Server written in C with authentication and file management

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages