Skip to content

Instantly share code, notes, and snippets.

@jasonsperske
Last active November 4, 2024 11:03
Show Gist options
  • Save jasonsperske/5400283 to your computer and use it in GitHub Desktop.
Save jasonsperske/5400283 to your computer and use it in GitHub Desktop.
JavaScript Obfuscator

Based on @VisioN's profile signature in StackOverflow, turned into a configurator that anyone can use.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
#obfuscated {
width: 100%;
height: 350px;
}
</style>
<input id='input' value='I love you'/>
<button id='obfuscate'>obfuscate</button>
<br/>
<textarea id='obfuscated'></textarea>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
var obfuscateMap = {
'a': ['(([]===[])+/-/)[1]'],
'b': ['(1+{})[(1<<1)+1]'],
'c': ['(1+{})[1+11>>>1]','(-{}+{})[-1+1e1-1]'],
'e': ['([]+![])[1<<1<<1]','([,][~1]+[])[1-~1]'],
'f': ['([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]])[1^1]'],
'i': ['/\\[[^1]+\\]/[([]+![])[1<<1<<1]+(/|/[(1+{})[1+11>>>1]+[[]+{}][+!1][1]+([]+1/[])[1<<1>>1]+([1<1]+[])[1+11>>>1+1]+[[!!1]+1][+[]][1-1]+([]+!!/!/)[1|1]+(/1/[1]+[])[!1%1]+(-{}+{})[-1+1e1-1]+(1+[!!1])[1]+([]+1+{})[1<<1]+[!!/!!/+[]][+[]][1&1]]+/=/)[1e1+(1<<1|1)+(([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]])[1^1]==+!1)]+(!![]+{})[1|1<<1]+[1+{}+1][!1+!1][(11>>1)+1]](([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]]))[1&.1][(11>>>1)-1]'],
'I': ['[[]+1/!1][1^1][1>>1]'],
'j': ['(1+{})[1<<1+1]'],
'l': ['([]+!!-[])[1<<1]'],
'n': ['([]+1/[])[1<<1>>1]'],
'o': ['[[]+{}][+!1][1]','([]+1+{})[1<<1]','[/~/+{}][+!1][-~1<<1]','[[],[]+{}][1<<1>>>1][1||1]'],
'O': ['[[]+{}][+!1][(1<<1<<1)+(1<<1<<1)]','[[]+{}][+!1][(1<<1<<1<<1)]'],
'r': ['([]+!!/!/)[1|1]','[!!/!!/+[]][+[]][1&1]'],
's': ['([1<1]+[])[1+11>>>1+1]'],
't': ['[[!!1]+1][+[]][1-1]','(1+[!!1])[1]'],
'u': ['(/1/[1]+[])[!1%1]','(/[<+>]/[1&1|1]+[1.1])[1/11.1&1.11]'],
'v': ['/\\[[^1]+\\]/[([]+![])[1<<1<<1]+(/|/[(1+{})[1+11>>>1]+[[]+{}][+!1][1]+([]+1/[])[1<<1>>1]+([1<1]+[])[1+11>>>1+1]+[[!!1]+1][+[]][1-1]+([]+!!/!/)[1|1]+(/1/[1]+[])[!1%1]+(-{}+{})[-1+1e1-1]+(1+[!!1])[1]+([]+1+{})[1<<1]+[!!/!!/+[]][+[]][1&1]]+/=/)[1e1+(1<<1|1)+(([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]])[1^1]==+!1)]+(!![]+{})[1|1<<1]+[1+{}+1][!1+!1][(11>>1)+1]](([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]]))[1&.1][11>>>1]'],
'x': ['[([]+![])[1<<1<<1]+(/|/[(1+{})[1+11>>>1]+[[]+{}][+!1][1]+([]+1/[])[1<<1>>1]+([1<1]+[])[1+11>>>1+1]+[[!!1]+1][+[]][1-1]+([]+!!/!/)[1|1]+(/1/[1]+[])[!1%1]+(-{}+{})[-1+1e1-1]+(1+[!!1])[1]+([]+1+{})[1<<1]+[!!/!!/+[]][+[]][1&1]]+/=/)[1e1+(1<<1|1)+(([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]])[1^1]==+!1)]+(!![]+{})[1|1<<1]+[1+{}+1][!1+!1][(11>>1)+1]][1>>1][1]'],
'y': ['(/1/+1/[1<1][1%1])[1^11]'],
' ': ['({}+[])[1<<1^11>>1]','[[]+{}][!1.1%1][11111.1%11.1*111e11|!1]'],
}, obfuscate = function(input, map) {
var out = [], char;
for(char = 0; char < input.length; char++) {
if(map.hasOwnProperty(input[char])) {
out.push(map[input[char]][Math.floor(Math.random()*map[input[char]].length)])
} else {
out.push('?');
}
}
return out.join('+');
};
$(function() {
$('#obfuscate').on('click', function() {
$('#obfuscated').val(obfuscate($('#input').val(), obfuscateMap));
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment