+ 58
[ASSIGNMENT] ๐ WHY THIS WORKS ๐
I've created a simple JS obfuscation. The challenge is to explain why this code works. Let's see if anyone can decode my obfuscation ๐. https://code.sololearn.com/WsNVWfgW9egp/?ref=app
26 Answers
+ 31
@Swapnil โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโSrivastava
A little reverse engineering gets me this.
document.body.innerHTML='hellothis is magic<br>i\'m c++'
Utilizing a few invisible unicode characters as your string in the p tag;
\u200d zero width joiner 8205
\u200b zero width space 8203
\u0020 space 32
Then splitting by \u200d
and joining by '0' or \u0030
and splitting by \u200b
and joining by '1' or \u0031
then splitting that result by " " you end up with the following binary string array;
['1100100', '1101111', '1100011', '1110101', '1101101', '1100101', '1101110', '1110100', '101110', '1100010', '1101111', '1100100', '1111001', '101110', '1101001', '1101110', '1101110', '1100101', '1110010', '1001000', '1010100', '1001101', '1001100', '111101', '100111', '1101000', '1100101', '1101100', '1101100', '1101111', '1110100', '1101000', '1101001', '1110011', '100000', '1101001', '1110011', '100000', '1101101', '1100001', '1100111', '1101001', '1100011', '111100', '1100010', '1110010', '111110', '1101001', '1011100', '100111', '1101101', '100000', '1100011', '101011', '101011', '100111']
Which is then converted into decimal values, which in turn are used to get the characters, that when joined together form the final above value.
Nice trick.
Here's the code in Python with the invisible characters converted to their unicode representations. Written in a non-complex way for a little easier understanding.
https://code.sololearn.com/c4fPl64MPe1a
+ 32
a great one, but i am out for any explanations ๐๐
+ 32
๐ https://ibb.co/dgxKMS ๐
//see the image ๐จ
1)no role of js section and css section
//U can remove them
2)why line 7 is so long ... its coming to next line
/*U have used invisible unicode characters there , to hide "i'm c++ , magic" ... whatever*/
when U'll try backspacing in that line , U'll notice that while backspacing ... sometimes spaces come ...that accounts for the space between those words U r displaying in the output & more things U have written there 'include' ...
//Swapnil , make some lessons on unicode,SL'll give U special badge for that
+ 30
@swapnil he is always doing weird stuff..โ๏ธ๐๐
accept my challenges & tell me if u r free 2 accept until limit
+ 23
@Kim San I Thanks.
+ 22
@Saksham Saxena if you are talking about making a android app with JavaScript then see this :
https://code.sololearn.com/WZcEbcTeHPf3/?ref=app
and if you are taking about c++ then I dont know. The code above is not actually c++. Actually, the c++ code there does nothing. It is just to confuse. Everything there is just done by JavaScript.
+ 21
@Tim Thuma let me tell you <script type="c++"> does nothing.๐
+ 20
@Jay I know I've used split() and join() a lot. But, still it is not the answer to the challenge.
+ 20
HINT : what's that <p> tag doing there ?
+ 16
It's these two lines' fold:
`#include`</script>`
`#include <script type="c++">`
I think first line declares a script and the second one tells us that we're gonna use c++.
I guess that's all?
+ 14
nice code๐๐
+ 11
wow ๐ฎ
+ 10
it's don't work to me ๐
+ 10
This code is JavaScript,you can remove the c++ and write anything there,the magic is in the html script tag with the constructor.To be honest you'll have to explain this yourself๐
+ 9
this logic is simpler than it looks swapnil has just evily added so many logic to throw us off track!!๐
+ 5
do you know what is biggest obfuscation? this line =>
<!-- THE REAL CODE IS IN JS TAB -->
+ 3
nice...... magic... with p taggg
+ 3
but.. can u explain how u do it... how it is hidden...
0
I don't know if you've changed the code, but actually it is not working on my code playground...