Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / hashish.js
Created April 30, 2015 13:16
Get complete hash of URL without substring, split/join or indexof
if(window.location.hash) {
alert(window.location.hash.replace("#",""));
//above we simply get rid of the first occurance of #, without global set, only first match dealt with
} else {
alert('no hash for you');
}
//this is a WHAK.com script :)
@JavaScript-Packer
JavaScript-Packer / WTF.js
Created April 29, 2015 06:52
WTF? How does this JavaScript even work? 20 obfuscated snippets from 1 script
//eample of weird and crazy obfuscation on http://www.whak.ca/ (whak-a-script)
var W,H,A,K,com;for(W='€̷̛͇̟̎̎̎ͅ€̷̷̷̷̧̛̛̛̛͕̰̗͎͇͕̗̖͇͕͔͎̎̍̍̇̍̍̇͛̎̚̕҉̷̷͕̎̍̍̎̓͛̎͛̚ͅ\n€̷̛͇͕͕̟̎ͨͅ€͔͛ͅ\n̷̷̛̥͎̰͇͇̟͉ͣͨͨ̎ͣͨͨ҉̷̵͇̟͇͕͕̟̣̘̎ͫ̎ͨ̎̓̎̎ͣ͊͊̋€̵̴̘͔ͣ͊͊҉͇͕͕̟̎ͨ̎̓҉̷͇̟̎̎̓̎͛\n̷̷̛͇̟͉ͣͨͨ҉̷͇̟͇͕͕̟̎ͫ̎ͨ̎̓͛',K='',com=31;127>com;com++)K+=String.fromCharCode(com);K=K.split(''),A='̫̎̉̔̊̇ͅ҉̴̧̖̼̙̩̘̺̝̭͙̓̀̿ͫͬ͊̋́͛̃͗͌ͭͦ̐͆̈́͘͡͝͏̶̵̷̡̛͉̪̤̟̥̰̱͔͕͇̗͎͂̂ͪ̄ͯ̾̑̽ͨ̌̍ͣ̕̚͢͜͠€‚̻̨̢̣̞͍̦̬̜͈̳͓̹̲̆ͮ̈̓ͩ͐͑ͤͧ̀̏̅̒͟ƒ̸̠̮̯͖͚͒͋ͥ́͞'.split('');for(var S in A)W=W.split(A[S]).join(K[S]);this['eval'](W);
//this was our original JavaScript source code:
var code = " alert( 'ScriptCompress.com' ); ";
var command="eval"; //command="\x65val";
function runner( Δ, ǃ ) { \u0065v\u0061l( ǃ )( Δ ) };
runner( code, command );
//ALL BELOW SAMPLES ARE ACTUAL WORKING JAVASCRIPT
@JavaScript-Packer
JavaScript-Packer / wtf.js
Created April 29, 2015 05:56
WTF? How does this JavaScript even work?
Δ=~[],Δ={ǃǃǃ:++Δ,ππππ:(!1+"")[Δ],ǃǃπ:++Δ,πǃπǃ:(!1+"")[Δ],ǃπǃ:++Δ,πǃππ:({}+"")[Δ],ππǃπ:(Δ[Δ]+"")[Δ],
ǃππ:++Δ,πππǃ:(!0+"")[Δ],πǃǃ:++Δ,πǃπ:++Δ,ππǃǃ:({}+"")[Δ],
ππǃ:++Δ,πππ:++Δ,πǃǃǃ:++Δ,πǃǃπ:++Δ},
Δ.πǃ=(Δ.πǃ=Δ+"")[Δ.πǃπ]+(Δ.ǃπ=Δ.πǃ[Δ.ǃǃπ])+(Δ.ππ=(Δ.π+"")[Δ.ǃǃπ])+(!Δ+"")[Δ.ǃππ]+(Δ.ǃǃ=Δ.πǃ[Δ.ππǃ])+(Δ.π=(!0+"")[Δ.ǃǃπ])+(Δ.ǃ=(!0+"")[Δ.ǃπǃ])+Δ.πǃ[Δ.πǃπ]+Δ.ǃǃ+Δ.ǃπ+Δ.π,Δ.ππ=Δ.π+(!0+"")[Δ.ǃππ]+Δ.ǃǃ+Δ.ǃ+Δ.π+Δ.ππ,Δ.π=Δ.ǃǃǃ[Δ.πǃ][Δ.πǃ],
Δ.π(Δ.π(Δ.ππ+'"'+Δ.ππππ+Δ.ǃ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.ππǃ+Δ.ππǃǃ+Δ.ǃǃ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.ǃǃπ+Δ.ǃπ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.ππǃ+"\\"+Δ.πǃǃ+Δ.ǃǃǃ+Δ.ππǃǃ+Δ.ǃπ+Δ.ππǃπ+Δ.πππǃ+"\\"+Δ.ǃǃπ+Δ.ǃπǃ+Δ.ǃπǃ+Δ.ǃ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.ππǃ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.ππǃ+Δ.πππǃ+"\\"+Δ.ǃǃπ+Δ.ππǃ+Δ.ǃπǃ+"("+Δ.ππǃǃ+Δ.ǃπ+Δ.ππǃπ+Δ.πππǃ+","+Δ.ππǃǃ+Δ.ǃπ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.πǃπ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.πǃπ+Δ.πǃπǃ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.ππǃ+Δ.ππǃπ+"){"+Δ.πππǃ+"\\"+Δ.ǃǃπ+Δ.ππǃ+Δ.ππǃ+Δ.πǃπǃ+(!1+"")[Δ.ǃπǃ]+"("+Δ.ππǃǃ+Δ.ǃπ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.πǃπ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.πǃπ+Δ.πǃπǃ+"\\"+Δ.ǃǃπ+Δ.πǃπ+Δ.ππǃ+Δ.ππǃπ+")("+Δ.ππǃǃ+Δ.ǃπ+Δ.ππǃπ+Δ.πππǃ+")}\\"+Δ.ǃǃπ+Δ.ππǃ+Δ.
@JavaScript-Packer
JavaScript-Packer / code_runner.js
Created April 29, 2015 04:50
Pass a command to function that can be easily obfuscated
var code = " alert( 'ScriptCompress.com' ); ";
var command="eval"; //command="\x65val";
function runner( Δ, ǃ ) { \u0065v\u0061l( ǃ )( Δ ) };
runner( code, command );
@JavaScript-Packer
JavaScript-Packer / obfuscation.js
Created April 29, 2015 03:58
Watch me do (step by step) a basic manual obfuscation of basic JavaScript source code
//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'));
@JavaScript-Packer
JavaScript-Packer / minified.js
Created April 29, 2015 03:25
Watch me do (step by step) a basic manual minification of basic JavaScript file
//212 bytes
function codepoints(ΔstringΔ) {
return ΔstringΔ.replace(/./g, function(ΔstringΔ) {
return ΔstringΔ.charCodeAt(0) + " ";
}).trim().replace(/ /g, ",");
}
alert(codepoints("JavaScript Packer"));
//first lets get rid of uneeded whitespace and linebreaks
@JavaScript-Packer
JavaScript-Packer / codepoints.js
Created April 29, 2015 03:08
Get your characters converted to an array (comma delimited) of codepoints
function codepoints(Δ) {
return Δ.replace(/./g, function(Δ) {
return Δ.charCodeAt(0) + " ";
}).trim().replace(/ /g, ",");
}
alert(codepoints("JavaScript Packer"));
@JavaScript-Packer
JavaScript-Packer / hexidecimal.js
Created April 29, 2015 02:59
Extreme escape for JavaScript code by every character (hex encoding)
function hex(Δ){
return Δ.replace(/./g, function(e){
return "\\x"+e.charCodeAt(0).toString(16);
});
};
alert(hex("JavaScript Packer"));
//extreme JavaScript escaping
@JavaScript-Packer
JavaScript-Packer / octal.js
Created April 29, 2015 02:57
Extreme escape for JavaScript code by every character
function octal(П){
return П.replace(/./g, function(e){
return "\\"+e.charCodeAt(0).toString(8);
});
};
alert(octal("JavaScript Packer"));
//extreme JavaScript escaping
@JavaScript-Packer
JavaScript-Packer / escapeHTML.js
Created April 29, 2015 02:54
Escape all characters to HTML entities (codepoints)
function escapeHTML(Δ){
return Δ.replace(/./g, function(e){
return "&#"+e.charCodeAt(0)+";";
});
};
alert(escapeHTML("JavaScript Packer"));