> 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/business-logic/logical-flaw-allowing-you-to-generate-infinite-money.md).

# 允许你生成无限金钱的逻辑缺陷

允许你生成无限金钱的逻辑缺陷，PortSwigger Web Security Academy 实验笔记，包括利用流程、载荷测试、Burp Suite 验证以及修复上下文。

### 无限金钱逻辑漏洞

**实验描述**

该实验包含购买流程中的一个逻辑缺陷。通过利用 \*\*礼品卡\*\*、\*\*促销优惠券\*\* 与 **订单确认**，可以无限生成积分，然后购买 Lightweight l33t 皮夹克。

提供的标识符：

* **用户**: wiener
* **密码**: peter

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d6266562de36e2204ea2a273ddcc86d4cde9b77a%2F%7BB513ED00-D597-4B79-A334-DA892468C359%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 故障原理

注册订阅新闻邮件后，会获得一张促销优惠券：

* **优惠券** : `SIGNUP30`

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-cec3ae61aa8aa88dfce9fdb38e896f416bcb2d8d%2F%7BD56D3280-BB4D-43F8-8847-6272878AAA4B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4facaaf5bc9fb5535fa62262eaefe8e69dbaa337%2F%7BAD53D7B2-725A-4FFC-95FD-DFA14AF52FE4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

在商店中可以购买 \*\*礼品卡\*\*。

问题在于，购买这些卡片时可以应用该优惠券。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-638bd9d523a18f5fbc134ee4c3e1881a831a5357%2F%7BA5CC399E-BDD2-43A3-AC1A-7FF29C413D6D%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 初始利用示例

* 购买一张面值为 **$10**
* 优惠券应用 `SIGNUP30`
* 最终支付价格： **$7**

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2b0c49ff4d33bdf84258dd94c311db53c0605d76%2F%7B218DFB98-4FA8-49E4-870E-3E1BD7F2B23A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* 收到一份 **礼品卡代码** （例如： `DbWseYFi2v`)

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bf544400cbdd52f0edd21528a147adf250381bd9%2F%7B05028327-3014-4261-AC5C-87AE4946C996%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-15228b23eb9e8d5f47d4f9499c64b44caf503f82%2F%7B2922EBC9-E4DA-4AFA-BF5C-77AFE41E241B%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

当在礼品卡部分使用该代码时，账户余额会增加 **10$** 而仅花费 **7$** 。

因此净收益为 **$3**，将总余额增加到 **$103**.

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5cfa35b4bf87c872cc9d6bb96abafaa4fb2c80cd%2F%7B5F7BEF80-054D-4C94-8965-2D2DDB5EB7D4%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 已识别的逻辑问题

1. 该优惠券可以被使用 **多次** 来购买礼品卡。
2. 礼品卡的余额 **仍按全额计入**，无论实际支付价格是多少。
3. 通过以下端点进行订单确认：

   ```bash
   /cart/order-confirmation?order-confirmed=true
   ```

可以动态获取礼品卡代码。

没有任何限制阻止对此过程进行自动化。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-55e2eabaee74030c602861c50f46a4dd23222418%2F%7B9C7CB844-596C-4813-8814-5CD251A30BE7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 攻击自动化（宏）

为了利用这一大规模漏洞，使用了一个 **Burp Suite 宏** 已实现。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-27e5c0020d46100245515c8757fda9e0d537b793%2F%7BC0FB1618-3BD6-4892-8DD0-09C160A6911E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 宏中拦截的请求

1. 添加一个商品 **礼品卡** 到购物篮中
2. 应用新闻邮件优惠券（`SIGNUP30`)
3. 订单校验（`提交订单`)
4. 获取订单确认响应
5. 将礼品卡注册到用户账户

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0c7ded1307665efdedff408fffc7c0c44263d3e5%2F%7BA0690E08-23D1-409E-85CF-82E673868463%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### 宏的关键要点

* 该 **礼品卡代码** 会动态提取自 `cart/order-confirmation` 响应。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-322587d183fd337eacf0b571ecefa119f9f85dde%2F%7B509B7CC2-BE19-44A3-9990-84933C1553E9%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

* 然后通过向礼品卡管理端点发送 POST 请求重新注入该代码。
* 自定义 **参数** 在 GET 查询中设置，用于存储代码值。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9bca90655a458d0f44ef9b653d82e1eea128ff43%2F%7B147C5FCB-AA53-4DDF-8B09-ADE105FABEF6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

应用的优惠券会从先前的查询中恢复其值，从而可自动重复使用。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9c9764756e9d9cfb63a9a9054dad2bc4e8068a43%2F%7B0B3C9369-8100-4A35-AF59-3DB19D928851%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### 批量执行

一旦宏配置完成：

所有针对 **URL 范围** 都会自动触发宏。

* 一个 **Intruder** 查询会发送到网站根路径。
* 配置：
* **500 个请求**
* **负载为空**

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6faa199c2f98a292c939ce81df7669a9096245f4%2F%7BFB2280E9-9ABE-4875-93B2-CBD08DCB4B7B%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**资源池** 限制为 **1 个并发请求**

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8c20676ac7b015e7dae383d1e5a649146196c9f0%2F%7B7B673C75-A05B-4061-8C29-80E55C2DBF87%7D.png?alt=media" alt="" width="364"><figcaption></figcaption></figure>

这种方法使得可以不间断地串联礼品卡的购买、确认和入账。

#### 结果

账户余额无限增长。 / 一旦积累了足够的余额，购买 **Lightweight l33t 皮夹克** 便可不受资金限制地实现。

<figure><img src="https://1574813340-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e6e2cd1996c83495734638cd08179a54e2a5cbf5%2F%7B9EBF5FDD-31DC-41F4-9B62-DC0272D14FDD%7D.png?alt=media" alt="" width="375"><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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/zh/web/business-logic/logical-flaw-allowing-you-to-generate-infinite-money.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
