Saturday, 22 September 2018

Decrypt the encrypted JavaScript in Blogger Theme

Many people use Blogger - particularly Blogger themes which have encrypted JavaScript inside- asks how to remove that. So, read this complete post to know how to remove/unpack the JavaScript in those themes.


Why the encrypted JavaScript?

Encrypted JavaScript is used to encrypt some lines of the JavaScript code on the webpage including the JavaScript code which is used for keeping the credit of the theme. So if you have purchased their theme then there is no problem. But if you removed the script directly then your theme starts to misbehave(some sections of the theme not appears).

In this post, I'll not tell you how to remove that credit removing script but will tell you how to unpack/decrypt those scripts.

Types Of Scripts

There are typically 2 types of scripts found in the Blogger templates that are either encrypted or packed into a function. If you can't see any direct executable JavaScript code. If you want to modify any code, it becomes much difficult. I've come up with 2 tools to help you to decrypt or unpack those script.
But first, we need to have a look at those scripts so that you can distinguish them and use the tool.

1.Packed Scripts

You must have seen the following type of scripts in the Blogger template.
eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(0(){4 1="5 6 7 8";0 2(3){9(3)}2(1)})();',10,10,'function|b|something|a|var|some|sample|packed|code|alert'.split('|'),0,{}))
They say function(p,a,c,k,e,d)... and so on at startings.
Steps to unpack this type of packed javascript are-

  1. Copy the whole function starting from eval() to the end of the code.
  2. Go to Javascript unpacker and paste that code into the box and click 'unpack'.
  3. After successfully unpacked, Copy the code in Output and replace that with the main code.
Note: You may take a backup of the theme before replacing the code as if you got mixed up, then you can restore it back.

2.Encrypted Scripts

Encrypted scripts look something lime below and are defined as the object in a variable.
var _0x760d=["\x64\x69\x73\x70\x6C\x61\x79","\x69\x6E\x6C\x69\x6E\x65\x2D\x62\x6C\x6F\x63\x6B","\x63\x73\x73","\x23\x6D\x73\x63\x6F\x6E\x74\x65\x6E\x74","\x43\x72\x65\x61\x74\x65\x64\x20\x62\x79\x20\x3C\x61\x20\x68\x72\x65\x66\x3D\x22\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x6D\x73\x64\x65\x73\x69\x67\x6E\x62\x64\x2E\x63\x6F\x6D\x22\x3E\x4D\x53\x20\x44\x65\x73\x69\x67\x6E\x3C\x2F\x61\x3E","\x68\x74\x6D\x6C","\x6C\x65\x6E\x67\x74\x68","\x23\x6D\x73\x63\x6F\x6E\x74\x65\x6E\x74\x3A\x76\x69\x73\x69\x62\x6C\x65","\x68\x72\x65\x66","\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x6D\x73\x64\x65\x73\x69\x67\x6E\x62\x64\x2E\x63\x6F\x6D","\x72\x65\x61\x64\x79"];
Steps for decrypting this type of the text is below. Sometimes this encrypted Javascript is inside the function(p,a,c,k,e,d). That means we need to unpack the scripts to decrypt this type of scripts.
  1. Copy the code between '=' and ';' {equal to and semicolon}.
  2. Paste it into the first textbox in JS decrypter.
  3. Click on decrypt.
  4. After successfully decryption, Copy the code in Output and replace that with the main code.
After decrypting, the above code will look something like below-
display,inline-block,css,#mscontent,Created by <a href="http://www.msdesignbd.com">MS Design</a>,html,length,#mscontent:visible,href,location,http://www.msdesignbd.com,ready

JavaScript decrypter webtool
Screenshot of the script decrypted in JS decrypter.

Tools Used

The tools used above are:-

  1. Javascript Unpacker (to unpack the JavaScript)
  2. Javascript Decrypter (to decrypt the encrypted JavaScript)

Demonstration

Here I've taken a free Blogger theme and going to unpack all the encrypted scripts in it.
First I'm going to search for the encrypted script. That's not there anywhere in the document so I searched for eval.
eval(packed)
After selecting and copying that code, unpack that(see the picture below.).
JS Unpacker
Okay so you can see the unpacked function of remove HTML tag which was encrypted.So if you had removed the script directly, the theme would have misbehaved.Now when I scroll down, you can see the encrypted script there.Its noting but the simple text when decrypted.(Click on Images to open).
JavaScript variable
Copy this and paste into JS Decrypter.
JS decrypter for blogger
Finally, replace the decrypted text and Unpacked text with the original once!

Conclusion

This is how you can decrypt those scripts. If you want to decrypt those scripts to remove the footer credit(I've already made a post on how to hide them!), you're free to!
This post may go a little advanced for some:/
Thanks for reading this, if found it helpful - tell me in the comment section below.

3 comments:

  1. Thank you for the useful information in this post! I found it to be very helpful, and I have saved the post for the future, and will share with friends who need help :)

    ReplyDelete
  2. how you got adsense approval in .blogspot.com domain??? its not possible.. i tried so much time but failed

    ReplyDelete

Comment something useful and creative :)