
Python के लिए लाइब्रेरी-स्तरीय eBPF सैंडबॉक्स (Linux और macOS): प्रति मॉड्यूल syscall-स्तरीय नियंत्रण।
secimport एक eBPF-आधारित सुरक्षा टूलकिट है जो प्रत्येक Python मॉड्यूल के लिए syscall प्रतिबंध लागू करता है, जिससे आपके अनुप्रयोग की सुरक्षा प्रोफ़ाइल पर सूक्ष्म नियंत्रण प्रदान होता है। इसे Linux के लिए seccomp-bpf की तरह समझें, लेकिन यह Python मॉड्यूल स्तर पर कार्य करता है।
git clone https://github.com/avilum/secimport.git
cd secimport/docker
./build.sh && ./run.sh
कमांड लाइन:
secimport --help
Usage: python -m secimport.cli [OPTIONS] COMMAND [ARGS]...
secimport is a comprehensive toolkit designed to enable the tracing, construction, and execution of secure Python runtimes. It leverages USDT probes and eBPF/DTrace technologies to enhance overall security measures.
WORKFLOW: 1. secimport trace / secimport shell 2. secimport build 3. secimport run
QUICKSTART: $ secimport interactive
For more details, please see https://github.com/avilum/secimport/wiki/Command-Line-Usage
╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
│ --help Show this message and exit. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ trace Trace a Python process using an entrypoint or interactive shell. │
│ shell Alias for 'trace'. │
│ trace-pid Trace a running process by PID. │
│ build Build a sandbox profile from a trace log. │
│ run Run a Python process inside the sandbox. │
│ interactive Run secimport in interactive mode. │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
secimport interactive
# In the Python shell that opens:
>>> secimport trace # Start tracing
>>> import requests # Perform actions you want to profile
>>> # Press CTRL+D to stop tracing
>>> secimport build # Build sandbox from trace
>>> secimport run # Run with enforcement
secimport trace # Trace a new Python process
secimport trace_pid <PID> # Trace an existing process
secimport build # Build sandbox from trace
secimport run [options] # Run with enforcement
# Stop on violation
secimport run --stop_on_violation=true
# Kill on violation
secimport run --kill_on_violation=true
import secimport
# Replace standard import with secure import
requests = secimport.secure_import('requests', allowed_syscalls=['open', 'read', ...])
USDT प्रोब्स के साथ Python इंस्टॉल करें:
# Configure Python with --enable-dtrace
# See detailed instructions in our wiki
एक समर्थित बैकएंड इंस्टॉल करें (eBPF या DTrace)
# Ubuntu/Debian
apt-get install bpftrace
# For other platforms, see our Installation wiki
secimport इंस्टॉल करें
pip install secimport
secimport जो सैंडबॉक्स बनाता है, उसके अलावा,
secimport build कमांड आपके ट्रेस किए गए कोड के लिए seccomp प्रोफ़ाइल के साथ एक nsjail सैंडबॉक्स बनाता है।
nsjail लिनक्स पर seccomp के साथ नेमस्पेस सैंडबॉक्सिंग सक्षम करता है
secimport निष्पादन योग्य bash स्क्रिप्ट के रूप में nsjail के साथ उपयोग करने के लिए स्वचालित रूप से seccomp प्रोफ़ाइल उत्पन्न करता है।
इसका उपयोग पूरी पायथन प्रक्रिया के सिसकॉल को सीमित करने के लिए किया जा सकता है, जो रक्षा की एक और परत है।