检测此PHP文件中的漏洞

-1 php security xss

我有这个链接

http://example.com/example.php?link=<link>&title=<title>&bild=<picturelink>&named=<text>

<>中的每个术语代表一个变量,可以由一个卑鄙的攻击者改变.

<named> = domain-name of <link>
Run Code Online (Sandbox Code Playgroud)

这是处理php文件

<?php
if(strpos($_GET[named],"known.com")!==false or 
   strpos($_GET[named],"known2.com")!==false or 
   strpos($_GET[named],"known3.com")!==false)
{
echo '<div align="center"><a href=' . 
     $_GET[link] . 
     ' target="_blank"><img alt="' . 
     htmlentities(utf8_decode($_GET[title])) . 
     '"  title="' . htmlentities(utf8_decode($_GET[title])) . 
     '"  src=' . $_GET[bild] . 
     '  border=0></a></div><br><br><b>' . 
     htmlentities(utf8_decode($_GET[title])) . 
     '</b><br><br><a  href=' . 
     htmlentities($_GET[link]) . 
     ' target="_blank" style="color: grey;">Text <i>' . 
     htmlentities(utf8_decode($_GET[title])) . '</i> text ' . 
     htmlentities($_GET[named]) . '!</a><br>(text)';
}
else
{
echo 'not allowed';
}
?>
Run Code Online (Sandbox Code Playgroud)

怎么能被攻击,你建议对php文件进行哪些更改?

Bra*_*rad 5

逃避你的数据!

任何用户输入都不应该直接放入HTML中,或者他们可以插入Javascript并窃取会话等等.

使用这样的东西: htmlspecialchars($_GET['link'])

另见:http: //en.wikipedia.org/wiki/Cross-site_scripting#Exploit_scenarios