
Linux system-call monitor using ptrace to trace file, process, network, and memory activity, with namespace isolation and machine learning classification for behavioral security analysis.
A Linux system-call monitoring and behavioral security analysis tool combining ptrace-based tracing, lightweight namespace isolation, and machine learning classification.
SysTrace observes the runtime behavior of a target program at the system-call level, extracts behavioral features, and classifies the observed activity as benign or malicious using a trained Random Forest model. It is built primarily in C for low-level tracing and isolation, with a Python/scikit-learn component for classification and reporting.
SysTrace traces a target process using ptrace, capturing system calls related to file access, process creation, network activity, and memory operations. The captured behavior is aggregated into syscall statistics and a feature vector, which is passed to a trained Random Forest classifier to produce a benign/malicious prediction. Results are compiled into a structured HTML security report.
The project also includes a lightweight sandboxing layer built on Linux namespaces, used to isolate the target process during tracing.

ptrace to attach to and inspect target processes, including syscall arguments and registers.open/openat, read, close, chmodexecve, fork, clone, killsocket, connectmmap, mprotectHeuristic rules flag suspicious behavioral patterns, including:
mmap/mprotect usage)An isolation layer built directly on Linux namespace primitives:
clone() with CLONE_NEWUSER, CLONE_NEWPID, CLONE_NEWNSMS_PRIVATEpivot_root and umount2tmpfs-backed minimal root filesystem, constructed at runtime under /tmp/systrace-rootThis provides basic process, PID, and mount isolation for the traced target — it is not a container runtime replacement.
file, process, network, fork, connect, execve, read, open, close, memory, chmod, kill, labelRandomForestClassifier (scikit-learn) is trained on these vectors to distinguish benign from malicious behavior.ml/syscall_model.pkl.DATASETfeatures.json (raw feature data) and report.html (human-readable report).[file, process, network, fork, connect, execve, read, open, close, memory, chmod, kill]
[15, 2, 0, 0, 0, 2, 1, 10, 4, 14, 6, 0]
linux-syscall-monitor/
├── include/
├── src/
│ ├── tracer.c # Core ptrace-based syscall tracer
│ ├── syscall.c # Syscall interception/handling
│ ├── namespace.c # Namespace/clone setup
│ ├── set_root.c # pivot_root / minimal rootfs setup
│ ├── file_monitor.c # File operation monitoring
│ ├── process_monitor.c # Process creation/execution monitoring
│ ├── network_monitor.c # Network activity monitoring
│ ├── memory_monitor.c # Memory-related activity monitoring
│ ├── fd_tables.c # File descriptor tracking
│ ├── rules.c # Rule-based detection logic
│ ├── alert.c # Security alert generation
│ ├── stat.c # Syscall statistics aggregation
│ └── dataset.c # Feature vector / dataset generation
├── ml/
│ ├── train.py # Random Forest training script
│ ├── predict.py # Classification / inference script
│ └── syscall_model.pkl # Trained model
├── dashboard/ # Report/dashboard assets
├── tests/
├── Makefile
├── dataset.csv
└── README.md
ptrace-based tracing introduces observable overhead and is detectable/evadable by sufficiently sophisticated malware.SysTrace is a research and learning project exploring Linux internals, system-call tracing, namespace-based isolation, and behavioral malware detection using machine learning. It is not a certified or production-ready security tool and should not be relied upon as the sole defense against malicious software. Use in isolated, controlled environments only.
This project was built to explore and demonstrate:
ptraceclone, pivot_root, mount namespaces)| Category | Stack |
|---|
| Core tracer | C, Linux ptrace |
| Isolation | Linux namespaces, clone, mount namespaces, pivot_root, tmpfs |
| Machine learning | Python, scikit-learn, Random Forest |
| Data / output | JSON, HTML |
| Build | Make |