-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce Snow integration with CSP (#118)
- Loading branch information
Showing
27 changed files
with
513 additions
and
446 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
function bypass(wins) { | ||
(wins || []).forEach(w => w.alert.call(top, 'snow bypass attempt')); | ||
} | ||
|
||
function run(js) { | ||
const script = document.createElement('script'); | ||
script.textContent = '{' + js + '}'; | ||
document.head.appendChild(script); | ||
} | ||
|
||
(function(){ | ||
location.href.includes('self-xss-challenge-msg') && (msg.style.display = 'block'); | ||
|
||
location.search.includes('disable') || SNOW((win) => { | ||
win.alert = (msg) => { | ||
console.log('Snow: ', 'alert API is disabled, message is printed to console instead: ', msg); | ||
} | ||
}); | ||
|
||
ta.value = JSON.parse(localStorage.code_snow || '""') || | ||
` | ||
/* | ||
attempts to bypass Snow after running: | ||
SNOW((win) => { | ||
win.alert = (msg) => { | ||
console.log('Snow: ', 'alert API is disabled, message is printed to console instead: ', msg); | ||
} | ||
}); | ||
*/ | ||
debugger; | ||
// insertion bypass attempt | ||
(function(){ | ||
const ifr = document.createElement('iframe'); | ||
document.head.appendChild(ifr); | ||
ifr.contentWindow.alert.call(top, 'alert bypass using insertion') | ||
}()); | ||
// innerHTML bypass attempt | ||
(function(){ | ||
const a = document.createElement('a'); | ||
a.innerHTML = '<iframe id="xxx"></iframe>'; | ||
document.head.appendChild(a); | ||
a.firstChild.contentWindow.alert.call(top, 'alert bypass using innerHTML') | ||
}()); | ||
// onload attribute bypass attempt | ||
(function(){ | ||
const ifr = document.createElement('iframe'); | ||
ifr.onload = () => ifr.contentWindow.alert.call(top, 'alert bypass using onload attribute') | ||
document.head.appendChild(ifr); | ||
}()); | ||
// onload listener bypass attempt | ||
(function(){ | ||
const ifr = document.createElement('iframe'); | ||
ifr.addEventListener('load', () => ifr.contentWindow.alert.call(top, 'alert bypass using onload listener')) | ||
document.head.appendChild(ifr); | ||
}()); | ||
`; | ||
|
||
bt.addEventListener('click', () => { | ||
localStorage.code_snow = JSON.stringify(ta.value); | ||
run(ta.value); | ||
}); | ||
|
||
window.addEventListener('keydown', (event) => { | ||
if ((event.ctrlKey || event.metaKey) && event.code === 'Enter') { | ||
bt.click(); | ||
} | ||
}); | ||
}()); |
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Oops, something went wrong.