简述SQL注入漏洞的防御方法

来源:百度知道 编辑:UC知道 时间:2024/05/17 03:32:37

分析下面一条SQL语句
sql="select * from tb_admin where a='"&username&"' and userpwd='"&pwd&"'"
正常的时候是
username="admin"
pwd="admin"
select * from tb_admin where a='admin' and userpwd='admin'
如果
username="'or'="
select * frm tb_admin where a=''or '=' and userpwd=''
其中不管怎么样 '=' 都是true
看看这条语句能不查到数据?
这是最简单的
复杂的话可以看看相关的SQL注入
网上资料很多

基本上讲,不要直接用request得来的东西拼字符串就行了

username=Replace(Replace(request("username"),"'",""),Chr(39),"")用这个得来值就行了