The fundamentals of persistence with Bash
Persistence refers to maintaining access to a compromised system after the initial exploitation. For pentesters assessing Linux systems, understanding Bash-based persistence techniques is essential. This section covers some fundamental methods for establishing persistence using Bash.
Creating a new user in Bash
One basic technique is to create a new user account with root privileges. See the following example for the commands to add a new user with root privileges:
$ sudo useradd -m -s /bin/bash bashdoor $ sudo usermod -aG sudo bashdoor $ echo "bashdoor:password123" | sudo chpasswd
These commands create a new user named bashdoor, add them to the sudo group, and set their password to password123. The new user will have full root access.
Let’s take a closer look at how this works:
useradd: Creates the new user account-m: Creates a home directory-s: Sets the login shell tobashusermod -aG:...