> For the complete documentation index, see [llms.txt](https://viperone.gitbook.io/pentest-everything/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://viperone.gitbook.io/pentest-everything/writeups/to-do/escape.md).

# Escape (WIP)

## Nmap

```
sudo nmap 192.168.233.113 -p- -sS -sV

PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp   open  http    Apache httpd 2.4.29 ((Ubuntu))
8080/tcp open  http    Apache httpd 2.4.38 ((Debian))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```

![](/files/-MWjxYwgmzsxNJ_yJXbc)

The directory page /dev/index.php allows for GIF uploads. Attempting to upload a different file type will be rejected.

![](/files/-MWk65EH2O55zmbODfmn)

This can be bypassed by first upload a legitimate GIF file. I used a small GIF such as the following[: https://giphy.com/gifs/obi-won-hvE0PhVAnGQAo](https://giphy.com/gifs/obi-won-hvE0PhVAnGQAo).

Upload the file and capture the request with Burpsuite. The request when attempting upload should look something similar to the image below:

![](/files/-MWk6jLxSNnBoaOQQmur)

We now need to send the request to repeater so we can edit it and inject a PHP reverse shell. In the request below I have ensured the filename ends in '.php' and the first line of the original request has been kept in as these are magic bytes which are used to identify what type of file is being upload. As far as the server is concerned because the line starting with: `GIF89aÈ*` exists in the request then the file must be a GIF.

Ensure the following is still set: `Content-Type: image/gif` Then under the magic byte sequence we can inject a PHP Reverse shell.

![](/files/-MWk6x1CsqmOuq2fCxZP)

Once completed send the request on and check to see if uploaded.

![](/files/-MWk7l9qJjx8l75I3UgJ)

Once uploaded start a netcat listener and browse to the following:<http://192.168.233.113:8080/dev/uploads/shell.php>.

A shell should be received as www-data.

![](/files/-MWk836eZN9UGpMhMqjy)


---

# 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 dynamically by asking a question.

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

```
GET https://viperone.gitbook.io/pentest-everything/writeups/to-do/escape.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
