公司质量目标的制定:有谁知道asp里怎么解决 1'or'1'='1可以登入的问题?

来源:百度文库 编辑:神马品牌网 时间:2024/04/23 18:15:31

不要使用这样的语句"select * from 表名 where UserName='" & 用户名 & "' and Password='" & 密码 & "'"

正确的做法应该是"select * from 表名 where UserName='" & 用户名 & "'"
如果没有此用户,直接退出,如果有此用户,再比较
rs("Password")是否等于密码
正确就登录,不正确就退出

在登陆、注册和修改密码的程序里,在原有的接收密码数据的语句后加入判断,如果包含非法字符则提示错误,示例如下:

<%
password=request("password")
if Check_Str(password) then
%>
<script language=javascript>
alert('包含非法符号!');
history.go(-1);
</script>
<%
else

'你的原有处理语句加在这里

end if

'下面是检查非法字符的函数,可以另存一个文件,在需要用的地方include进来

Function Check_Str(Input)

Output = False
If InStr(Input,Chr(32)) Then Output = True '空格
If InStr(Input,Chr(33)) Then Output = True '!
If InStr(Input,Chr(34)) Then Output = True '"
If InStr(Input,Chr(35)) Then Output = True '#
If InStr(Input,Chr(36)) Then Output = True '$
If InStr(Input,Chr(37)) Then Output = True '%
If InStr(Input,Chr(38)) Then Output = True '&
If InStr(Input,Chr(39)) Then Output = True ''
If InStr(Input,Chr(42)) Then Output = True '*
If InStr(Input,Chr(43)) Then Output = True '+
If InStr(Input,Chr(44)) Then Output = True ',
If InStr(Input,Chr(46)) Then Output = True '.
If InStr(Input,Chr(47)) Then Output = True '/
If InStr(Input,Chr(58)) Then Output = True ':
If InStr(Input,Chr(59)) Then Output = True ':
If InStr(Input,Chr(60)) Then Output = True '<
If InStr(Input,Chr(61)) Then Output = True '=
If InStr(Input,Chr(62)) Then Output = True '>
If InStr(Input,Chr(63)) Then Output = True '?
If InStr(Input,Chr(64)) Then Output = True '@
If InStr(Input,Chr(91)) Then Output = True '[
If InStr(Input,Chr(92)) Then Output = True '\
If InStr(Input,Chr(93)) Then Output = True ']
If InStr(Input,Chr(94)) Then Output = True '^
If InStr(Input,Chr(96)) Then Output = True '`
If InStr(Input,Chr(123)) Then Output = True '{
If InStr(Input,Chr(124)) Then Output = True '|
If InStr(Input,Chr(125)) Then Output = True '}
If InStr(Input,Chr(126)) Then Output = True '~
Check_Str = Output

End Function

%>

你可以用replace这个来过滤掉'就可以了.

这是什么问题,没有看明白,你说得清楚点

这是二进制或问题,就是密码框中天1'or'1'='1和程序里的‘ ’构成一个true,所以可以登陆,但现在基本上都防止这中输入了