急,up有分

lk_cool 2003-11-12 05:50:50
<!--#include file="userconn.inc"-->

<%
dim dbconn
dim rs
%>
<%
session("passok")=false
uname=request.form("uname")
pass=request.form("password")

if uname<>"" or pass<>"" then

'set conn=server.createobject("adodb.connection")
application.lock

commandtext="select * from checkusers where name='"& uname &"' and mima='"& pass &"'"
set rs=conn.Execute(commandtext)

if rs.eof then
session("passok")=false
else
session("passok")=true
end if

set conn=nothing

application.unlock

end if

select case session("passok")
case true
Response.Redirect("select.asp")
case false
%>

<html>
<head>
<title>登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#ffffff" text="#000000">

<h1>密码错误</h1>
<a href="check.asp">返回</a>

</body>
<% end select %>
</html>


这段代码编写的程序可以北绕过去!

我的密码根本没有作用

请问这是为什么?

怎样避免?

...全文
65 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
vivisogood 2003-12-08
  • 打赏
  • 举报
回复
http://websit/userconn.inc可以直接看到

第二
select * from checkusers where name='"& uname &"' and mima='"& pass &"'

如果pass 是'1 or '1'='1 就
qiangtian 2003-11-19
  • 打赏
  • 举报
回复
不要在一个sql语句里比较用户名密码,先用sql语句检查用户是否存在,然后在检查密码是否正确
  • 打赏
  • 举报
回复
首先把提交时,客户端检查非法字符,然后查询的时候先查用户名,后用查到的记录数据比较密码,千万不要用AND,把用户名和密码同时查,这样会被构造的字符串通过
DeltaCat 2003-11-19
  • 打赏
  • 举报
回复
1.按一楼的方法
2.过滤特殊字符,如 空格,单引号,双引号
lk_cool 2003-11-19
  • 打赏
  • 举报
回复
输入什么可以进去?
for example:
Comer 2003-11-13
  • 打赏
  • 举报
回复
up
xx
mjwgtm 2003-11-13
  • 打赏
  • 举报
回复
uname=replace(trim(request("uname")),"'","")
pass=replace(trim(Request("password")),"'","")
sjjf 2003-11-12
  • 打赏
  • 举报
回复
无非也就是拼sql的特殊字符问题了。
比如
commandtext="select * from checkusers where name='"& uname &"' and mima='"& pass &"'"

那么如果没有过滤掉特殊字符例如 '和or and之类的字符或其组合字符。则会被利用
生成
select * from checkusers where name='aa' or 1=1 and mima='xxx'
这样无论你输入什么都无效了。
解决方法,具体跟数据库的sql语法的字符有关(不同的数据库的字符串界定不一定一样)。
1)你可以在客户端做检查如果不是字符串传型的不允许输入字符串
如果是字符串型的,则不允许'和and,or存在。
2)在服务器端将' and or用别的内容替换掉。但可能会影响数据库的完整性约束。
3)在服务器端将字符的界定符转义例如遇到'都用''代替(类似网络传输中的0比特填充法),但是也存在影响数据库完整性约束问题。
dafei0320 2003-11-12
  • 打赏
  • 举报
回复
顶---
luoluonet 2003-11-12
  • 打赏
  • 举报
回复
sql注入~

过滤单引号等字符串~~
bzscs 2003-11-12
  • 打赏
  • 举报
回复
至少要replace(uname,"'","''")replace(pass,"'","''")
tuoshi 2003-11-12
  • 打赏
  • 举报
回复
把用户名和密码分开来判断,另外也可对一些特殊字符进行过滤。
ljupin 2003-11-12
  • 打赏
  • 举报
回复
按Tal(Tal)说的试试
萝卜波 2003-11-12
  • 打赏
  • 举报
回复
把 commandtext 写出来看看
是否 这个页面获取到了 用户和密码 数据
whb147 2003-11-12
  • 打赏
  • 举报
回复
你把session("passok")写出来看看是什么东西。

Tal 2003-11-12
  • 打赏
  • 举报
回复
commandtext="select * from checkusers where name='"& uname &"'"

查到后再比较
if rs("mima") = pass then
session("mima") = pass
else
session("mima") = ""
end if
以后在每一页中都
if session("mima") & "" <> "" then
response.redirct "login.asp"
end if

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧