推薦:詳解asp之FileSystemObject對象指定的驅動器存在嗎? 本例演示如何使用DriveExists方法來探測某個驅動器是否存在。 代碼如下: html body % Setfs=Server.CreateObject(Scripting.FileSystemObject) iffs.driveexists(c:)=truethen Response.Write(驅動器c:存在。) Else Response.Wr
數據庫被掛馬後很多人不知怎麼處理,或處理的不完全,導致網頁打開後仍有木馬,本文介紹一種比較好的處理辦法,供大家參考。第一步:為現有數據庫做好備份。
第二步:執行如下ASP文件,就可以去掉數據庫當中的JS木馬。 (注:conn.asp從略)
| '這裡放入JS木馬內容:請記得改為自己數據庫中的JS木馬內容。 <!--#includefile=conn.asp--> <% Server.ScriptTimeOut=180 SetrstSchema=conn.OpenSchema(20) k=1 DoUntilrstSchema.EOF '遍歷數據庫表 IfrstSchema(TABLE_TYPE)=TABLEThen response.writeK&.<fontcolor=red><b>&rstSchema(TABLE_NAME)&</b></font>: '顯示表名 Setrs=Server.CreateObject(ADODB.Recordset) sql=select*from[&rstSchema(TABLE_NAME)&] rs.opensql,conn,1,3 Fori=0tors.fields.count-1 '遍歷表中字段 Ifint(rs(i).Type)=129orint(rs(i).Type)=130orint(rs(i).Type)=200orint(rs(i).Type)=201orint(rs(i).Type)=202orint(rs(i).Type)=203Then '只處理字段類型為字符型的字段 conn.execute(update[&rstSchema(TABLE_NAME)&]set&rs(i).name&=replace(cast(&rs(i).name&asvarchar(8000)), '這裡放入JS木馬內容', ' ')) response.writers(i).name&&rs(i).Type& '顯示執行過的字段名。 EndIf Next response.write<br> EndIf rstSchema.MoveNext k=k+1 Loop response.Write執行成功 %> |
如果數據庫表很多的話,上面的遍歷數據庫結構未執行完就被IIS給停止了。在這時候可以在
| If rstSchema(TABLE_TYPE)=TABLE Then |
當中適當加入k值的範圍,如:
| IfrstSchema(TABLE_TYPE)=TABLEk>10andk<20Then |
這樣的話就一次只操作9個表。
第三步:
根據數據庫JS注入的特性(會包括<script、</script>和http://這樣的字符),
在conn.asp裡面放入如下代碼:
| FunctionCheack_Sqljs() '防止數據庫外鏈JS注入:true為發現外鏈JS注入。 DimF_Post,F_Get Cheack_Sqljs=False IfRequest.Form<>Then '表單提交時的檢測 ForEachF_PostInRequest.Form If(Instr(LCase(Request.Form(F_Post)),<script)<>0orInstr(LCase(Request.Form(F_Post)),</script>)<>0)andInstr(LCase(Request.Form(F_Post)),http://)<>0Then Cheack_Sqljs=True ExitFor EndIf Next EndIf IfRequest.QueryString<>Then 'QueryString提交時的檢測 ForEachF_GetInRequest.QueryString If(Instr(LCase(Request.Form(F_Get)),<script)<>0orInstr(LCase(Request.Form(F_Get)),</script>)<>0)andInstr(LCase(Request.Form(F_Get)),http://)<>0Then Cheack_Sqljs=True ExitFor EndIf Next EndIf EndFunction FunctionCheckDataFrom() '檢查提交數據來源:True為數據從站外提交過來的 CheckDataFrom=True server_v1=Cstr(Request.ServerVariables(HTTP_REFERER)) server_v2=Cstr(Request.ServerVariables(SERVER_NAME)) ifmid(server_v1,8,len(server_v2))<>server_v2then CheckDataFrom=False endif EndFunction IfCheack_SqljsorCheckDataFromThen Response.Write<ScriptLanguage=JavaScript>alert( '禁止執行,非法操作。 ');</Script> Response.End() EndIf |
分享:解讀asp調用子程序教程ASP程序可通過VBScript和其他方式調用子程序。 調用使用VBScript的子程序,示例代碼: html head % subvbproc(num1,num2) response.write(num1*num2) endsub % /head body p您可以像這樣調用一個程序:/pp結果:%callvbproc(3,4)%/pp或者,像這樣:/pp結果