Created
June 28, 2016 08:43
-
-
Save rebolyte/24de064e98e9e69b70c4e3964a9ad1e3 to your computer and use it in GitHub Desktop.
JS code obfuscation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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