国语自产精品视频在线看:您身边最放心的安全下载站! 最新软件|热门排行|软件分类|软件专题|厂商大全

国语自产精品视频在线看

技术教程
您的位置:首页系统集成网络安全 → ASP数据库被挂马的编程处理方法

ASP数据库被挂马的编程处理方法

我要评论 2009/11/24 16:40:17 来源:国语自产精品视频在线看 编辑:绿色资源站 [ ] 评论:0 点击:218次

    数据库被挂马我相信很多人【hěn duō rén】都碰到🚆过。在这里【zài zhè lǐ】🔓,我讲下【wǒ jiǎng xià】我处理🌊的方法。 

    第一步:为现有数据库【shù jù kù】🤘做好备份【fèn】♐。

    第二步【dì èr bù】✅:执行如【zhí háng rú】下ASP文件,这样就👨可以去掉数据【diào shù jù】库当中的JS木马🤲:

    注:conn.asp自己去🔘写了【xiě le】。

    '这里放入【rù】🍯JS木马内【mù mǎ nèi】容:请记得改为自🤩己数据库中的【kù zhōng de】🛺JS木马内【mù mǎ nèi】容。

    <!--#include file="conn.asp"-->

    <%

    Server.ScriptTimeOut=180 Set rstSchema = conn.OpenSchema(20)

    k=1

    Do Until rstSchema.EOF '遍历数【biàn lì shù】据库表💞

    If rstSchema("TABLE_TYPE")="TABLE" Then

    response.write K&".<font color=red><b>"&rstSchema("TABLE_NAME") & "</b></font>:" '显示表【xiǎn shì biǎo】🎣名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'只处理【zhī chù lǐ】🚭字段🔋类型为字符型【zì fú xíng】的字段【de zì duàn】🔋

    conn.execute("update ["&rstSchema("TABLE_NAME")&"] set "&rs(i).name&" =replace(cast("&rs(i).name&" as varchar(8000)),'这里放入【rù】⏫JS木马内容【róng】⬜','')") response.write rs(i).name &" "&rs(i).Type &" "'显示执💜行过的字段名【zì duàn míng】。

    End If

    Next

    response.write "<br>"

    End If

    rstSchema.MoveNext

    k=k+1

    Loop

    response.Write "执行成🎨功【gōng】"

    %>

    如果数据库表【jù kù biǎo】🗑很多的【hěn duō de】话,上面的遍历数据库结构未执行完就【háng wán jiù】被🔜IIS给停止【gěi tíng zhǐ】了。在这时【zài zhè shí】❎候可以🚹在🍍:

    If rstSchema("TABLE_TYPE")="TABLE" Then

    当中适【dāng zhōng shì】当加入k值的范【zhí de fàn】😼围📱,如:

    If rstSchema("TABLE_TYPE")="TABLE" k>10 and k<20 Then

    这样的【zhè yàng de】🙁话就一🍺次只操【cì zhī cāo】作9个表。

    第三步【dì sān bù】✨:

    根据数🏸据库【jù kù】JS注入的【zhù rù de】特性(会包括<script、</script>和👪http://这样的字符【zì fú】),在🌪conn.asp里面放【lǐ miàn fàng】🏯入如下代码:

    Function Cheack_Sqljs()'防止数据库外【jù kù wài】链【liàn】🍉JS注入【zhù rù】🌜:true为发现外链【liàn】🍉JS注入【zhù rù】🌜。

    Dim F_Post,F_Get

    Cheack_Sqljs=False

    If Request.Form<>"" Then'表单提交时的⏺检测【jiǎn cè】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提交时【tí jiāo shí】🧀的检测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()'检查提【jiǎn chá tí】交数据【jiāo shù jù】🗞来源🐜:True为数据从站外📘提交过【tí jiāo guò】来的

    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('禁止执【jìn zhǐ zhí】🌼行,非法操【fēi fǎ cāo】🕑作。');</Script>" Response.End()

    End If

关键词:ASP数据库

阅读本文后您有什么感想? 已有 人给出评价!

  • 0 欢迎喜欢
  • 0 白痴
  • 0 拜托
  • 0 哇
  • 0 加油
  • 0 鄙视