如何用asp程序處理數(shù)據(jù)庫(kù)被掛馬的問(wèn)題_ASP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:詳解asp之FileSystemObject對(duì)象指定的驅(qū)動(dòng)器存在嗎? 本例演示如何使用DriveExists方法來(lái)探測(cè)某個(gè)驅(qū)動(dòng)器是否存在。 代碼如下: html body % Setfs=Server.CreateObject(Scripting.FileSystemObject) iffs.driveexists(c:)=truethen Response.Write(驅(qū)動(dòng)器c:存在。) Else Response.Wr
數(shù)據(jù)庫(kù)被掛馬后很多人不知怎么處理,或處理的不完全,導(dǎo)致網(wǎng)頁(yè)打開(kāi)后仍有木馬,本文介紹一種比較好的處理辦法,供大家參考。第一步:為現(xiàn)有數(shù)據(jù)庫(kù)做好備份。
第二步:執(zhí)行如下ASP文件,就可以去掉數(shù)據(jù)庫(kù)當(dāng)中的JS木馬。(注:conn.asp從略)
| ’這里放入JS木馬內(nèi)容:請(qǐng)記得改為自己數(shù)據(jù)庫(kù)中的JS木馬內(nèi)容。 <!--#include file="conn.asp"--> <% Server.ScriptTimeOut=180 Set rstSchema = conn.OpenSchema(20) k=1 Do Until rstSchema.EOF ’遍歷數(shù)據(jù)庫(kù)表 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木馬內(nèi)容’,’’)") response.write rs(i).name &" "&rs(i).Type &" "’顯示執(zhí)行過(guò)的字段名。 End If Next response.write "<br>" End If rstSchema.MoveNext k=k+1 Loop response.Write "執(zhí)行成功" %> |
如果數(shù)據(jù)庫(kù)表很多的話,上面的遍歷數(shù)據(jù)庫(kù)結(jié)構(gòu)未執(zhí)行完就被IIS給停止了。在這時(shí)候可以在
| If rstSchema("TABLE_TYPE")="TABLE" Then |
當(dāng)中適當(dāng)加入k值的范圍,如:
| If rstSchema("TABLE_TYPE")="TABLE" k>10 and k<20 Then |
這樣的話就一次只操作9個(gè)表。
第三步:
根據(jù)數(shù)據(jù)庫(kù)JS注入的特性(會(huì)包括<script、</script>和http://這樣的字符),
在conn.asp里面放入如下代碼:
| Function Cheack_Sqljs()’防止數(shù)據(jù)庫(kù)外鏈JS注入:true為發(fā)現(xiàn)外鏈JS注入。 Dim F_Post,F_Get Cheack_Sqljs=False If Request.Form<>"" Then’表單提交時(shí)的檢測(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提交時(shí)的檢測(cè) 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()’檢查提交數(shù)據(jù)來(lái)源:True為數(shù)據(jù)從站外提交過(guò)來(lái)的 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(’禁止執(zhí)行,非法操作。’);</Script>" Response.End() End If |
分享:解讀asp調(diào)用子程序教程ASP程序可通過(guò)VBScript和其他方式調(diào)用子程序。 調(diào)用使用VBScript的子程序,示例代碼: html head % subvbproc(num1,num2) response.write(num1*num2) endsub % /head body p您可以像這樣調(diào)用一個(gè)程序:/p p結(jié)果:%callvbproc(3,4)%/p p或者,像這樣:/p p結(jié)果
相關(guān)ASP教程:
- asp FSO 讀寫(xiě)文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫(kù)實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過(guò)濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁(yè)模板:ASP內(nèi)建對(duì)象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無(wú)組件分頁(yè)實(shí)現(xiàn)思路及代碼
ASP教程Rss訂閱編程教程搜索
ASP教程推薦
- ASP 與ASP有什么不同
- ASP基礎(chǔ)教程之ASP程序?qū)ookie的處理
- 揭秘17個(gè)ASP編程基礎(chǔ)典型代碼
- ASP內(nèi)置對(duì)象Request和Response的詳解
- ASP Cookies 教程
- asp操作access提示無(wú)法從指定的數(shù)據(jù)表中刪除原因分析及解決
- ASP實(shí)現(xiàn)在提交表單到數(shù)據(jù)庫(kù)的同時(shí)發(fā)郵件通知
- 淺析asp程序創(chuàng)建access數(shù)據(jù)庫(kù)
- 動(dòng)態(tài)網(wǎng)頁(yè)制作技術(shù)ASP開(kāi)發(fā)中的常見(jiàn)問(wèn)題
- 瞄準(zhǔn)Apache IIS7向開(kāi)源張開(kāi)雙臂
- 相關(guān)鏈接:
- 教程說(shuō)明:
ASP教程-如何用asp程序處理數(shù)據(jù)庫(kù)被掛馬的問(wèn)題
。