Created
June 17, 2019 11:19
-
-
Save jpginc/111d222fee41914366989ece814aad8b to your computer and use it in GitHub Desktop.
ignored characters in javascript
This file contains 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
function getIgnoredChars(payload, insertionPoint) | |
{ | |
var asciiMax = 65535; | |
var ignoredChars = []; | |
for(var i = 0; i < asciiMax; i++) { | |
var test = String.fromCharCode(i); | |
var urlStr = payload.slice(0, insertionPoint) + test + payload.slice(insertionPoint); | |
try { | |
var url = new URL(urlStr); | |
if(url.protocol == "javascript:") { | |
ignoredChars.push(test); | |
} | |
} catch (e) {} | |
} | |
return ignoredChars; | |
} | |
atStart = getIgnoredChars("javascript:",0) //get character that can be present before the URI | |
atEnd = getIgnoredChars("javascript:",10) //get character that can be present before the ':' | |
aftertBeforeColon = getIgnoredChars("javascript:",9) //get character that can be present before anywhere inside the 'javascript' part | |
inTheMiddle = getIgnoredChars("javascript:",5) //get character that can be present before anywhere inside the 'javascript' part | |
console.log('done') | |
console.log("at the start" + JSON.stringify(atStart)); | |
console.log("at the end" + JSON.stringify(atEnd)); | |
console.log("between 't' and ':'" + JSON.stringify(aftertBeforeColon)); | |
console.log("int the middle" + JSON.stringify(inTheMiddle)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment