<sup id="pau0i"></sup>
      <object id="pau0i"></object>
        <object id="pau0i"></object>

          湖南長(zhǎng)沙八年做網(wǎng)站,網(wǎng)絡(luò)優(yōu)化推廣服務(wù)團(tuán)隊(duì),讓您小投資大回報(bào),幫您打開網(wǎng)絡(luò)營(yíng)銷財(cái)富之門!
           業(yè)務(wù)服務(wù)熱線:0731-88571521  13637482004  
           


          地址:長(zhǎng)沙市韶山南路248號(hào)南園503
                室(瀟湘晨報(bào)旁)
          電話:0731-88571521
          手機(jī):13637482004
          Q  Q:44377655 522392221
          網(wǎng)址:www.jelker.com
          郵箱:522392221@qq.com
          網(wǎng)站維護(hù)與安全
          長(zhǎng)沙做網(wǎng)站聯(lián)系電話:0731-88571521 13637482004

          防SQL注入代碼(ASP版), 網(wǎng)站防SQL注入,網(wǎng)站防跨站攻擊

          信息來(lái)源:轉(zhuǎn)載 互聯(lián)網(wǎng)   發(fā)布時(shí)間:2019-3-19   瀏覽:

          防SQL注入代碼(ASP版)

          <% 
          Dim Fy_Url,Fy_a,Fy_x,Fy_Cs(),Fy_Cl,Fy_Ts,Fy_Zx 
          '---定義部份 頭------ 
          Fy_Cl = 1 '處理方式:1=提示信息,2=轉(zhuǎn)向頁(yè)面,3=先提示再轉(zhuǎn)向 
          Fy_Zx = "index.Asp" '出錯(cuò)時(shí)轉(zhuǎn)向的頁(yè)面 
          '---定義部份 尾------ 

          On Error Resume Next 
          Fy_Url=Request.ServerVariables("QUERY_STRING") 
          Fy_a=split(Fy_Url,"&") 
          redim Fy_Cs(ubound(Fy_a)) 
          On Error Resume Next 
          for Fy_x=0 to ubound(Fy_a) 
          Fy_Cs(Fy_x) = left(Fy_a(Fy_x),instr(Fy_a(Fy_x),"=")-1) 
          Next 
          For Fy_x=0 to ubound(Fy_Cs) 
          If Fy_Cs(Fy_x)<>"" Then 
          If Instr(LCase(Request(Fy_Cs(Fy_x))),"'")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"select")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"update")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"chr")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"delete%20from")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),";")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"insert")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"mid")<>0 Or Instr(LCase(Request(Fy_Cs(Fy_x))),"master.")<>0 Then 
          Select Case Fy_Cl 
          Case "1" 
          Response.Write "<Script Language=JavaScript>alert(' 出現(xiàn)錯(cuò)誤!參數(shù) "&Fy_Cs(Fy_x)&" 的值中包含非法字符串!\n\n 請(qǐng)不要在參數(shù)中出現(xiàn):and,select,update,insert,delete,chr 等非法字符!\n\n我已經(jīng)設(shè)置了不能SQL注入,請(qǐng)不要對(duì)我進(jìn)行非法手段!');window.close();</Script>" 
          Case "2" 
          Response.Write "<Script Language=JavaScript>location.href='"&Fy_Zx&"'</Script>" 
          Case "3" 
          Response.Write "<Script Language=JavaScript>alert(' 出現(xiàn)錯(cuò)誤!參數(shù) "&Fy_Cs(Fy_x)&"的值中包含非法字符串!\n\n 請(qǐng)不要在參數(shù)中出現(xiàn):,and,select,update,insert,delete,chr 等非法字符!\n\n設(shè)計(jì)了門,非法侵入請(qǐng)離開,謝謝!');location.href='"&Fy_Zx&"';</Script>" 
          End Select 
          Response.End 
          End If 
          End If 
          Next 
          %>

          以上代碼為較多網(wǎng)友所用,從使用的感言來(lái)看,效果顯著。

          Dim Query_Badword,Form_Badword,Err_Message,Err_Web,form_name 

          '------定義部份 頭---------------------------------------------------------------------- 

          Err_Message = 1 '處理方式:1=提示信息,2=轉(zhuǎn)向頁(yè)面,3=先提示再轉(zhuǎn)向 
          Err_Web = "Err.Asp" '出錯(cuò)時(shí)轉(zhuǎn)向的頁(yè)面 
          Query_Badword="'‖and‖select‖update‖chr‖delete‖%20from‖;‖insert‖mid‖master.‖set‖chr(37)‖=" 
          '在這部份定義get非法參數(shù),使用"‖"號(hào)間隔 
          Form_Badword="'‖%‖&‖*‖#‖@‖=‖select‖and‖set‖delete" '在這部份定義post非法參數(shù),使用"‖"號(hào)間隔 

          '------定義部份 尾----------------------------------------------------------------------- 

          On Error Resume Next 
          '----- 對(duì) get query 值 的過(guò)濾. 
          if request.QueryString<>"" then 
          Chk_badword=split(Query_Badword,"‖") 
          FOR EACH Query_form_name IN Request.QueryString 
          for i=0 to ubound(Chk_badword) 
          If Instr(LCase(request.QueryString(Query_form_name)),Chk_badword(i))<>0 Then 
          Select Case Err_Message 
          Case "1" 
          Response.Write "<Script Language=JavaScript>alert('傳參錯(cuò)誤!參數(shù) "&form_name&" 的值中包含非法字符串!\n\n請(qǐng)不要在參數(shù)中出現(xiàn):and update delete ; insert mid master 等非法字符!');window.close();</Script>" 
          Case "2" 
          Response.Write "<Script Language=JavaScript>location.href='"&Err_Web&"'</Script>" 
          Case "3" 
          Response.Write "<Script Language=JavaScript>alert('傳參錯(cuò)誤!參數(shù) "&form_name&"的值中包含非法字符串!\n\n請(qǐng)不要在參數(shù)中出現(xiàn):and update delete ; insert mid master 等非法字符!');location.href='"&Err_Web&"';</Script>" 
          End Select 
          Response.End 
          End If 
          NEXT 
          NEXT 
          End if 

          '-----對(duì) post 表 單值的過(guò)濾. 
          if request.form<>"" then 
          Chk_badword=split(Form_Badword,"‖") 
          FOR EACH form_name IN Request.Form 
          for i=0 to ubound(Chk_badword) 
          If Instr(LCase(request.form(form_name)),Chk_badword(i))<>0 Then 
          Select Case Err_Message 
          Case "1" 
          Response.Write "<Script Language=JavaScript>alert('出錯(cuò)了!表單 "&form_name&" 的值中包含非法字符串!\n\n請(qǐng)不要在表單中出現(xiàn): % & * # ( ) 等非法字符!');window.close();</Script>" 
          Case "2" 
          Response.Write "<Script Language=JavaScript>location.href='"&Err_Web&"'</Script>" 
          Case "3" 
          Response.Write "<Script Language=JavaScript>alert('出錯(cuò)了!參數(shù) "&form_name&"的值中包含非法字符串!\n\n請(qǐng)不要在表單中出現(xiàn): % & * # ( ) 等非法字符!');location.href='"&Err_Web&"';</Script>" 
          End Select 
          Response.End 
          End If 
          NEXT 
          NEXT 
          end if

          以上是另一種版本。

          <%
          Dim GetFlag Rem(提交方式)
          Dim ErrorSql Rem(非法字符) 
          Dim RequestKey Rem(提交數(shù)據(jù))
          Dim ForI Rem(循環(huán)標(biāo)記)
          ErrorSql = "'~;~and~(~)~exec~update~count~*~%~chr~mid~master~truncate~char~declare" Rem(每個(gè)敏感字符或者詞語(yǔ)請(qǐng)使用半角 "~" 格開)
          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請(qǐng)不要做任何嘗試"");location.href=""index.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請(qǐng)不要做任何嘗試"");location.href=""index.asp"";</script>"
          Response.End
          End If
          Next
          Next
          End If
          %>

          1、將上述代碼放入conn文件中即可!

          2、將上述代碼保存為safe.asp,在conn文件中引入也可!




          相關(guān)熱點(diǎn)文章


          地址:湖南長(zhǎng)沙市韶山南路248號(hào)南園503室(瀟湘晨報(bào)旁) 版權(quán)所有:長(zhǎng)沙市天心區(qū)斌網(wǎng)網(wǎng)絡(luò)技術(shù)服務(wù)部 統(tǒng)一社會(huì)信用代碼:92430103MA4LAMB24R
          咨詢電話:0731-88571521   13637482004
          業(yè)務(wù) QQ:客服一 1306053142 客服二 1320506001 技術(shù)/售后 522392221 高級(jí)顧問(wèn) 44377655
          服務(wù)郵箱:fanbin@binweb.cn  官方網(wǎng)址:www.jelker.com   www.pk0731.com
          旗下網(wǎng)站:斌網(wǎng)網(wǎng)絡(luò)  長(zhǎng)沙信息處  佛佛網(wǎng)  曬土貨網(wǎng)
           湘公網(wǎng)安備 43010302000270號(hào)  網(wǎng)站ICP備案號(hào):湘ICP備13006070號(hào)-2  網(wǎng)站地圖  網(wǎng)站XML
              
          在線客服1 在線客服2 技術(shù)咨詢 資深顧問(wèn)

          国产精品久久久久精品|久久网国产精品色婷婷免费|国产另类小说 视频 中文字幕|亚洲欧洲日产国码在线|2020最新国产在线不卡A|无码人妻少妇久久中文字幕蜜|99国产一区二区精品久久
          <sup id="pau0i"></sup>
              <object id="pau0i"></object>
                <object id="pau0i"></object>