sql="select uid,pwd from account where uid='" & username & "' and pwd='" & pwd "'" rs.open sql,conn,1,1 if not rs.eof then response.write rs(0) & "欢迎您,您已登陆成功" else response.write "登陆失败,错误的用户名或密码" end if ............ 以上程序的漏洞是显而易见的 我们可以以 用户名: admin 密码: a' or '1'='1 轻易以admin的账号登陆系统 因为我们的sql 变为了 select uid,pwd from account where uid='admin' and pwd='a' or '1'='1' 显然 uid='admin' and pwd='a' or '1'='1'是恒为成立的所以 rs.eof 为false
正确的写法应为 sql="select uid,pwd from account where uid='" & username & "' and pwd='" & pwd "'" rs.open sql,conn,1,1 if rs(0)=username and rs(1)=pwd then response.write rs(0) & "欢迎您,您已登陆成功" else response.write "登陆失败,错误的用户名或密码" end if