# tmanh191/ebpf-ransomware-reactive-detector architecture

> Architecture diagram of the GitHub repository tmanh191/ebpf-ransomware-reactive-detector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tmanh191/ebpf-ransomware-reactive-detector
- Repository: https://github.com/tmanh191/ebpf-ransomware-reactive-detector

## Overview

This is a Linux eBPF ransomware detector. A privileged operator starts the Python controller, which configures BPF maps and attaches probes; kernel events are tracked and scored per process, then delivered to Python for display, CSV logging, and termination of processes flagged with major severity. Detection covers filesystem, encryption, and network activity, with sequence and threshold-pattern matching. The shared C header defines the event and configuration structures. The source excerpts are partial, so only shown wiring and README-documented capabilities are represented.

Main entry points: [`detector.py`](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py) (Event handler), [`bpf.c`](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c) (Kernel probes), [`bpf.h`](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.h) (Event schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_kernel["Kernel Monitoring"]
  node_probes["Kernel probes<br/>[bpf.c]"]
  node_event_schema["Event schema<br/>[bpf.h]"]
  node_event_stream["Event ring buffer<br/>[bpf.c]"]
end

subgraph group_detection["Detection"]
  node_controller["Python controller<br/>[detector.py]"]
  node_tracking["Process event tracking<br/>[bpf.c]"]
  node_scoring["Pattern and threshold scoring<br/>[bpf.c]"]
end

subgraph group_response["Response and Reporting"]
  node_event_handler["Event handler<br/>[detector.py]"]
  node_termination["Process termination<br/>[detector.py]"]
  node_terminal["Terminal output<br/>[detector.py]"]
  node_csv_log["CSV event log<br/>[detector.py]"]
end

node_operator(("Root operator"))
node_bcc["BCC runtime"]

node_operator -->|"starts"| node_controller
node_controller -->|"loads BPF"| node_bcc
node_controller -->|"configures and attaches"| node_probes
node_probes -->|"records events"| node_tracking
node_tracking -->|"analyzes stats"| node_scoring
node_scoring -->|"submits events"| node_event_stream
node_event_stream -->|"delivers events"| node_event_handler
node_event_handler -->|"kills major alerts"| node_termination
node_event_handler -->|"prints events"| node_terminal
node_event_handler -->|"logs events"| node_csv_log
node_probes -->|"uses definitions"| node_event_schema

click node_controller "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py"
click node_probes "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c"
click node_event_schema "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.h"
click node_tracking "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c"
click node_scoring "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c"
click node_event_stream "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c"
click node_event_handler "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py"
click node_termination "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py"
click node_terminal "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py"
click node_csv_log "https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_probes,node_event_schema,node_event_stream toneBlue
class node_controller,node_tracking,node_scoring toneAmber
class node_event_handler,node_termination,node_terminal,node_csv_log toneMint
class node_operator,node_bcc toneIndigo
```

## Components

### Kernel Monitoring

- [Kernel probes](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c): `bpf.c`
- [Event schema](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.h): `bpf.h`
- [Event ring buffer](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c): `bpf.c`

### Detection

- [Python controller](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py): `detector.py`
- [Process event tracking](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c): `bpf.c`
- [Pattern and threshold scoring](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/bpf.c): `bpf.c`

### Response and Reporting

- [Event handler](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py): `detector.py`
- [Process termination](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py): `detector.py`
- [Terminal output](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py): `detector.py`
- [CSV event log](https://github.com/tmanh191/ebpf-ransomware-reactive-detector/blob/main/detector.py): `detector.py`

### Other components

- **Root operator**
- **BCC runtime**

## Connections

- Root operator → Python controller: starts (evidence: `README.md`)
- Python controller → BCC runtime: loads BPF (evidence: `detector.py`)
- Python controller → Kernel probes: configures and attaches (evidence: `detector.py`)
- Kernel probes → Process event tracking: records events (evidence: `bpf.c`)
- Process event tracking → Pattern and threshold scoring: analyzes stats (evidence: `bpf.c`)
- Pattern and threshold scoring → Event ring buffer: submits events (evidence: `bpf.c`)
- Event ring buffer → Event handler: delivers events (evidence: `detector.py`)
- Event handler → Process termination: kills major alerts (evidence: `detector.py`)
- Event handler → Terminal output: prints events (evidence: `detector.py`)
- Event handler → CSV event log: logs events (evidence: `detector.py`)
- Kernel probes → Event schema: uses definitions (evidence: `bpf.c`)
