# Knife

## Gaining Access

Nmap scan:

<figure><img src="/files/6GO9FBamcycfg2SRSrRE" alt=""><figcaption></figcaption></figure>

### PHP-Dev

I found nothing interesting about the web application hosted on port 80. However, when viewing the traffic proxied through Burpsuite, we see an interesting header:

<figure><img src="/files/opcyPsUajl7OCBI7RO5g" alt=""><figcaption></figcaption></figure>

PHP/8.1.0-dev is vulnerable to a publicly available RCE exploit.

{% embed url="<https://www.exploit-db.com/exploits/49933>" %}

This script can be used to gain a shell as the user.

<figure><img src="/files/F8eiqkIslJbLycfUuIwv" alt=""><figcaption></figcaption></figure>

From this, we can get a shell using the `mkfifo` script. After spawning a TTY shell, we find that we are the user `james`.

## Privilege Escalation

### Knife Sudo

When enumerating sudo privileges, we see that we can run `knife`.

<figure><img src="/files/pLYv4oyyf3xWhP8o2U54" alt=""><figcaption></figcaption></figure>

`knife` can be used to spawn a root shell since we can run `sudo` with it.

<figure><img src="/files/J60FOIbaaJeyYtTtecHj" 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://rouvin.gitbook.io/ibreakstuff/writeups/hackthebox/easy/knife.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.
