JavaScript Obfuscation/Deobfuscation
Last updated
Last updated
Obfuscation is a technique used to make a script more difficult to read by humans but allows it to function the same from a technical point of view, though performance may be slower. This is usually achieved automatically by using an obfuscation tool, which takes code as an input, and attempts to re-write the code in a way that is much more difficult to read, depending on its design.
Code Minification involves compressing the code into a single, often lengthy line. This greatly reduces its readability by humans while maintaining its functionality from a technical perspective.
Online Resources for JavaScript Minifiers:
A packer
obfuscation tool usually attempts to convert all words and symbols of the code into a list or a dictionary and then refer to them using the (p,a,c,k,e,d)
function to re-build the original code during execution. The (p,a,c,k,e,d)
can be different from one packer to another. However, it usually contains a certain order in which the words and symbols of the original code were packed to know how to order them during execution.
While a packer does a great job reducing the code's readability, we can still see its main strings written in cleartext, which may reveal some of its functionality. This is why we may want to look for better ways to obfuscate our code.
Online Javascript Obfuscator makes javascript code harder to read or understand.
Completely obfuscate the code and hide any remnants of its original functionality.
Just as there are tools to obfuscate code automatically, there are tools to beautify and deobfuscate the code automatically.
Browser tool, CTRL+ALT+I and then click on the '{}' button on the Debugger tab which will Pretty Print the script into its propoer JavaScript formatting
Online resources like Prettier or Beautifiier
Refer to the page Encoding/decoding