Skip to content

Instantly share code, notes, and snippets.

@yahelc
Created May 15, 2015 16:10
Show Gist options
  • Save yahelc/ad2fbadcea57d6f72001 to your computer and use it in GitHub Desktop.
Save yahelc/ad2fbadcea57d6f72001 to your computer and use it in GitHub Desktop.
Deobfuscate Silverpop's %%RECIPIENTID%%
function deobfuscate_sp_recipientid(a) {
var b = a.length,
c = a.substring(b -
1);
a = a.substring(0, b - 2);
switch (parseInt(c, void 0)) {
case 1:
a += "*";
break;
case 2:
a += "**"
}
c = [];
for (b = 0; 25 >= b; b++) c[b] = String.fromCharCode(65 + b);
for (b = 0; 25 >= b; b++) c[b + 26] = String.fromCharCode(97 + b);
for (b = 0; 9 >= b; b++) c[b + 52] = String.fromCharCode(48 + b);
c[62] = "_";
c[63] = "-";
for (var b = [], d = 0; 256 > d; d++) b[d] = -1;
for (d = 0; 64 > d; d++) b[c[d].charCodeAt(0)] = d;
b[61] = -2;
for (var c = Array(3 * (a.length / 4)), g = 0, e = 0, f = 0, k = 0, d = 0; d < a.length; d++) {
var h = a.charAt(d),
h = "." == h ? "\n" : "*" == h ? "\x3d" : a.charAt(d),
h = h.charCodeAt(0),
h = 255 >= h ?
b[h] : -1;
switch (h) {
case -1:
break;
case -2:
h = 0, k++;
default:
switch (g) {
case 0:
e = h;
g = 1;
break;
case 1:
e <<= 6;
e |= h;
g = 2;
break;
case 2:
e <<= 6;
e |= h;
g = 3;
break;
case 3:
e <<= 6, e |= h, c[f + 2] = e & 255, e >>>= 8, c[f + 1] = e & 255, e >>>= 8, c[f] = e & 255, f += 3, g = 0
}
}
}
if (0 != g) a = null;
else
for (f -= k, a = "", b = c.length != f ? f : c.length, d = 0; d < b; d++) a += String.fromCharCode(c[d]);
return a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment