Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / javascript-packer-codepoints.js
Created May 4, 2015 11:53
A JavaScript Packer that encodes to code points of characters. Live demo on http://www.whak.ca/demo/codepoints-packer.htm
var $='WHAK',w=document,h='getElementById',a="javascript",k="value",o="packer";
w.writeln('<h4><a href="http://www.'+$+'.ca">JavaScript Source Code To Code Points Packer</a></h4>\
<textarea id=javascript rows=6 cols=77 onmouseover=this.select()>alert("www.'+$+'.com");<\/textarea>\
<br><textarea id=packer rows=6 cols=77 onmouseover=this.select()><\/textarea><br>\
<input value="Pack" type=button onclick="w[h](o)[k]=Pack_JS_2_Codepoints(w[h](a)[k]);"> \
<input value="Test" type=button onclick="eval(w[h](o)[k]);">');
function Pack_JS_2_Codepoints(W,H,A,K){K=W.replace(/./g,function(H){
return","+H.charCodeAt(0)});A="eval(String.fromCharCode("+K.replace(",","")+"));";return A}
w[h](o)[k]=Pack_JS_2_Codepoints(w[h](a)[k]);
//Try it on http://www.whak.ca/demo/codepoints-javascript-packer.htm
@JavaScript-Packer
JavaScript-Packer / weird-base64-trick.txt
Last active August 29, 2015 14:20
Being Silly, Decode words by Actually Encoding with Base64, made by a modded Base64 script, demo on http://www.whak.ca/demo/base64-glitch.htm
In JavaScript, this will make an alert:
eval(unescape(btoa("jW«·ý¼ÿnՊȭÿm0Ãöy'+Š›B¢jkzË?Ùç(›ý»ÿoÝ¿öýŸ").replace(/\57/g,"\45")));
$DJ
If you encode the above with Base64 it will give you the word JERK
,åD
If you encode the above with Base64 it will give you the word LOVE
@JavaScript-Packer
JavaScript-Packer / Twitter-Text-Compressor.js
Last active August 29, 2015 14:20
Another Twitter string compressor. In base 36 I found over 18,000 possible lowercase combinations of letters only. Live demo on http://www.whak.ca/disfunction.htm
//Another Twitter string compressor. In base 36 I found over 18,000 posible combinations of letters only.
//My name is Dave, there is character 㜊 (code &#14090;) that looks like "ave"
//javascript:alert(parseInt('ave', 36)), so I can literally encode my name to 2 characters instead of 5.
document['wr'+'ite'](unescape("%3Ctextarea%20id=whak%20rows=%226%22%20cols=%2277%22%20onmouseover=%22this.select()%22%3EDave%20suggests%20that%20you%20visit%20www.ScriptCompress.com%20for%20many%20neat%20JavaScript%20programming%20tools!%3C%2Ftextarea%3E%3Cinput%20type=text%20id=%22szwhak%22%20size=%225%22%3E%3Cbr%3E%3Ctextarea%20id=%22pack%22%20rows=%226%22%20cols=%2277%22%20onmouseover=%22this.select()%22%3E%3C%2Ftextarea%3E%3Cinput%20type=text%20id=%22szpack%22%20size=%225%22%3E%3Cbr%3E%3Cinput%20type=%22button%22%20id=%22encoder%22%20onclick=%22encode(whak.value)%22%20value=%22Twit%20Compress%22%3E%3Cinput%20type=%22button%22%20id=%22decoder%22%20onclick=%22decode()%22%20value=%22Twit%20Decompress%22%3E"));
function disf
@JavaScript-Packer
JavaScript-Packer / encode-decode-binary.js
Last active August 29, 2015 14:20
Binary encoder/decoder functions that let you choose a combiner/joiner for each binary. Live demo on http://www.whak.ca/demo/encode-decode-binary.htm
function ascii2binary(e, joiner) {
return Array.prototype.map.call(e, function(e) {
var t = e.charCodeAt(0).toString(2);
return "00000000".substr(t.length) + t;
}).join(joiner);
}
function binary2ascii(e, joiner) {
if (!joiner)joiner=" "; //added so you can leave joiner blank e.g. joiner="";
return e.replace(RegExp(joiner + "*[01]{8}" + joiner + "*", "g"), function(e) {
return String.fromCharCode(parseInt(e, 2));
@JavaScript-Packer
JavaScript-Packer / run-length-encode.js
Created May 10, 2015 15:35
Run Length Encode & Decoder JavaScript functions - Live demo on http://www.whak.ca/demo/run-length-encode.htm
// run length encoder/decoder, not useful when sequence has numbers already in it
function encode_rle(r) {
for (var o, i, n = 0, t = r.length, e = ""; t > n; ++n) void 0 !== o ? r[n] === o ? i++ :(e += i + o,
o = r[n], i = 1) :(o = r[n], i = 1);
return e + (i + o);
}
function decode_rle(r) {
var t, n = /^\d+/.exec(r);
return null === n ? "" :(n = n[0], t = r[n.length], Array(+n + 1).join(t) + decode_rle(r.substr((n + t).length)));
@JavaScript-Packer
JavaScript-Packer / unpacker.js
Last active August 29, 2015 14:21
Made an unpacker (still have to make the JavaScript Packer to compress to this format) that does not need to have assigned character list to match the mapped layout, instead it uses the number of replacement. Made this a while ago, but not long until you are using 2 bytes or more per replacement. The packer will do this with only repeated words …
var W,H,A,K='0("1 11 10.12");2("3 11 10.12");4("5 11 10.12");6.7="8 9 11 10.12";';H=13;
A='alert,HERE,prompt,THERE,confirm,EVERYWHERE,test,value,HELLO,WORLD,WHAK,From,com'[W='split'](',');
while(H--){if(K[H]){K=K[W](H).join(A[H])}}eval(K);
//unpacked
/*
alert("HERE From WHAK.com");
prompt("THERE From WHAK.com");
confirm("EVERYWHERE From WHAK.com");
test.value="HELLO WORLD From WHAK.com";
@JavaScript-Packer
JavaScript-Packer / encode-URL.html
Created May 20, 2015 02:14
3 ways to obfuscate links in HTML source code. Just the www part is encoded for example.
<a href="http://%77%77%77.scriptcompress.com/">ScriptCompress.com</a>
<a href="http://&#119;&#119;&#119;.scriptcompress.com/">ScriptCompress.com</a>
<a href="http://&#x77;&#x77;&#x77;.scriptcompress.com/">ScriptCompress.com</a>
Encoder/decoder on http://www.scriptcompress.com/30-encoders-in-1.htm
@JavaScript-Packer
JavaScript-Packer / pyramid-scheme-chunker.js
Created June 28, 2015 03:10
You can find the pyramid shaped JavaScript packer on www.whak.ca/packer/ so you can make your own! Live demo on http://jsfiddle.net/Lhzgddtn/
$='\
ZnVu\
Y3Rpb\
24gcmF\
uZG9tU2\
l0ZSgpe3\
ZhciBhPSJ\
odHRwOi8vd\
3d3LldIQUsu\
Y29tIGh0dHA6\
@JavaScript-Packer
JavaScript-Packer / base64-encode-decode.js
Created July 1, 2015 00:45
Perfect ATOB/BTOA alternatives (Base64 encoder/decoder) for JavaScript/Jscript.net Demo on http://jsfiddle.net/1okoy0r0/
function b2a(a) {
var c, d, e, f, g, h, i, j, o, b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", k = 0, l = 0, m = "", n = [];
if (!a) return a;
do c = a.charCodeAt(k++), d = a.charCodeAt(k++), e = a.charCodeAt(k++), j = c << 16 | d << 8 | e,
f = 63 & j >> 18, g = 63 & j >> 12, h = 63 & j >> 6, i = 63 & j, n[l++] = b.charAt(f) + b.charAt(g) + b.charAt(h) + b.charAt(i); while (k < a.length);
return m = n.join(""), o = a.length % 3, (o ? m.slice(0, o - 3) :m) + "===".slice(o || 3);
}
function a2b(a) {
var b, c, d, e = {}, f = 0, g = 0, h = "", i = String.fromCharCode, j = a.length;
@JavaScript-Packer
JavaScript-Packer / indexof-alternative.js
Created July 1, 2015 01:25
IE web browser often won't handle indexOf() command in JavaScript (Jscript is IE's engine or coding for Jscript.net), so here is an alternate function: http://jsfiddle.net/ccxqosxn/
function myIndexOf(a, b) {
var c, d, e = a.length, f = b.length;
for (c = 0; e > c; c++) {
for (d = 0; f > d && a[c + d] == b[d]; d++) ;
if (d == f) return c;
}
return -1;
}
//USAGE: