Skip to content

fookang/File-transfer-Web-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Transfer Server

A small HTTPS file transfer server written in C. It supports user registration/login, cookie-based sessions, and file uploads.

Features

  • HTTPS Support: TLS/SSL encryption using OpenSSL
  • User Authentication: Registration and login with secure password hashing (PBKDF2-SHA256)
  • Session Management: Cookie-based authentication with cryptographically secure random session tokens
  • File Upload: Support for multipart/form-data file uploads
  • IPv4/IPv6 Support: Dual-stack networking
  • Multiple Content Types: Serves HTML, CSS, JavaScript, images, PDFs, and more

Requirements

  • GCC compiler
  • OpenSSL development libraries
  • Linux environment

Installation

  1. Clone or download the repository

  2. Install dependencies (Ubuntu/Debian):

sudo apt-get install libssl-dev
  1. Generate SSL certificates:
openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 365

Note: the generated certificate is self-signed, so your browser will likely show a security warning when accessing https://localhost:8080.

  1. Build the project:
make

Usage

Start the server:

./file_transfer

The server will listen on port 8080. Access it via:

  • https://localhost:8080

Project Structure

├── Src/              # Source files
│   ├── file_transfer.c    # Main server implementation
│   ├── client_info.c      # Client connection management
│   └── cookie.c           # Cookie implementation
├── Inc/              # Header files
│   ├── client_info.h      # Client data structures
│   ├── users.h            # User authentication functions
│   └── cookie.h           # Session cookie management
├── Data/             # Persistent data storage
│   ├── users.txt          # User credentials
│   └── cookies.txt        # Active sessions
├── public/           # Web content
│   ├── *.html             # Public pages (login, register, home)
├── Makefile          # Build configuration
└── README.md         # This file

Routes

  • GET / - Home page
  • GET /login.html - Login page
  • POST /login - User login
  • GET /register.html - Registration page
  • POST /register - User registration
  • POST /upload - File upload (authenticated)

Security Features

  • Password hashing with PBKDF2-SHA256 (10,000 iterations)
  • 16-byte cryptographic salt per user
  • 256-byte random session tokens, stored as 512-character hex cookies
  • HTTPS/TLS encryption for all communications
  • Session-based authentication

Development

Clean build artifacts:

make clean

Rebuild from scratch:

make re

Notes

  • Default port: 8080
  • User data persists in Data/users.txt
  • Active sessions stored in Data/cookies.txt

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors