Created
April 29, 2015 03:58
-
-
Save JavaScript-Packer/0ac9254197d10e6b9b33 to your computer and use it in GitHub Desktop.
Watch me do (step by step) a basic manual obfuscation of basic JavaScript source code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//using encoder online tools @ http://www.scriptcompress.com/30-encoders-in-1.htm | |
function hex(Δ){return Δ.replace(/./g,function(Δ){return'\\x'+Δ.charCodeAt(0).toString(16)})}; | |
alert(hex('ScripCompress.com')); | |
//lets bracket notation stuff | |
function hex(Δ){return Δ['replace'](/./g,function(Δ){return'\\x'+Δ['charCodeAt'](0)['toString'](16)})}; | |
alert(hex('ScripCompress.com')); | |
//lets encode stuff between brackets using hexidecimal/hex | |
function hex(Δ){return Δ['\x72\x65\x70\x6c\x61\x63\x65'](/./g,function(Δ){return'\\x'+Δ['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](0)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](16)})}; | |
alert(hex('\x53\x63\x72\x69\x70\x43\x6f\x6d\x70\x72\x65\x73\x73\x2e\x63\x6f\x6d')); | |
//lets encode variable and function names in unicode | |
function \u0068\u0065\u0078(\u0394){return \u0394['\x72\x65\x70\x6c\x61\x63\x65'](/./g,function(\u0394){return'\\x'+\u0394['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](0)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](16)})}; | |
\u0061\u006c\u0065\u0072\u0074(\u0068\u0065\u0078('\x53\x63\x72\x69\x70\x43\x6f\x6d\x70\x72\x65\x73\x73\x2e\x63\x6f\x6d')); | |
//lets make it a dataURI and embed in an embeded embedded file | |
document['write']('<script src="data:,function%20%5Cu0068%5Cu0065%5Cu0078(%5Cu0394)%7Breturn%20%5Cu0394%5B%27%5Cx72%5Cx65%5Cx70%5Cx6c%5Cx61%5Cx63%5Cx65%27%5D(%2F.%2Fg,function(%5Cu0394)%7Breturn%27%5C%5Cx%27+%5Cu0394%5B%27%5Cx63%5Cx68%5Cx61%5Cx72%5Cx43%5Cx6f%5Cx64%5Cx65%5Cx41%5Cx74%27%5D(0)%5B%27%5Cx74%5Cx6f%5Cx53%5Cx74%5Cx72%5Cx69%5Cx6e%5Cx67%27%5D(16)%7D)%7D;%0D%0A%5Cu0061%5Cu006c%5Cu0065%5Cu0072%5Cu0074(%5Cu0068%5Cu0065%5Cu0078(%27%5Cx53%5Cx63%5Cx72%5Cx69%5Cx70%5Cx43%5Cx6f%5Cx6d%5Cx70%5Cx72%5Cx65%5Cx73%5Cx73%5Cx2e%5Cx63%5Cx6f%5Cx6d%27));"><\/script>'); | |
//because the script source is theoretically HTML in a href link type environment, we can encode some HTML entities | |
this['document']['write']('<script src="data:,function \u0068\u0065\u0078(\u0394){return \u0394['\x72\x65\x70\x6c\x61\x63\x65'](/./g,function(\u0394){return'\\x'+\u0394['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](0)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](16)})}; \u0061\u006c\u0065\u0072\u0074(\u0068\u0065\u0078('\x53\x63\x72\x69\x70\x43\x6f\x6d\x70\x72\x65\x73\x73\x2e\x63\x6f\x6d'));"><\/script>'); | |
//now lets encode again between brackets using octal this time and then encode this in unicode | |
\u0074\u0068\u0069\u0073['\144\157\143\165\155\145\156\164']['\167\162\151\164\145']('\74\163\143\162\151\160\164\40\163\162\143\75\42data:,function \u0068\u0065\u0078(\u0394){return \u0394['\x72\x65\x70\x6c\x61\x63\x65'](/./g,function(\u0394){return'\\x'+\u0394['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](0)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](16)})}; \u0061\u006c\u0065\u0072\u0074(\u0068\u0065\u0078('\x53\x63\x72\x69\x70\x43\x6f\x6d\x70\x72\x65\x73\x73\x2e\x63\x6f\x6d'));\42\76\74\/\163\143\162\151\160\164\76'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment