思考めも
そもそもどこから手を付けて良いか分からない。。。
冷静に見ると
({"aaaaa" : function() {
/*内側の処理*/
}})[ "bbbbb"["ccccc"]() ]();
という形なので、
「"aaaaa" == "bbbbb"["ccccc"]」でないと内側の処理が実行されない。
これを実現できるのは選択肢の中からだと
「"function" == "Function"["toLowerCase"]」
となる。
続いて内側の最初
(new Function( "ddddd" + "eeeee" + "fffff" ))();
Functionの中の文字列がJavaScriptとして実行されるわけだけれど、
+で繋いでしまうと意味がない文字列にしかならない。
選択肢を見ると顔文字のような「/*^_^*/」がコメントとして使える。
そのため、
(new Function( "return" + "/*^_^*/" + "fffff" ))();
まで確定。3つめを保留して先へ。。。
そもそもの最終目標が「alert(1)」なので、試しに実験。
({"function" :function() {
this["hhhhh"] = (new Function("return" + "/*^_^*/" + "alert"))();
try {
this["hhhhh"](1);
} catch (e) {
console.log(e);
}
}})["Function"["toLowerCase"]() ]();
"Illegal invocation"なるエラーになる。
「ネイティブ関数の別名を作っちゃダメ!」エラーらしい。
ここで処理をデバッガで追いながら、
ふと「new Function」の時のthisがwindowオブジェクトである事に気付く。
({"function" :function() {
this["hhhhh"] = (new Function("return" + "/*^_^*/" + "this"))();
try {
this["hhhhh"]["alert"](1);
} catch (e) {
console.log(e);
}
}})["Function"["toLowerCase"]() ]();
alert(1)成功!
これで、
var pattern = "iiiii";
var r = new RegExp( pattern );
を前提として、
「r[ "ggggg" ]( pattern ) == "hhhhh"」
を実現できる組み合わせを考える事に。
変数rはRegExpオブジェクトなので、
「r[ "ggggg" ]( pattern )」
がまともに動く選択肢そのものが少ない。
「"exec"」と「"constructor"」の二択。
多分「"exec"」
選択肢の残りを片っ端から"iiiii"に入れる。
すると、"^[w]$"の場合だけnullになる。
で。完成。