Recently I came across an interesting website that illustrates a Javascript Obfuscator: http://bl.ocks.org/jasonsperske/5400283
For example, (([]===[])+/-/)[1]
gives a
and (1+{})[(1<<1)+1]
gives b
.
I have tried hard to understand the evaluation sequence of these obfuscated result but was in vain.
Taking (1+{})[(1<<1)+1]
as an example, I understand that <<
is the bitwise shift operator and will return 2, so the expression becomes (1+{})[3]
. But then I cannot understand what does it mean by 1+{}
and [3]
.
Google isn't really helpful to this problem as search engines don't like the brackets or slashes very much, so in case there are duplicate questions I'm sorry about that.
Description. This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.
The >>> operator is identical to the >> operator, except that the bits that fill in the shifted left bits have the value of 0. The >>> operator is said to be an unsigned shift because it does not preserve the sign of the operand.
The logical and ( && ) and or ( || ) are logical operators in JavaScript. Normally, you're using these operators on booleans: true && true // => true. true && false // => false.
The left-shift operator causes the bits in shift-expression to be shifted to the left by the number of positions specified by additive-expression . The bit positions that have been vacated by the shift operation are zero-filled.
It's just obfuscation tricks.
for example :
[]===[]
===> false
and
([]===[])+/-/
===> "false/-/"
( You could test it in the console by yourself)
So what is (([]===[])+/-/)[1]
? ( second char)
That's right :'a'
You may want to look at this also :
You could go step by step:
(([]===[]))
is simply false
. Converted into a string "false/-/"
and indexed by [1]
gives you the a
of the string "false".
The same goes for (1+{})
which results in the string "1[object Object]"
.
And 1<<1+1 is another way of writing 3
so this results in "1[object Object]"[3]
, which is simply b
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With