注册 登录
编程论坛 ASP技术论坛

数据库被写入问题(有可能是注入)?

kingfangdeng 发布于 2010-11-15 17:20, 458 次点击
先看代码:
dim ErrorAction
    ErrorAction=true
    dim M_Name,M_Password,M_Password1,M_Question,M_Answer,M_Company,M_Tel,M_Fax,M_Mobile,M_Address,M_Zip,M_Contact,prov,city,M_Website,M_Email,M_CompAttribute,M_TradeName,M_mainProducts,M_AnnualRevenue,M_EmployeerNum,checkcode
   
    M_Name=FormatSQL(trim(request("M_Name")))
    checkcode=trim(request.Form("checkcode"))
    M_Password=FormatSQL(trim(request("M_Password")))
    M_Question=FormatSQL(trim(request("M_Question")))
    M_Answer=FormatSQL(trim(request("M_Answer")))
    M_Company=FormatSQL(trim(request("M_Company")))
    M_Tel=FormatSQL(trim(request("M_Tel")))
    M_Fax=FormatSQL(trim(request("M_Fax")))
    M_Mobile=FormatSQL(trim(request("M_Mobile")))
    M_Address=FormatSQL(trim(request("M_Address")))
    M_Zip=FormatSQL(trim(request("M_Zip")))
    M_Contact=FormatSQL(trim(request("M_Contact")))
    prov=FormatSQL(trim(request("prov")))
    city=FormatSQL(trim(request("city")))
    M_Website=FormatSQL(trim(request("M_Website")))
    M_Email=FormatSQL((trim(request("M_Email"))))
    M_CompAttribute=FormatSQL(trim(request("M_CompAttribute")))
    M_TradeName=FormatSQL(trim(request("M_TradeName")))
    M_mainProducts=FormatSQL(trim(request("M_mainProducts")))
    M_AnnualRevenue=FormatSQL(trim(request("M_AnnualRevenue")))
    M_EmployeerNum=FormatSQL(trim(request("M_EmployeerNum")))
    M_Sex=FormatSQL(trim(request.Form("M_Sex")))
    M_zhiwei=FormatSQL(trim(request.Form("M_Zhiwei")))
   
    if M_Name="" then
        Response.Write "<Script Language=JavaScript>alert('\n提示您:\n\n用户名不能为空!');history.back(-1)</Script>"
        Response.end
    end if
   
    if checkcode="" then
        Response.Write "<Script Language=JavaScript>alert('\n提示您:\n\n验证码不能为空!');history.back(-1)</Script>"
        Response.end
    end if
        
    if checkcode<>Session("GetCode") then
        Response.Write "<Script Language=JavaScript>alert('\n提示您:\n\n验证码输入不正确!');history.back(-1)</Script>"
        Response.end
    end if
   
    if M_Company="" then
        Response.Write "<Script Language=JavaScript>alert('\n中国照明信息网提示您:\n\n公司名称不能为空!');history.back(-1)</Script>"
        Response.end
    end if
        
    dim rs,sql
    set rs=server.CreateObject("adodb.recordset")
    sql="select * from member_login where M_Name='"&M_Name&"'"
    rs.open sql,conn,3,3
    if rs.eof then
    rs.addnew
        rs("M_Name")=M_Name
        rs("M_Password")=md5(M_Password)
        rs("M_Question")=M_Question
        rs("M_Answer")=M_Answer
        rs("M_Company")=M_Company
        rs("M_Tel")=M_Tel
        rs("M_Fax")=M_Fax
        rs("M_Mobile")=M_Mobile
        rs("M_Address")=M_Address
        rs("M_Zip")=M_Zip
        rs("M_Contact")=M_Contact
        rs("M_LiveProv")=prov
        rs("M_LiveCity")=city
        rs("M_Website")=M_Website
        rs("M_Email")=M_Email
        rs("M_CompAttribute")=M_CompAttribute
        rs("M_TradeName")=M_TradeName
        rs("M_mainProducts")=M_mainProducts
        rs("M_AnnualRevenue")=M_AnnualRevenue
        rs("M_EmployeerNum")=M_EmployeerNum
        rs("M_Type")=M_Type
        rs("M_Sex")=M_Sex
        rs("M_zhiwei")=M_zhiwei
    rs.update
    rs.close
    set rs=nothing

'*************************************
'过滤特殊字符
'*************************************
Function FormatSQL(ChkStr)
    Dim Str:Str=ChkStr
    If IsNull(Str) Then
        FormatSQL = ""
        Exit Function
    End If
    Str = Replace(Str, "&", "&amp;")
    Str = Replace(Str,"'","'")
    Str = Replace(Str,"""",""")
    Dim re
    Set re=new RegExp
    re.IgnoreCase =True
    re.Global=True
    re.Pattern="(w)(here)"
    Str = re.replace(Str,"$1here")
    re.Pattern="(s)(elect)"
    Str = re.replace(Str,"$1elect")
    re.Pattern="(i)(nsert)"
    Str = re.replace(Str,"$1nsert")
    re.Pattern="(c)(reate)"
    Str = re.replace(Str,"$1reate")
    re.Pattern="(d)(rop)"
    Str = re.replace(Str,"$1rop")
    re.Pattern="(a)(lter)"
    Str = re.replace(Str,"$1lter")
    re.Pattern="(d)(elete)"
    Str = re.replace(Str,"$1elete")
    re.Pattern="(u)(pdate)"
    Str = re.replace(Str,"$1pdate")
    re.Pattern="(\s)(or)"
    Str = re.replace(Str,"$1or")
    Set re=Nothing
    FormatSQL=Str
End Function

%>
放到服务器后,后台数据库总是被写入很多条信息。甚至30秒内会有一次。
5 回复
#2
hams2010-11-16 08:15
加个验证码
#3
kingfangdeng2010-11-16 08:43
回复 2楼 hams
加了四个数字的验证码,结果还是一样。。怎么办?
#4
gupiao1752010-11-16 11:30
请问楼主加的验证码是什么?纯文本还是图片?

最好是用图片格式的验证码,而且如果有必要的话把汉字写进去并加干扰符,即用肉眼才能识别其中的字符!
#5
gupiao1752010-11-16 11:40
另外楼主可以查看一下日志,或者看看写入的信息是什么,跟踪一下IP等等,把这些信息反馈一下!
#6
hams2010-11-16 17:27
加个中文的验证码,数字字母的基本没用了。以前我装的动网论坛也是,一天注册几百个号,都是注册机注册的,加数字和字母的没起做用,加中文的之后就没有了。
1