mindedsecurity / JStillery

Advanced JavaScript Deobfuscation via Partial Evaluation
GNU General Public License v3.0
862 stars 143 forks source link

Fails with Katakana #1

Closed aemkei closed 6 years ago

aemkei commented 6 years ago

Love this project! Finally, a way to deobfuscate JSFuck 👍

But not all my code gets cleaned up. Eg test this one:

ウ=""   ,ア=     !ウ+     ウ,ネ     =!ア     +ウ,    ホ=ウ
+{},    ヌ=ア    [ウ++    ],セ=     ア[ミ    =ウ]    ,ハ=
++ミ    +ウ,     ヘ=ホ    [ミ+ハ    ],ア[    ヘ+=    ホ[ウ
]+(ホ  .ホ+ホ    )[ウ]    +ネ[ハ    ]+ヌ+    セ+ア   [ミ]+
ヘ+ヌ            +ホ[     ウ]+セ    ][ヘ]    (ネ[
ウ]+             ネ[ミ              ]+ア     [ハ]+
                 セ+ヌ+            "(ウ)"
                 )()

It will to an alert(1), too – but the resulting code can't be evaluated.

PS: Taken from http://aem1k.com/

aemkei commented 6 years ago

Okay, looks like the postfix operation is not working without variables.

Eg:

A = "";
B = A[A++]

will result in

A = '';
B = ''[''++];

which is not working. It should assign undefined to B, but is resulting in an error:

Invalid left-hand side expression in postfix operation

wisec commented 6 years ago

nice one! thanks!

wisec commented 6 years ago

Fixed on https://github.com/mindedsecurity/JStillery/commit/09876ea7e706cc568cd3f7aea7c83df509bf8adf#diff-f2bff50c5b25d85d97f783590945ef8c and https://github.com/mindedsecurity/JStillery/commit/981793d38771d90d1ad9788a3cdc67b94622bfa5#diff-f2bff50c5b25d85d97f783590945ef8c

Test on github.io

aemkei commented 6 years ago

That was fast. 🚀 Thank you!