# Course #662: Unix Privilege Escalation Check with unix-privesc-check$

## Section 1: Introduction to unix-privesc-check$

Privilege escalation is a critical aspect of penetration testing and ethical hacking. It involves exploiting vulnerabilities in a system to gain elevated access to resources that are usually protected from unprivileged users. The `unix-privesc-check$` tool is designed to assist penetration testers in identifying potential privilege escalation paths on Unix-like operating systems. This section will guide you through the installation, configuration, and effective usage of `unix-privesc-check$` on Kali Linux.

### 1.1 Installation of unix-privesc-check$

Before diving into the usage of the `unix-privesc-check$` tool, let's first walk through the installation process on Kali Linux.

#### Step 1: Update Your Kali Linux

Before installing any new tool, it's always good to ensure your system is up-to-date. Open your terminal and run the following command to update the package list and upgrade any outdated packages:

"`bash
sudo apt update && sudo apt upgrade -y
"`

#### Step 2: Install Dependencies

The `unix-privesc-check$` tool may require some dependencies. Install them using the following command:

"`bash
sudo apt install git -y
"`

#### Step 3: Clone the Repository

The `unix-privesc-check$` tool is hosted on GitHub. You can clone the repository directly to your local machine using:

"`bash
git clone https://github.com/UltimateHackers/unix-privesc-check.git
"`

#### Step 4: Navigate to the Directory

Once cloned, navigate into the directory where the tool resides:

"`bash
cd unix-privesc-check
"`

#### Step 5: Make the Script Executable

Before running the script, you must ensure that it is executable. Run the following command:

"`bash
chmod +x unix-privesc-check.sh
"`

### 1.2 Configuration of unix-privesc-check$

The configuration of `unix-privesc-check$` is minimal, as the script is designed to run out of the box. However, you can customize it by editing the script file if necessary. Open the script in a text editor of your choice:

"`bash
nano unix-privesc-check.sh
"`

In this file, you may find various internal parameters and settings, such as environmental variables that can be adjusted to fine-tune the checks performed by the tool.

### 1.3 Step-by-Step Usage

Now that we have installed and configured `unix-privesc-check$`, let’s explore how to use it effectively.

#### Step 1: Initial Execution

To run the tool, simply execute the following command in the terminal:

"`bash
./unix-privesc-check.sh
"`

The tool will automatically start scanning the local system for potential privilege escalation vectors. You should see output similar to the following:

"`
[+] Checking for writable directories…
[+] Checking for SUID binaries…
[+] Checking for world-writable files…
[+] Checking for cron jobs…

"`

#### Step 2: Analyzing Output

The output will present various checks performed by the tool. Here are some key items to pay attention to:

– **Writable Directories**: If the script finds directories with write permissions for non-root users, this could be a potential vector for privilege escalation.
– **SUID Binaries**: These are executables that run with the privileges of the file owner. If misconfigured, they can be exploited.
– **World-Writable Files**: Files with global write access can be manipulated to escalate privileges.
– **Cron Jobs**: Scheduled tasks that run as root can be manipulated if they are improperly configured.

#### Real-World Use Cases

1. **SUID Binary Exploitation**: If `unix-privesc-check$` identifies a vulnerable SUID binary, a pentester can attempt to execute it to gain elevated privileges.

2. **Modifying Cron Jobs**: If a cron job running as root is identified with the ability to change its execution, the attacker could modify the job to execute a malicious payload.

3. **Leveraging Writable Directories**: An attacker can place a malicious script in a writable directory that is executed by a scheduled task or service.

### 1.4 Detailed Technical Explanations

#### Understanding Privilege Escalation Vectors

– **Writable Directories**: The presence of writable directories can allow users to add files or scripts that could be executed with higher privileges based on how the system interacts with these files.

– **SUID and SGID Bits**: The SUID (Set User ID) and SGID (Set Group ID) bits are used in Unix-like systems to allow users to run an executable with the effective permissions of the file's owner or group. Misconfigured SUID programs can be exploited to gain root access.

– **World-Writable Files**: Files with permissions set to allow anyone to write can be exploited by placing malicious content that could be executed by a service running with higher privileges.

– **Cron Jobs**: These jobs can be scheduled to run scripts or commands at specified intervals. If an attacker can alter a script or job that is executed as root, they can gain elevated privileges.

#### References for Further Reading

– [Kali Tools: unix-privesc-check](https://www.kali.org/tools/unix-privesc-check/)
– [Understanding SUID and SGID](https://www.geeksforgeeks.org/suid-sgid-bit-linux/)
– [Privilege Escalation Techniques](https://www.tcpipguide.com/free/t_privilegeescalationtechniques.htm)

### 1.5 Code Examples

Here are some additional code snippets to enhance your understanding and usage of the tool:

#### Example of Modifying File Permissions

To change the permissions of a file to make it SUID:

"`bash
sudo chmod u+s /path/to/vulnerable/binary
"`

#### Example of Creating a Malicious Payload

If you have identified a writable directory and want to create a malicious script:

"`bash
echo -e '#!/bin/bashn/bin/bash' > /tmp/malicious.sh
chmod +x /tmp/malicious.sh
"`

#### Example of Scheduling a Cron Job

To schedule a malicious payload to run every minute as root:

"`bash
echo '* * * * * root /tmp/malicious.sh' | sudo tee -a /etc/crontab
"`

### Conclusion

In this section, we have covered the installation, configuration, and effective usage of the `unix-privesc-check$` tool on Kali Linux. By understanding how to utilize this powerful tool, ethical hackers and penetration testers can identify potential privilege escalation paths in Unix-like systems. Remember that responsible disclosure and ethical practices are paramount in all penetration testing scenarios.

Stay tuned for the next section of this course, where we will delve deeper into specific scenarios and advanced techniques in privilege escalation.

Made by pablo rotem / פבלו רותם

Pablo Guides