Linux Hackers Become Root with CURL & Sudo
3 min read
7 months ago
Published on Jun 05, 2024
This response is partially generated with the help of AI. It may contain inaccuracies.
Table of Contents
Step-by-Step Tutorial: Becoming Root with CURL & Sudo
-
Introduction to the Challenge:
- The challenge is about privilege escalation using CURL and Sudo.
- The task involves running a program in the root user's home directory via an SSH connection.
-
SSH Connection Setup:
- SSH into the local host using the provided credentials: username -
user
, password -userpass
. - Check the contents of the directory using the
ls
command.
- SSH into the local host using the provided credentials: username -
-
Identifying Privilege Escalation Opportunities:
- Use
sudo -l
to list commands that can be run as the root user. - Note the ability to run commands as the user 'fry' without a password.
- Use
-
Setting up an HTTP Server:
- Run a Python 3 HTTP server on Port 8000 using the command
python3 -m http.server 8000
. - Access the server on Port 8000 to ensure it is running correctly.
- Run a Python 3 HTTP server on Port 8000 using the command
-
Creating a Symbolic Link:
- Create a symbolic link named
healthcheck
pointing to thefry.bash_history
file usingln -s /home/fry/.bash_history healthcheck
. - Access the symbolic link on Port 8000 to view the contents of
fry.bash_history
.
- Create a symbolic link named
-
Exploiting Arbitrary Read and Write:
- Utilize CURL with the asterisk (*) wildcard to read and write files.
- Retrieve the contents of
fry.bash_history
using CURL. - Create a new file in the temporary directory using CURL.
-
Generating SSH Keys:
- Generate a public/private key pair using
ssh-keygen
. - Move the public key (
id_rsa.pub
) to the HTTP server directory.
- Generate a public/private key pair using
-
Adding SSH Key to Authorized Keys:
- Access the
authorized_keys
file in the~/.ssh
directory. - Append the contents of the public key to the
authorized_keys
file.
- Access the
-
SSH Access as Root User:
- SSH into the host as the 'fry' user and check if the SSH key authentication works.
- If successful, SSH into the host as the 'root' user using the same key pair.
-
Accessing the Flag:
- Navigate to the home directory of the 'root' user.
- Execute the
get_flag_random_suffix
binary within 1 second to retrieve the flag.
-
Conclusion:
- Reflect on the process of privilege escalation using CURL and Sudo.
- Acknowledge the importance of securing Sudo permissions to prevent unauthorized access.
-
Acknowledgments:
- Appreciate the resources and training provided by Black Hills Information Security and John Strand.
This step-by-step guide outlines the process of escalating privileges and gaining root access using CURL and Sudo as demonstrated in the video "Linux Hackers Become Root with CURL & Sudo" by John Hammond.