|
下面介绍很简单的防黑小技巧
在网页config.asp文件里面加上这样一串代码
function ChkPost()
dim server_v1,server_v2
chkpost=false
server_v1=Cstr(Request.Servervariables("HTTP_REFERER"))
server_v2=Cstr(Request.Servervariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2))<>server_v2 then
chkpost=false
else
chkpost=true
end if
end function
然后在那些问题页面里找个合适的位置插入以下代码:
if not ChkPost() then
response.write "请不要尝试漏洞或者请您关闭防火墙!"
response.end
end if
看不懂的朋友可以看看下面的例子:
文件:clearpk.asp
<!--#include file="config.asp" -->
<!--#include file="conn.asp" -->
<%
n=request.form("username")
p=request.form("userchr")
if instr(n,"'")<>0 or instr(n,";")<>0 or instr(n,"&")<>0 or instr(n,"%")<>0 then
response.write "您所输入的数据包含非法字符,对不起!"
response.end
end if
if instr(p,"'")<>0 or instr(p,";")<>0 or instr(p,"&")<>0 or instr(p,"%")<>0 then
response.write "您所输入的数据包含非法字符,对不起!"
response.end
end if
if n<>"" and p<>"" then
if not ChkPost() then
response.write "请不要尝试漏洞或者请您关闭防火墙!"
response.end
end if
set rs1 = Server.CreateObject("ADODB.Recordset")
sql="select * from Character where AccountID='"&n&"' and Name='"&p&"' and pklevel<>3"
rs1.open sql,conn,1,3
if rs1.eof or rs1.bof then
防止通过网页修改数据库的方法之一
对所有.asp文件进行查找,凡maxlength的地方请注意:
把所有这样的语名通通改为maxlength=18及以下,例如角色id你只需要maxlength=10 就可以了,只有身份证需要18长度,其实的全部改小就可以了。
很简单的吧!
|