1

【alert(1) to win】 Level 07 - Skandia

 2 years ago
source link: https://exp-blog.com/safe/ctf/alert/level-07-skandia/
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 07



javascript
function escape(s) {
  return '<script>console.log("' + s.toUpperCase() + '")</script>';
}

这题用 toUpperCase 把输入字符全部转换成大写了。

JS 标签对大小写是不敏感的,但是 JS 函数则是大小写敏感,这样会导致 alert() 函数失效。

其实这种题型有通解:利用 <svg> 标签构做实体编码解析进行绕过。

在网页编码中,以 ASCII; 称为实体编码,其中 ASCII 可以用十进制或十六进制表示。如 ( 的 ASCII 编码为 40 (或十六进制 0x28) ,那么 (( 就是 ( 的实体编码。

其工作原理为:

  • toUpperCase 对实体编码本身的字符(如 a)进行大写转换,但是实体编码字符本身并没有对应的大写字符,因此不会起作用
  • <svg> 再把实体编码解析为对应的 ASCII 字符

因此这题可构造这样的 payload :

javascript
");</script><svg><img src=0 onerror=alert(1); />
01.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK