Linux persistence techniques
Every place on a Linux system that makes code run again: what reads it and when, where it lives, how intruders abuse it, and how to check a host. Each page maps to MITRE ATT&CK and to what the Linux Persistence tool flags.
By when it fires
At boot
- Kernel modulesHow attackers load rootkit kernel modules at boot and abuse modprobe install lines, what the configuration reveals, and how to check and clean a Linux host.T1547.006root
- rc.localHow /etc/rc.local runs commands as root at every boot through rc-local.service, how attackers plant payloads in it, and how to check and clean a host.T1037.004root
- systemd generatorsHow systemd generators run as root at every boot and daemon-reload, how attackers use them to create units that exist only in /run, and how to audit them.T1543.002root
- systemd servicesHow attackers persist with systemd services, sockets, path units, drop-in overrides and lingering user units on Linux, and how to find and remove them.T1543.002Users and root
- SysV init scriptsHow attackers persist with /etc/init.d scripts and rc?.d start links on SysV and systemd hosts, and how to find, verify and remove a malicious init script.T1037.004root
On a schedule
- At jobsHow attackers use at and atd for delayed or self-renewing jobs on Linux, what a spool file reveals about who queued it, and how to list and remove jobs.T1053.002Users and root
- Cron jobsHow attackers persist with crontab, /etc/cron.d, run-parts folders and anacron on Linux, and how to find, verify and remove a malicious cron job.T1053.003Users and root
- Logrotate scriptsHow attackers hide commands in logrotate postrotate, prerotate, firstaction and lastaction scripts that run daily as root, and how to find and remove them.root
- systemd timersHow attackers use systemd timers instead of cron for scheduled persistence on Linux, where timer units live, and how to list, verify and remove them.T1053.006Users and root
At login
- Local accountsHow attackers add UID 0 users, empty passwords, shells on service accounts and root-equivalent groups on Linux, and how to audit passwd, shadow and group.T1136.001T1078.003root
- MOTD scriptsHow Debian and Ubuntu run /etc/update-motd.d scripts as root at every login through pam_motd, how attackers abuse them, and how to check and clean a host.root
- XDG autostartHow .desktop files in /etc/xdg/autostart and ~/.config/autostart start programs at every desktop login, how attackers abuse them, and how to check a host.T1547.013Users and root
Each new shell
- History tamperingHow intruders stop or wipe shell history on Linux (.bash_history linked to /dev/null, HISTFILE unset), why it travels with persistence, and how to check.T1070.003Users and root
- Shell startup filesHow .bashrc, .profile, /etc/profile.d and zsh files run code at every login or shell, how attackers plant aliases and payloads in them, and how to check.T1546.004Users and root
At SSH login
- SSH authorized keysHow attackers plant SSH keys, forced commands and ~/.ssh/rc scripts to keep access to Linux hosts, and how to find rogue authorized_keys entries.T1098.004Users and root
- sshd configurationHow attackers change sshd_config, its drop-ins and Match blocks to keep SSH access to Linux hosts, and how to audit the effective OpenSSH server settings.T1098.004root
At authentication
Privilege
On an event
On network change
On package install
Every program start
Cheat sheet
One line per technique: when it runs, who can set it up, the main locations and the ATT&CK mapping.
| Technique | Runs | Set up by | Main locations | ATT&CK |
|---|---|---|---|---|
| At jobs | On a schedule | Users and root | /var/spool/cron/atjobs/* · /var/spool/at/* · /etc/at.allow · /etc/at.deny | T1053.002 |
| Cron jobs | On a schedule | Users and root | /etc/crontab · /etc/cron.d/* · /etc/cron.hourly/* · /etc/cron.daily/* | T1053.003 |
| History tampering | Each new shell | Users and root | ~/.bash_history · ~/.zsh_history · /root/.bash_history · ~/.bashrc | T1070.003 |
| Kernel modules | At boot | root | /etc/modules · /etc/modules-load.d/*.conf · /etc/modprobe.d/*.conf · /usr/lib/modules-load.d/*.conf | T1547.006 |
| LD_PRELOAD / ld.so.preload | Every program start | Users and root | /etc/ld.so.preload · /etc/ld.so.conf · /etc/ld.so.conf.d/*.conf · /etc/environment | T1574.006 |
| Local accounts | At login | root | /etc/passwd · /etc/shadow · /etc/group · /etc/gshadow | T1136.001, T1078.003 |
| Logrotate scripts | On a schedule | root | /etc/logrotate.conf · /etc/logrotate.d/* | — |
| MOTD scripts | At login | root | /etc/update-motd.d/* · /etc/pam.d/sshd · /etc/pam.d/login · /run/motd.dynamic | — |
| Network hooks | On network change | root | /etc/NetworkManager/dispatcher.d/* · /etc/network/if-up.d/* · /etc/network/if-pre-up.d/* · /etc/ppp/ip-up.d/* | — |
| Package manager hooks | On package install | root | /etc/apt/apt.conf.d/* · /etc/dpkg/dpkg.cfg.d/* · /etc/dnf/plugins/*.conf · /etc/yum/pluginconf.d/*.conf | T1546.016 |
| PAM backdoors | At authentication | root | /etc/pam.d/* · /etc/pam.conf · /usr/share/pam-configs/* · /usr/lib/x86_64-linux-gnu/security/*.so | T1556.003 |
| rc.local | At boot | root | /etc/rc.local · /etc/rc.d/rc.local · /usr/lib/systemd/system/rc-local.service | T1037.004 |
| Shell startup files | Each new shell | Users and root | /etc/profile · /etc/profile.d/*.sh · /etc/bash.bashrc · /etc/bashrc | T1546.004 |
| SSH authorized keys | At SSH login | Users and root | ~/.ssh/authorized_keys · ~/.ssh/authorized_keys2 · /root/.ssh/authorized_keys · ~/.ssh/rc | T1098.004 |
| sshd configuration | At SSH login | root | /etc/ssh/sshd_config · /etc/ssh/sshd_config.d/*.conf · /etc/ssh/sshrc · /etc/default/ssh | T1098.004 |
| Sudoers rules | Privilege | root | /etc/sudoers · /etc/sudoers.d/* · /etc/sudo.conf | T1548.003 |
| systemd generators | At boot | root | /etc/systemd/system-generators/* · /usr/local/lib/systemd/system-generators/* · /usr/lib/systemd/system-generators/* · /run/systemd/system-generators/* | T1543.002 |
| systemd services | At boot | Users and root | /etc/systemd/system/* · /etc/systemd/system/<unit>.d/*.conf · /usr/lib/systemd/system/* · /usr/local/lib/systemd/system/* | T1543.002 |
| systemd timers | On a schedule | Users and root | /etc/systemd/system/*.timer · /etc/systemd/system/timers.target.wants/* · /usr/lib/systemd/system/*.timer · ~/.config/systemd/user/*.timer | T1053.006 |
| SysV init scripts | At boot | root | /etc/init.d/* · /etc/rc[0-6S].d/* · /etc/rc.d/init.d/* · /etc/rc.d/rc[0-6].d/* | T1037.004 |
| udev rules | On an event | root | /etc/udev/rules.d/*.rules · /run/udev/rules.d/*.rules · /usr/lib/udev/rules.d/*.rules · /lib/udev/rules.d/*.rules | T1546.017 |
| XDG autostart | At login | Users and root | /etc/xdg/autostart/*.desktop · ~/.config/autostart/*.desktop | T1547.013 |
MITRE ATT&CK coverage
The ATT&CK techniques these pages and the tool cover. Some mechanisms have no sub-technique of their own and are listed under the closest parent.