> 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/zh/web-vulnerabilities/graphql-attack/graphql-introspection-pentesting-web.md).

# GraphQL 内省

{% hint style="info" %}
**GraphQL 中的内省** 是一种机制，允许客户端获取 API 的 GraphQL 模式信息。这意味着客户端可以探索并发现 API 中存在的数据类型、字段以及关系，这对需要构建 GraphQL 客户端的开发者来说非常有用。然而，内省也可被攻击者用来获取 API 中存在的结构和数据的敏感信息，从而实施更复杂的攻击。
{% endhint %}

我们\*\*找到\*\*如下内容：

<figure><img src="/files/365abbcb9f146eef17fc3808b9a9c2326ba37005" alt=""><figcaption></figcaption></figure>

我们 **拦截** 使用 Burp Suite 拦截请求：

<figure><img src="/files/50b823bb4ee057be9632f9376fffb6213541d280" alt=""><figcaption></figcaption></figure>

在 URL 中，我们 **插入** 其中一个目录（在我的例子中，是 /graphql）：

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

一旦我们找到了该目录，我们 **将其赋予** 如下内容：

```bash
?query=fragment%20FullType%20on%20Type%20{+%20%20kind+%20%20name+%20%20description+%20%20fields%20{+%20%20%20%20name+%20%20%20%20description+%20%20%20%20args%20{+%20%20%20%20%20%20...InputValue+%20%20%20%20}+%20%20%20%20type%20{+%20%20%20%20%20%20...TypeRef+%20%20%20%20}+%20%20}+%20%20inputFields%20{+%20%20%20%20...InputValue+%20%20}+%20%20interfaces%20{+%20%20%20%20...TypeRef+%20%20}+%20%20enumValues%20{+%20%20%20%20name+%20%20%20%20description+%20%20}+%20%20possibleTypes%20{+%20%20%20%20...TypeRef+%20%20}+}++fragment%20InputValue%20on%20InputValue%20{+%20%20name+%20%20description+%20%20type%20{+%20%20%20%20...TypeRef+%20%20}+%20%20defaultValue+}++fragment%20TypeRef%20on%20Type%20{+%20%20kind+%20%20name+%20%20ofType%20{+%20%20%20%20kind+%20%20%20%20name+%20%20%20%20ofType%20{+%20%20%20%20%20%20kind+%20%20%20%20%20%20name+%20%20%20%20%20%20ofType%20{+%20%20%20%20%20%20%20%20kind+%20%20%20%20%20%20%20%20name+%20%20%20%20%20%20%20%20ofType%20{+%20%20%20%20%20%20%20%20%20%20kind+%20%20%20%20%20%20%20%20%20%20name+%20%20%20%20%20%20%20%20%20%20ofType%20{+%20%20%20%20%20%20%20%20%20%20%20%20kind+%20%20%20%20%20%20%20%20%20%20%20%20name+%20%20%20%20%20%20%20%20%20%20%20%20ofType%20{+%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind+%20%20%20%20%20%20%20%20%20%20%20%20%20%20name+%20%20%20%20%20%20%20%20%20%20%20%20%20%20ofType%20{+%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20kind+%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name+%20%20%20%20%20%20%20%20%20%20%20%20%20%20}+%20%20%20%20%20%20%20%20%20%20%20%20}+%20%20%20%20%20%20%20%20%20%20}+%20%20%20%20%20%20%20%20}+%20%20%20%20%20%20}+%20%20%20%20}+%20%20}+}++query%20IntrospectionQuery%20{+%20%20schema%20{+%20%20%20%20queryType%20{+%20%20%20%20%20%20name+%20%20%20%20}+%20%20%20%20mutationType%20{+%20%20%20%20%20%20name+%20%20%20%20}+%20%20%20%20types%20{+%20%20%20%20%20%20...FullType+%20%20%20%20}+%20%20%20%20directives%20{+%20%20%20%20%20%20name+%20%20%20%20%20%20description+%20%20%20%20%20%20locations+%20%20%20%20%20%20args%20{+%20%20%20%20%20%20%20%20...InputValue+%20%20%20%20%20%20}+%20%20%20%20}+%20%20}+}

```

我们很可能遇到 **这个错误**，要解决它，只需放两个 **下划线** 在变量前：

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

解决后，我们复制所有 **响应内容**:

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

我们将它们粘贴到网页中 [graphql-kit](https://graphql-kit.com/graphql-seeager/) 在内省部分：

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

现在，我们有一个 **图形视图** ，展示 GraphQL 的结构：

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

在 **query**，如我们所知这些字段，我们将它们插入请求中，服务器返回它们的值：

<figure><img src="/files/cc49dc220fa25c617dbf641873ef2ca6f969db27" 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/zh/web-vulnerabilities/graphql-attack/graphql-introspection-pentesting-web.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.
