analyzing-persistence-mechanisms-in-linux
This skill detects and analyzes persistence mechanisms in Linux systems by scanning crontab entries, systemd units, LD_PRELOAD injections, shell profile modifications, SSH backdoors, and init scripts. Use it during security incident investigations to identify how attackers maintain access, build forensic timelines from auditd logs, or develop detection rules for threat hunting and monitoring coverage validation.
git clone --depth 1 https://github.com/mukul975/Anthropic-Cybersecurity-Skills /tmp/analyzing-persistence-mechanisms-in-linux && cp -r /tmp/analyzing-persistence-mechanisms-in-linux/skills/analyzing-persistence-mechanisms-in-linux ~/.claude/skills/analyzing-persistence-mechanisms-in-linuxSKILL.md
# Analyzing Persistence Mechanisms in Linux ## Overview Adversaries establish persistence on Linux systems through crontab jobs, systemd service/timer units, LD_PRELOAD library injection, shell profile modifications (.bashrc, .profile), SSH authorized_keys backdoors, and init script manipulation. This skill scans for all known persistence vectors, checks file timestamps and integrity, and correlates findings with auditd logs to build a timeline of persistence installation. ## When to Use - When investigating security incidents that require analyzing persistence mechanisms in linux - When building detection rules or threat hunting queries for this domain - When SOC analysts need structured procedures for this analysis type - When validating security monitoring coverage for related attack techniques ## Prerequisites - Root or sudo access on target Linux system (or forensic image) - auditd configured with file watch rules on persistence paths - Python 3.8+ with standard library (os, subprocess, json) - Optional: OSSEC/Wazuh agent for file integrity monitoring alerts ## Steps 1. **Scan Crontab Entries** — Enumerate all user crontabs, /etc/cron.d/, /etc/cron.daily/, and anacron jobs for suspicious commands 2. **Audit Systemd Units** — Check /etc/systemd/system/ and ~/.config/systemd/user/ for non-package-managed service and timer units 3. **Detect LD_PRELOAD Hijacking** — Check /etc/ld.so.preload and LD_PRELOAD environment variable for injected shared libraries 4. **Inspect Shell Profiles** — Scan .bashrc, .bash_profile, .profile, /etc/profile.d/ for injected commands or reverse shells 5. **Check SSH Authorized Keys** — Audit all authorized_keys files for unauthorized public keys with command restrictions 6. **Correlate Auditd Logs** — Search auditd logs for file modification events on persistence paths to build an installation timeline 7. **Generate Persistence Report** — Produce a risk-scored report of all discovered persistence mechanisms ## Expected Output - JSON report of all persistence mechanisms found with risk scores - Timeline of persistence installation from auditd correlation - MITRE ATT&CK technique mapping (T1053, T1543, T1574, T1546) - Remediation commands for each detected persistence mechanism
Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.
Detect dangerous ACL misconfigurations in Active Directory using ldap3
Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.
Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect
Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups' TTPs for detection-gap analysis. Use to compare threat-actor technique coverage, find gaps in detection engineering, or produce Navigator visualizations for threat-intel reporting.
Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query