Post

Secure HTTP Server

Secure HTTP Server

A simple HTTP server written in C that demonstrates real memory safety using Fil-C. The code contains patterns that would be easily exploitable in normal C, but Fil-C’s runtime protection catches all memory safety violations.

Installation and Execution

Step 1: Install Dependencies

First, ensure your system has the necessary tools to handle the downloads and execution environment.

1
2
3
# the below commands are for fedora or Red Hat based OSs, ensure you use appropriate command for your distro eg. apt for debian based systems.
sudo dnf update
sudo dnf install git wget xz python3 cmake ninja-build gcc gcc-c++ patchelf

Step 2: Download the Fil-C

Download and Extract: Check fil-c.org for the latest version

1
2
3
4
mkdir ~/filc_project && cd ~/filc_project
wget https://fil-c.org/download/filc-0.677-linux-x86_64.tar.xz
tar -xf filc-0.677-linux-x86_64.tar.xz
cd filc-0.677-linux-x86_64

Run Setup:

1
./setup.sh

Step 3: Compile with Fil-C

Instead of using standard gcc, you must use the Fil-C compiler located in the build/bin directory.

1
build/bin/clang -O2 -g -o server server.c
1
2
3
4
# flags 
-O2: Standard optimization.
 -g: Includes debugging information (highly recommended for Fil-C to provide better error reports).
 -o server: Names your output program.

Step 4: Run the Program

Now you can start your memory-safe server:

1
./server

You should see the message: Starting Server on port 8080

Download the Script

This post is licensed under CC BY 4.0 by the author.