How alexevgmart/pwn_defense_for_ctf works
Project Overview and Purpose
• The README makes it clear that this system is built to secure binary services in a CTF setting. Its purpose is to monitor and restrict non-printable characters in system I/O (via a Linux kernel module) while also providing a networked monitoring and control interface.
• The system is divided into multiple pieces: a kernel-space module that adds syscall monitoring, a user-space component that interacts with this low-level module, a set of server-side components (including a TCP server and a web application built with Docker), and a lightweight HTTP proxy (implemented in Go) for routing traffic.
Main Architectural Components
a. Kernel Module (kernel_module directory):
• Contains a Linux kernel module (with files like read_and_write.c, ftrace_helper.h, user.c, and the Makefile).
• It intercepts sys_read and sys_write to filter non-printable characters.
• Runs on a dedicated host, isolated from general network access.
b. User-Space Binary:
• Located within the kernel_module folder (the “user” binary).
• It sends data to the server (using the provided server IP/port) from the same host where the kernel module runs.
c. Server Components (server directory):
• Contains environment settings (.env), docker-compose configuration, and sub-components.
• Rules:
• The “rules” folder holds multiple JSON files that define formatting or validation rules (e.g., addr.json, flag.json, etc.), which likely configure or inform both data validation and potential filtering mechanisms.
• TCP Server:
• In the folder server/tcp_server, a Dockerfile and tcp_server.py are included – this component likely handles network communications for binary services.
• Web Application:
• In server/web_app, there’s a Dockerfile, various static assets (CSS/JS), and templates (for rendering the editor, login, etc.).
• Also includes a services.json file which is crucial for configuring redirection (pointing to real backend services).
• The web server (web_server.py) serves the monitoring/control interface.
d. Proxy (proxy directory):
• Contains a Go module (proxy/go.mod, proxy/proxy.go).
• Acts as a “pseudo_http_proxy” that accepts HTTP requests from hosts in the general network and routes them to the internal web application’s host/port.
• This component is set up so that external access is funneled safely to the dedicated web services.
Relationships and Data Flow
• The kernel module runs on an isolated host, monitoring system calls. Its associated “user” binary sends monitoring data from this host to the central server.
• The central server has at least two main parts:
– A TCP server designed to handle specific binary service communications.
– A web application deployed via Docker (along with its associated configuration/settings and static/dynamic files) that presents the monitoring dashboard or control UI.
• The Go-based proxy sits on a host exposed to the public network. It receives HTTP traffic and routes it to the web application (using configuration from services.json).
• The system is partitioned based on security: the internal host (running kernel module and user binary) is isolated, while web access occurs on a separate, controlled host with the proxy mediating public access.
Architectural Patterns and Technologies
• Separation of Concerns / Tiered Architecture: The system clearly separates kernel-space monitoring, user-level data sending, service processing (via TCP server and web app), and external HTTP proxying.
• Containerization: The web app and TCP server use Docker for isolation and deployment, as shown by Dockerfiles and docker-compose.yml.
• Modular Design: Each module is self-contained (kernel module, proxy, server components) and interacts with others via defined interfaces (e.g., sending data over the network or via configuration JSONs).
• Use of configuration files (such as JSON rule sets and services.json) shows an emphasis on flexible, pluggable components.