Using sucrack to Brute Force the Root Password via su Command
In this step, we will learn how to use the sucrack
tool to brute force the root user's password through the su
command.
The su
command is used to switch to another user's identity on Linux systems. Except for the root user, other users need to provide the target user's password when using this command.
The tool we will use for brute forcing the su
command is sucrack
. sucrack
is a multi-threaded Linux tool designed to brute force local user passwords through the su
command.
Since the su
command requires user input from a TTY shell, a simple shell script cannot accomplish the brute force attack. sucrack
is written in C language and supports multi-threading, making the brute force process highly efficient.
You can check the official website of sucrack
for more information.
In a real-world scenario, the target machine may not have internet access, so you can install sucrack
using one of the following two methods:
- Download the
sucrack
source code and upload it to the target machine, then compile and run it.
- Download the
sucrack
source code, compile it locally, and then upload the compiled binary to the target machine.
In this lab, we have already installed sucrack
for you.
-
Before attempting the brute force attack, we will set up the lab environment:
Open a terminal and navigate to the project directory:
cd /home/labex/project
Run the script env_setup_1.sh
to set up the lab environment:
./env_setup_1.sh
This script switches us to the unprivileged www-data
user. Our goal is to obtain the root
user's password through brute force
.
We have a pre-prepared wordlist at /tmp/common-wordlists.txt
for demonstration purposes. You can also use your own wordlist.
-
The syntax for brute force attacking the su
command using sucrack
is:
sucrack -w <threads> [-u <username>] <wordlist>
The parameters are:
-w
: Specifies the number of threads
<wordlist>
: Specifies the wordlist file
-u
: Specifies the username to brute force. If you do not specify a username, sucrack
will brute force the root
user's password by default.
Let's try to brute force by running the following command:
sucrack -w 20 /tmp/common-wordlists.txt > ~/sucrack.log && reset
The output of the brute force attack is redirected to the sucrack.log
file.
Note: The reset
command is used to clear the terminal screen becase sometimes after using sucrack
, the terminal may display not properly.
-
This brute force attack may take some time. After some time, check the sucrack.log
file to confirm the password:
cat ~/sucrack.log
Expected output:
password is: really
-
Then, we can switch to the root user using:
su - root
Enter the password really
to switch to the root user.
really
-
Create a file named success_1.txt
in the /root
directory to confirm that you have successfully switched to the root user:
echo "Success_1" > /root/success_1.txt
You can check the /root/success_1.txt
file to confirm that you have successfully switched to the root user.
You have learned how to use sucrack
to brute force the root user's password!