Persistence
A set of the limited-flavors of Linux persistence.
Cron jobs
One of the most know and used persistence mecanism on Linux. Either a malicious cronjob is added, or a legitimate one weaponized : check everything !
Location
/etc/crontab- System wide cron jobs/var/spool/cron/crontabs- User cron jobs
Shell RC
When shells are starting, they execute rc and profiles files. These can be used as persistence mechanism.
Location
<user_profile>/.bashrc<user_profile>/.bash_profile/etc/bash.bashrc/profile
<user_profile>/.zshrc<user_profile>/.zprofile
<user_profile>/.kshrc<user_profile>/.profile
<user_profile>/.tcshrc<user_profile>/.cshrc<user_profile>/.login/etc/csh.cshrc/etc/csh.login
Daemons
Some Unix systems uses Run Levels to specify a certain state of operation of the OS. There are mainly 6 run levels. At runlevel 0, the system is halting. At runlevel 1, the user is a Single Mode. Etc.
For each of these levels, a specific script can associated. It will then be executed at startup and if the corresponding runlevel is selected.
Location
/etc/init.d/*- SystemV/etc/rd[0–6].d/*- RC/lib/systemd/system/*- Systemd/etc/systemd/system/*- Systemd
Setuid binary
A setuid binary will run with the rights of the owner. Creating a binary with setuid rights on the system might allow someone to keep privilege access to an already compromised machine.
To find binaries with setuid
Accounts / SSH Keys
While these are not direct persistence mecanims since it doesn't imply code execution, it is widely used by attackers to keep a hand on the compromised system.
Location
/etc/passwd- Addition of a user<userprofile>/.ssh/authorized_keys- Addition of a SSH key
Last updated
Was this helpful?