Challenge
Math time!. The page hands you the checker source in a textarea; the password is a length, not a secret string.第三关 Math time!:页面直接把校验源码放在一个 textarea 里,密码是一段算出来的长度,不是一个固定字符串。
Solution
用带登录态的会话取关卡页:
$ curl -s -b 'HackThisSite=<mission-cookie>' \ 'https://www.hackthissite.org/missions/javascript/3/'页面里的 textarea 给出这段源码:
var foo = 5 + 6 * 7;var bar = foo % 8;var moo = bar * 2;var rar = moo / 3;function check(x) { if (x.length == moo) { alert("win!"); window.location += "?lvl_password=" + x; } else { alert("Fail D:"); }}foo = 5 + 6 * 7。乘法优先:,。bar = foo % 8。()。moo = bar * 2。。rar = moo / 3。。这一行算完就没被用过,是干扰项:校验里只引用了moo。
用 Node 运行一遍确认:
$ node -e 'var foo = 5 + 6 * 7, bar = foo % 8, moo = bar * 2, rar = moo / 3; console.log(foo, bar, moo, rar)'47 7 14 4.666666666666667校验条件是 x.length == moo,也就是 x.length == 14。
Verify
提交一个 14 字符的串:
$ curl -s -b 'HackThisSite=<mission-cookie>' \ -e 'https://www.hackthissite.org/missions/javascript/3/' \ 'https://www.hackthissite.org/missions/javascript/3/?lvl_password=aaaaaaaaaaaaaa'