<source id="4vppl"><ins id="4vppl"></ins></source>
<u id="4vppl"><sub id="4vppl"><label id="4vppl"></label></sub></u>
<object id="4vppl"></object>
  • <u id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></u>

    <object id="4vppl"></object>
    <b id="4vppl"><sub id="4vppl"><tr id="4vppl"></tr></sub></b>

      <i id="4vppl"><thead id="4vppl"></thead></i>

      <thead id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></thead>

      當前位置:首頁 > 網站舊欄目 > 學習園地 > 程序開發教程 > 用asp程序處理數據庫被掛馬的辦法

      用asp程序處理數據庫被掛馬的辦法
      2010-01-13 12:51:28  作者:  來源:網絡編程
      第一步:為現有數據庫做好備份。
      第二步:執行如下ASP文件,就可以去掉數據庫當中的JS木馬。(注:conn.asp從略) 
      ’這里放入JS木馬內容:請記得改為自己數據庫中的JS木馬內容。
      <!--#include file="conn.asp"-->
      <%
      Server.ScriptTimeOut=180
      Set rstSchema = conn.OpenSchema(20)
      k=1
      Do Until rstSchema.EOF ’遍歷數據庫表
          If rstSchema("TABLE_TYPE")="TABLE" Then 
              response.write K&".<font color=red><b>"&rstSchema("TABLE_NAME") & "</b></font>:" ’顯示表名
              Set rs=Server.CreateObject("ADODB.Recordset")
              sql="select * from [" & rstSchema("TABLE_NAME")&"]"
              rs.open sql,conn,1,3
              For i=0 to rs.fields.count-1 ’遍歷表中字段
                 If int(rs(i).Type)=129 or int(rs(i).Type)=130 or int(rs(i).Type)=200 or int(rs(i).Type)=201 or int(rs(i).Type)=202 or int(rs(i).Type)=203 Then’只處理字段類型為字符型的字段
                  conn.execute("update ["&rstSchema("TABLE_NAME")&"] set "&rs(i).name&" =replace(cast("&rs(i).name&" as varchar(8000)),’這里放入JS木馬內容’,’’)")
                  response.write rs(i).name &" "&rs(i).Type &" "’顯示執行過的字段名。
                End If
              Next
              response.write "<br>" 
          End If 
          rstSchema.MoveNext
          k=k+1
      Loop
      response.Write "執行成功"
      %>
      如果數據庫表很多的話,上面的遍歷數據庫結構未執行完就被IIS給停止了。在這時候可以在 
      If rstSchema("TABLE_TYPE")="TABLE" Then
      當中適當加入k值的范圍,如:
      If rstSchema("TABLE_TYPE")="TABLE" k>10 and k<20 Then
      這樣的話就一次只操作9個表。
      第三步
      根據數據庫JS注入的特性(會包括<script、</script>和http://這樣的字符),
      在conn.asp里面放入如下代碼: 
      Function Cheack_Sqljs()’防止數據庫外鏈JS注入:true為發現外鏈JS注入。
          Dim F_Post,F_Get
          Cheack_Sqljs=False
          If Request.Form<>"" Then’表單提交時的檢測
              For Each F_Post In Request.Form
                  If (Instr(LCase(Request.Form(F_Post)),"<script")<>0 or Instr(LCase(Request.Form(F_Post)),"</script>")<>0) and Instr(LCase(Request.Form(F_Post)),"http://")<>0 Then 
                      Cheack_Sqljs=True
                      Exit For
                  End If
              Next
          End If
          If Request.QueryString<>"" Then’QueryString提交時的檢測
              For Each F_Get In Request.QueryString
                  If (Instr(LCase(Request.Form(F_Get)),"<script")<>0 or Instr(LCase(Request.Form(F_Get)),"</script>")<>0) and Instr(LCase(Request.Form(F_Get)),"http://")<>0 Then 
                      Cheack_Sqljs=True
                      Exit For
                  End If
              Next 
          End If
      End Function
      Function CheckDataFrom()’檢查提交數據來源:True為數據從站外提交過來的
          CheckDataFrom=True
          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
              CheckDataFrom=False
          end if
      End Function
      If Cheack_Sqljs or CheckDataFrom Then
         Response.Write "<Script Language=JavaScript>alert(’禁止執行,非法操作。’);</Script>" 
         Response.End()
      End If

      安徽新華電腦學校專業職業規劃師為你提供更多幫助【在線咨詢
      国产午夜福三级在线播放_亚洲精品成a人片在线观看_亚洲自慰一区二区三区_久久棈精品久久久久久噜噜
      <source id="4vppl"><ins id="4vppl"></ins></source>
      <u id="4vppl"><sub id="4vppl"><label id="4vppl"></label></sub></u>
      <object id="4vppl"></object>
    1. <u id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></u>

      <object id="4vppl"></object>
      <b id="4vppl"><sub id="4vppl"><tr id="4vppl"></tr></sub></b>

        <i id="4vppl"><thead id="4vppl"></thead></i>

        <thead id="4vppl"><li id="4vppl"><label id="4vppl"></label></li></thead>
        宅男欧美一区在线观看 | 中文字幕人成乱码熟女免费 | 日韩a级片视频中文字幕 | 日本午夜两性视屏 | 亚洲国产一级在线 | 日韩AV一区二区三区五月天 |