Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
JavaScript-Packer / evil-eval.js
Created January 26, 2016 00:24
Hidden evil eval in JavaScript www.JavaScriptCrypt.com
var evil_eval = (!+[] + [])[!+[] + !+[] + !+[]] + "v" + (!1 + [])[+!+[]] + (!1 + [])[!+[] + !+[]];
function test() {
alert("WHAK.com");
}
this[evil_eval](test());
@JavaScript-Packer
JavaScript-Packer / notifier.js
Created January 24, 2016 20:50
Internet Browser notifications in JavaScript
!function() {
"Notification" in window ? "granted" === Notification.permission ? new Notification("Hi there from WHAK.com!") :"denied" !== Notification.permission && Notification.requestPermission(function(permission) {
"granted" === permission && new Notification("Hi there from WHAK.com!");
}) :alert("no");
}();
@JavaScript-Packer
JavaScript-Packer / vanity-functions-variables.js
Created January 24, 2016 16:08
Few ways to do vanity scripting in JavaScript www.fakehack.com
var www = {}; www.WHAK = {};
www.WHAK.ca = "http://www.whak.ca";
www.WHAK.com = function(){ return "http://www.whak.com"; }();
www.WHAK.us = function(x){ return x}
console.log(www.WHAK.us("http://www.whak.us"));
console.log(www.WHAK.com);
console.log(www.WHAK.ca);
@JavaScript-Packer
JavaScript-Packer / hex-encoder.htm
Created January 17, 2016 18:10
HEX encoding from JavaScript escape function/command. www.whak.ca
<input type="button" value="Hex Escape" onclick="alert(escape('A test!').replace(/%/g,'\\x'));">
<input type="button" value="Hex unEscape" onclick="alert(unescape('A\\x20test\\x21'.replace(/\\x/g,'%')));">
@JavaScript-Packer
JavaScript-Packer / cypheriffic.js
Created January 15, 2016 16:49
Like ROT13 but uses characters used in JavaScript source codes to encrypt/encode. Function will automatically decide if it must decode or encode. www.whak.ca
function cypher(r) {
function t(r, e) {
var a = "\n\x20\t`~_^*'\"<+,-.:;=>!?/{|}[\\]#$%&()@0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
a.length > e && (r === a.split("").reverse().join("")[e] && (n += a[e]), t(r, e + 1));
}
function e(r, a) {
return a > r.length ? void 0 : (t(r[a], 0), e(r, a + 1), n);
}
var n = "";
return e(r, 0);
@JavaScript-Packer
JavaScript-Packer / codepoints.js
Created January 14, 2016 09:25
UTF-8 to character code points array, bot encode and decode functions
var toCharCode = function(x) {
var o, e = x.split(""), t = [];
for (o in e) t.push(e[o].charCodeAt(0));
return t;
};
var unCharCode = function(x) {
return this["eval"]("String.fromCharCode(" + x + ")");
};
@JavaScript-Packer
JavaScript-Packer / swappie.js
Created January 11, 2016 17:58
JavaScript function to swap 2 sets of strings with each other. Switch double quotes with single quotes for example. www.WHAK.ca
function swap_str(e, r, t) {//function to swap 2 sets of strings with each other
return e = e.split(r).join("WHAK_a_SWAP"), e = e.split(t).join("WHAK_b_SWAP"), e = e.split("WHAK_a_SWAP").join(t),
e = e.split("WHAK_b_SWAP").join(r);
}
//test 1
var str = 'this is "test" of a \'test\' of swapping strings';
var manipulated = swap_str(str,"'",'"');
document.writeln(manipulated)
//test 2
manipulated = swap_str(manipulated,"'",'"');
@JavaScript-Packer
JavaScript-Packer / lzw.jz
Created January 9, 2016 23:28
JavaScript LZW Compression (encode and decode functions). Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78 algorithm published by Lempel and Ziv in 1978. The algorithm is simple to implement,…
function en(c) {
var x = "charCodeAt", b, e = {}, f = c.split(""), d = [], a = f[0], g = 256;
for (b = 1; b < f.length; b++) c = f[b], null != e[a + c] ? a += c :(d.push(1 < a.length ? e[a] :a[x](0)),
e[a + c] = g, g++, a = c);
d.push(1 < a.length ? e[a] :a[x](0));
for (b = 0; b < d.length; b++) d[b] = String.fromCharCode(d[b]);
return d.join("");
}
function de(b) {
@JavaScript-Packer
JavaScript-Packer / parse-between.js
Last active January 5, 2016 18:27
www.whak.ca/between-parser.htm Parse a string for variables found between 2 smaller strings. Good for parsing all data from all the data say held between quotes or brackets.
function parseBetween(s, b, b2, j) {
var x = [];
var a = s.split(b);
for (var i = 1; i < a.length; i++) if (true == function(z) {
return z % 2;
}(i)) x.push(a[i].split(b2));
if ("" == j) return x; else return x.join(j);
}
var str = 'hello, my website is "www.WHAK.ca", my friend\'s site is "www.BibleHunter.com". what\'s yours?';
document.writeln(parseBetween(str, '"', '"', "<hr>"));
@JavaScript-Packer
JavaScript-Packer / javascript-escape.js
Created January 1, 2016 04:13
Simple and effective escaper function for JavaScript new lines, quotes, etc
function kleen(e, r) {
r = "replace";
return e[r](/\\/g, "\\\\")[r](/\r/gm, "\n")[r](/\n{2,}/gm, "\n")[r](/\n/g, "\\n")[r](/\'/g, "\\'"[r](/\"/g, '\\"'));
}