This project leverages eBPF (Extended Berkeley Packet Filter) to monitor file operations and a machine learning model to detect ransomware behavior in real-time. When ransomware activity is detected, the process is automatically terminated.
In this work, we propose a two-phased approach to detect and deter ransomware in real-time. We leverage the capabilities of eBPF (Extended Berkeley Packet Filter) and artificial intelligence (AI) to develop proactive and reactive methods. In the first phase, we utilize signature-based detection, where we employ custom eBPF programs to trace the execution of new processes and perform hash-based analysis against a known ransomware dataset. In the second, we employ a behavior-based technique that focuses on monitoring the process activities using a custom eBPF program and the creation of ransom notes — a prominent indicator of ransomware activity through the use of Natural Language Processing (NLP). By leveraging eBPF’s low-level tracing capabilities and integrating NLP-based machine learning algorithms, our solution achieves an impressive 99.79% accuracy in identifying ransomware incidents within a few seconds on the onset of zero-day attacks.
This work is part of LeARN: Leveraging eBPF and AI for Ransomware Nose Out and is published in COMSNETS'25 CSP proceedings. You can take a look at the attached research paper for more details.
To run this project, ensure you have the required dependencies installed.
Kernel headers are required for eBPF programs to function correctly.
sudo apt-get update
sudo apt-get install -y linux-headers-$(uname -r)Install bcc, bpfcc-tools, and related dependencies.
sudo apt-get install -y bpfcc-tools libbpfcc libbpfcc-dev python3-bpfccInstall bpftrace to facilitate eBPF debugging and tracing.
sudo apt-get install -y bpftraceIt is recommended that a virtual environment for Python dependencies be created while using system-installed eBPF tools.
python3 -m venv bcc_env --system-site-packages
source bcc_env/bin/activateEnsure you have Python 3 and pip installed. Then, install the necessary Python libraries inside the virtual environment.
pip install numpy scikit-learn nltk pandasFirst run the below bash command before downloading the ntlk resources, to ensure that nltk resources are downloaded in the virtual environment.
sudo $(which python)import nltk
nltk.download('punkt_tab')
nltk.download('punkt')
nltk.download('stopwords')
nltk.download('wordnet')Ensure that the pre-trained model.pkl file is downloaded and change the location variable accordingly.
To start monitoring for ransomware activity, run:
source bcc_env/bin/activate
sudo $(which python) eBPF_RansomNote.py- If ransomware activity is detected, the process is killed.
- If the process is benign, it is allowed to continue execution.
- The eBPF program attaches to the
sys_enter_openattracepoint and captures file creations. - The filename and process ID (PID) are extracted.
- If the file can be read, its content is preprocessed using NLP.
- The TF-IDF vectorizer and Random Forest model predict whether the process is ransomware.
- If classified as ransomware, the process is terminated.