当前位置:首页 > 技术问答集
firefox

这段简单的程序有注入危险吗?

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

经常看到讨论安全问题,说对任何用户提交的数据必须进行过滤,下面这段程序有过滤的必要吗?  
  $result=mysql_query("select   password   from   users   where   user_name=$_post[username]   limit   1");  
  $row=mysql_fetch_array($result);  
  if($row[password]==md5($_post[password]){  
  .....  
  }  
  else  
  die("");

· 网友精彩回答:

发表者:zairwolfo

没有绝对的东西。不要用安全性来开玩笑。还是从基本上写好先吧。

发表者:loveconan

if(   !get_magic_quotes_gpc()   )  
  {  
  if(   is_array($_get)   )  
  {  
  while(   list($k,   $v)   =   each($_get)   )  
  {  
  if(   is_array($_get[$k])   )  
  {  
  while(   list($k2,   $v2)   =   each($_get[$k])   )  
  {  
  $_get[$k][$k2]   =   addslashes($v2);  
  }  
  @reset($_get[$k]);  
  }  
  else  
  {  
  $_get[$k]   =   addslashes($v);  
  }  
  }  
  @reset($_get);  
  }  
   
  if(   is_array($_post)   )  
  {  
  while(   list($k,   $v)   =   each($_post)   )  
  {  
  if(   is_array($_post[$k])   )  
  {  
  while(   list($k2,   $v2)   =   each($_post[$k])   )  
  {  
  $_post[$k][$k2]   =   addslashes($v2);  
  }  
  @reset($_post[$k]);  
  }  
  else  
  {  
  $_post[$k]   =   addslashes($v);  
  }  
  }  
  @reset($_post);  
  }  
   
  if(   is_array($_cookie)   )  
  {  
  while(   list($k,   $v)   =   each($_cookie)   )  
  {  
  if(   is_array($_cookie[$k])   )  
  {  
  while(   list($k2,   $v2)   =   each($_cookie[$k])   )  
  {  
  $_cookie[$k][$k2]   =   addslashes($v2);  
  }  
  @reset($_cookie[$k]);  
  }  
  else  
  {  
  $_cookie[$k]   =   addslashes($v);  
  }  
  }  
  @reset($_cookie);  
  }  
  }

.
© 2006-2008 All Rights Reserved