HackThis javascipt
- attempts 1
日常看代码
1 | <script type='text/javascript'> $(function(){ $('.level-form').submit(function(e){ e.preventDefault(); if(document.getElementById('pass').value == correct) { document.location = '?pass=' + correct; } else { alert('Incorrect password') } })})</script> |
然后去搜索correct变量是啥
1 | <script type='text/javascript'> var correct = 'jrules' </script> |
- attempts 2
继续欢乐翻代码
1 | <script type='text/javascript'> |
1 | <script type='text/javascript'> $(function(){ $('.level-form').submit(function(e){ e.preventDefault(); if ($('.level-form #pass')[0].value.length == length) { document.location = "2?x=" + length; } else { alert('Incorrect Password'); } }); }); </script> |
注意这个
1 | if ($('.level-form #pass')[0].value.length == length) |
只要密码的长度等于length就ok了,所以我们按着上面算下length是多少就ok了,如果懒的话也可以改改js代码然后直接把length alert出来
- attempts 3
看到这里
1 | <script type='text/javascript'> var thecode = 'code123'; $(function(){ $('.level-form').submit(function(e){ e.preventDefault(); if ($('.level-form #pass')[0].value == thecode) { document.location = "?pass=" + thecode; } else { alert('Incorrect Password'); } }); }); </script> |
以为密码就是code123,可是居然不对…找了很久也没看到有其他的地方修改了thecode变量,于是直接改代码alert出thecode就ok了
- attempt 4
在网页源代码中没有找到任何信息,结合hint所说可以猜到是要找到另一个页面,试图用google去找没有找到,这时注意到url里带了个?input,发现访问
会自动带上input参数变成
因此应该是做了一个重定向,用firefox的网络工具的编辑和重发功能去掉input参数,直接查看
的响应,可以在源代码中找到密码
- attempt 5
首先是要看到网页的源代码,这个不难只要
view-source:https://www.hackthis.co.uk/levels/javascript/5
就可以看到,但是一开始并没有找到什么有价值的东西,仔细查看网页包含的其他js代码可以发现
view-source:https://www.hackthis.co.uk/files/js/min/extra_48d468a93b.js?1510507123
就是我们要找的
1 | a=window.location.host+""; |
这里有个要注意的地方就是我们自己执行这段代码时要把a的值换成www.hackthis.co.uk,我一开始没注意这个折腾了好久…