Border Guard Antivirus is a cyber-defense project inspired by a digital fantasy kingdom ๐ฐ, where processes are creatures ๐งฌ, ports are gates ๐ช, and malware is an invading army ๐ฆ โ๏ธ. The system works as an active defense wall ๐งฑ that monitors, detects, and reports suspicious behavior in real time on Linux and UNIX environments ๐ง.
This project blends operating systems concepts ๐ง , concurrent programming with threads ๐งต, low-level networking ๐ก, file integrity analysis ๐, and a GTK visual control panel ๐ฅ๏ธ.
Mission: build a resilient, proactive, and educational security layer that detects anomalies before they become incidents ๐จ.
- Border Patrol for files and mounted devices ๐๐งญ
- Monitors mounted paths (focused on /media) in near real time ๐.
- Builds and maintains a baseline of known files ๐งฑ.
- Detects suspicious events such as:
- file creation and deletion ๐โ๐โ
- abnormal file growth ๐
- extension changes ๐งช
- permission changes ๐
- ownership changes ๐ค
- replicated files ๐งฌ
- Sends real-time alerts to the interface ๐.
- Process and resource sentinels ๐ง ๐
- Reads process telemetry from /proc ๐.
- Tracks CPU and memory behavior over time ๐งฎ.
- Detects sustained overuse and anomalous peaks ๐จ.
- Generates alerts and can terminate processes that exceed thresholds for too long โ.
- Local port defense scanner ๐ก๐
- Scans local TCP ports on 127.0.0.1 ๐.
- Detects open ports and resolves service names when available ๐งพ.
- Classifies ports as expected or potentially compromised
โ ๏ธ . - Produces a live scan report for the GUI ๐๏ธ.
- Control hall interface with GTK ๐ฅ๏ธ๐งฐ
- Presents security data in dedicated windows ๐ช.
- Includes views for:
- active process table ๐
- process alerts ๐จ
- port scan alerts and report ๐ก
- file integrity alerts ๐
- Keeps monitoring modules active while the interface is running ๐.
The application uses concurrent modules coordinated by mutexes ๐:
-
Process thread ๐ง :
- reads /proc continuously and updates the internal process state.
-
File monitoring thread ๐:
- runs recursive inotify watches and compares events against baseline data.
-
Port scanning thread ๐ก:
- executes periodic scans and updates the shared report buffer.
-
GTK main thread ๐ฅ๏ธ:
- handles dialogs, windows, rendering, and user interaction.
During shutdown, all threads are canceled and joined safely, shared resources are released, and mutexes are destroyed cleanly ๐งน.
-
.git/ ๐งฌ
- Repository history, objects, refs, and version control metadata.
-
.gitignore ๐ซ
- Rules for files that should not be committed.
-
.vscode/ ๐ ๏ธ
- Local workspace/editor settings and tooling metadata.
-
Interfaz.c ๐ฅ๏ธ
- Main application entry point and GTK initialization.
- Thread creation and lifecycle coordination.
- GUI actions for process, file, and port alert visualization.
-
Prosesos.h ๐ง
- Process monitoring logic based on Linux /proc.
- CPU and memory threshold evaluation.
- Alert generation and optional process termination.
-
List.h ๐
- Doubly linked list used as live process state storage.
- Node creation, insertion, update, deletion, and cleanup operations.
-
Alert.h ๐จ
- Linked list for process alert events.
- Stores process name, alert type, and timestamp.
-
guardian_frontera.h ๐๐
- inotify-based file and directory monitoring.
- Baseline management, SHA-256 hashing, watch mapping, and event analysis.
-
port_scanner.h ๐ก
- Non-blocking localhost TCP scanner.
- Suspicious port detection policy and GTK alert dispatch.
- Shared report buffer and synchronization primitives.
-
README.md ๐
- Technical and functional project documentation.
This project is a combination of systems programming, security analysis, and GUI engineering. The stack is intentionally low-level to provide control, performance, and educational depth.
- Programming language and systems style ๐ป
- C language is used for direct memory control, deterministic performance, and close interaction with operating system APIs.
- The codebase follows a modular design where each header encapsulates a security domain.
- Operating system integration (Linux/UNIX) ๐ง
- /proc provides process metrics (CPU usage, memory footprint, process identity).
- inotify provides real-time file system notifications for creation, deletion, modification, and metadata changes.
- POSIX calls like stat, select, read, and kill support low-level monitoring and response behavior.
- Concurrency and synchronization ๐งต๐
- pthread is used to run process monitoring, file monitoring, and port scanning in parallel.
- Mutexes protect shared structures such as process state and scan reports, preventing race conditions.
- This model keeps the GUI responsive while security tasks run continuously.
- Networking and socket scanning ๐ก๐
- TCP sockets are created in non-blocking mode for efficient scanning.
- select and getsockopt are used to validate connection state without blocking the entire application.
- Localhost scanning is used to detect exposed services and suspicious communication surfaces.
- Cryptography and integrity verification ๐๐งฌ
- OpenSSL EVP and SHA-256 are used to fingerprint file contents.
- Hash comparisons make it possible to detect real content changes, file replication, and integrity anomalies.
- Graphical layer and event loop ๐ฅ๏ธ๐๏ธ
- GTK provides windows, dialogs, tables, text views, and interaction components.
- GLib utilities provide dynamic strings, memory helpers, and main-context callbacks for safe cross-thread UI notifications.
- Security findings are surfaced visually through alert dialogs and report windows.
- Internal data models ๐งฑ๐
- A custom doubly linked list stores evolving process telemetry.
- A dedicated alert list keeps chronological security notifications.
- File baseline structures maintain file metadata snapshots for differential analysis.
- Security detection strategy ๐ก๏ธ
โ ๏ธ
- Rule-based heuristics classify suspicious ports.
- Resource threshold policies identify abusive processes.
- Baseline-delta logic detects suspicious filesystem drift.
- Startup initializes GTK, mutexes, and monitoring threads โ๏ธ.
- Process monitor reads /proc and updates process telemetry continuously ๐.
- File monitor receives inotify events and compares against baseline hashes and metadata ๐.
- Port scanner runs periodic non-blocking scans and updates shared reports ๐ก.
- GUI thread presents alerts and live information to the user in dedicated windows ๐ฅ๏ธ.
- Shutdown sequence cancels threads, joins them safely, and frees all shared resources ๐งน.
This project is designed for Linux/UNIX environments because it depends on /proc and inotify.
- Install build dependencies (Ubuntu/Debian):
sudo apt update
sudo apt install -y build-essential pkg-config libgtk-3-dev libssl-dev libx11-dev- Go to the project root and compile:
gcc Interfaz.c -o border_guard $(pkg-config --cflags --libs gtk+-3.0) -lssl -lcrypto -pthread- Run the application:
./border_guard- Optional (recommended for full monitoring permissions):
sudo ./border_guardQuick notes:
- The GUI opens with buttons for process, port, and file alerts.
- File monitoring is oriented to mounted paths (especially
/media). - If
pkg-configcannot find GTK, verifylibgtk-3-devis installed.
Border Guard Antivirus is both a functional defensive platform and a practical systems-security lab ๐งช. Its strength comes from combining process telemetry, filesystem integrity analysis, and network surface monitoring into one coordinated real-time application ๐ก๏ธ๐ก๐๐ง .