Skip to content

Instantly share code, notes, and snippets.

@rebolyte
Created June 28, 2016 08:43
Show Gist options
  • Save rebolyte/24de064e98e9e69b70c4e3964a9ad1e3 to your computer and use it in GitHub Desktop.
Save rebolyte/24de064e98e9e69b70c4e3964a9ad1e3 to your computer and use it in GitHub Desktop.
JS code obfuscation
let code = "console.log('testing')";
// encode
let a = [...code]
.map(x => x.charCodeAt())
.map(x => x.toString(2))
.join('2');
// decode
let chars = a.split('2').map(x => parseInt(x, 2));
let origStr = String.fromCharCode(...chars);
new Function(origStr)();
// Template string tagging also works?
// alert`xss`
// (This runs and displays an alert)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment