HObfus vs Hacker
<< Prev
[ Level: 5 ]
Next >>
[1] HObfus
document.write(str);
HObfus が document.write でstrを書き出す。
[2] Hacker
document.write=(str)=>{console.log(str);}
Hacker が、override した document.write で str を盗む。
[3] HObfus
if(!$_isnative("write",document.write)){return false;}
HObfus は、document.write が native であるかチェックする。この際、document.write.toString()を使う。
[4] Hacker
document.write.toString=()=>{return "function write() { [native code] }";};
Hacker が、document.write.toString を override して、
document.write が nativeのように見せる。
[5] HObfus
if(document.write.hasOwnProperty('toString')){return false;}
HObfusは、document.write が 独自の toString をもっているかチェックする。
元々、document.write は 独自の toString を持っていないので、持っているとすれば
それは、Hacker が設置したものであることがわかる。
[6] Hacker
document.write.__proto__.toString=()=>{return "function write() { [native code] }";};
Hacker が、document.write.__proto__.toString を override して、
document.write が native のように見せる。
(この[6]を実行するには、[4]を disable しておく必要がある)
[7] HObfus
if(!$_isnative("toString",document.write.__proto__.toString)){return false;}
HObfusは、document.write.__proto__.toString が native かどうか調べる。
[8] Hacker
document.write.toString.toString=()=>{return "function toString() { [native code] }";};
Hacker が、document.write.toString.toString を override して、
document.write.toString が native のように見せる。
[9] HObfus
if(document.write.toString.hasOwnProperty('toString')){return false;}
HObfusは、document.write.toString が 独自の toString をもっているかチェックする。
元々、document.write.toString は 独自の toString を持っていないので、持っているとすれば
それは、Hacker が設置したものであることがわかる。
[10] Hacker
document.write.toString.toString.toString=()=>{return "function toString() { [native code] }";};
Hacker が、document.write.toString.toString.toString を override して、
document.write.toString.toString が native のように見せるが、もはや通用しない。
これ以上、Hackerができることはなく、HObfusの勝ちになる。
結論として、HObfusは以下の4つを確認しなければいけない。
a) document.write が native であること。
b) document.write.hasOwnProperty('toString') が false であること。
c) document.write.__proto__.toString が native であること。
(別の表現では、Function.prototype.toString が native であること)
d) document.write.toString.hasOwnProperty('toString') が false であること。