• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    兩個防SQL注入過濾代碼

    發布: 2008-8-04 10:25 | 作者: 網絡轉載 | 來源: 測試時代采編 | 查看: 85次 | 進入軟件測試論壇討論

    領測軟件測試網

    <%
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'ASP通用防注入代碼
    '您可以把該代碼COPY到頭文件中.也可以單獨作
    '為一個文件存在,每次調用使用
    '作者:y3gu - 2005-7-29
    'http://www.dosu.cn
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Dim GetFlag Rem(提交方式)
    Dim ErrorSql Rem(非法字符)
    Dim RequestKey Rem(提交數據)
    Dim ForI Rem(循環標記)
    ErrorSql = "'~;~and~(~)~exec~update~count~*~%~chr~mid
    ~master~truncate~char~declare" Rem(每個敏感字符或者詞語請使用半角 "~" 格開)
    ErrorSql = split(ErrorSql,"~")
    If Request.ServerVariables("REQUEST_METHOD")="GET" Then
    GetFlag=True
    Else
    GetFlag=False
    End If
    If GetFlag Then
    For Each RequestKey In Request.QueryString
    For ForI=0 To Ubound(ErrorSql)
    If Instr(LCase(Request.QueryString(RequestKey)),
    ErrorSql(ForI))<>0 Then
    response.write "<script>alert(""警告:\n請不要使用敏感字符"");location.href=""Sql.asp"";</script>"
    Response.End
    End If
    Next
    Next
    Else
    For Each RequestKey In Request.Form
    For ForI=0 To Ubound(ErrorSql)
    If Instr(LCase(Request.Form(RequestKey)),
    ErrorSql(ForI))<>0 Then
    response.write "<script>alert(""警告:\n請不要使用敏感字符"");location.href=""Sql.asp"";</script>"
    Response.End
    End If
    Next
    Next
    End If
    %>

    第二個

    Function Checkstr(Str)
    If Isnull(Str) Then
    CheckStr = ""
    Exit Function
    End If
    Str = Replace(Str,Chr(0),"", 1, -1, 1)
    Str = Replace(Str, """", """, 1, -1, 1)
    Str = Replace(Str,"<;","<;", 1, -1, 1)
    Str = Replace(Str,">;",">;", 1, -1, 1)
    Str = Replace(Str, "script", "script", 1, -1, 0)
    Str = Replace(Str, "SCRIPT", "SCRIPT", 1, -1, 0)
    Str = Replace(Str, "Script", "Script", 1, -1, 0)
    Str = Replace(Str, "script", "Script", 1, -1, 1)
    Str = Replace(Str, "object", "object", 1, -1, 0)
    Str = Replace(Str, "OBJECT", "OBJECT", 1, -1, 0)
    Str = Replace(Str, "Object", "Object", 1, -1, 0)
    Str = Replace(Str, "object", "Object", 1, -1, 1)
    Str = Replace(Str, "applet", "applet", 1, -1, 0)
    Str = Replace(Str, "APPLET", "APPLET", 1, -1, 0)
    Str = Replace(Str, "Applet", "Applet", 1, -1, 0)
    Str = Replace(Str, "applet", "Applet", 1, -1, 1)
    Str = Replace(Str, "[", "[")
    Str = Replace(Str, "]", "]")
    Str = Replace(Str, """", "", 1, -1, 1)
    Str = Replace(Str, "=", "=", 1, -1, 1)
    Str = Replace(Str, "’", "’’", 1, -1, 1)
    Str = Replace(Str, "select", "select", 1, -1, 1)
    Str = Replace(Str, "execute", "execute", 1, -1, 1)
    Str = Replace(Str, "exec", "exec", 1, -1, 1)
    Str = Replace(Str, "join", "join", 1, -1, 1)
    Str = Replace(Str, "union", "union", 1, -1, 1)
    Str = Replace(Str, "where", "where", 1, -1, 1)
    Str = Replace(Str, "insert", "insert", 1, -1, 1)
    Str = Replace(Str, "delete", "delete", 1, -1, 1)
    Str = Replace(Str, "update", "update", 1, -1, 1)
    Str = Replace(Str, "like", "like", 1, -1, 1)
    Str = Replace(Str, "drop", "drop", 1, -1, 1)
    Str = Replace(Str, "create", "create", 1, -1, 1)
    Str = Replace(Str, "rename", "rename", 1, -1, 1)
    Str = Replace(Str, "count", "count", 1, -1, 1)
    Str = Replace(Str, "chr", "chr", 1, -1, 1)
    Str = Replace(Str, "mid", "mid", 1, -1, 1)
    Str = Replace(Str, "truncate", "truncate", 1, -1, 1)
    Str = Replace(Str, "nchar", "nchar", 1, -1, 1)
    Str = Replace(Str, "char", "char", 1, -1, 1)
    Str = Replace(Str, "alter", "alter", 1, -1, 1)
    Str = Replace(Str, "cast", "cast", 1, -1, 1)
    Str = Replace(Str, "exists", "exists", 1, -1, 1)
    Str = Replace(Str,Chr(13),"<;br>;", 1, -1, 1)
    CheckStr = Replace(Str,"’","’’", 1, -1, 1)
    End Function

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: sql SQL Sql 代碼


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>