ASP資料庫被掛馬的程式設計處理方法

2021-12-29 22:04:52 字數 2241 閱讀 8574

資料庫被掛馬我相信很多人都碰到過。在這裡,我講下我處理的方法。

第一步:為現有資料庫做好備份。

第二步:執行如下asp檔案,這樣就可以去掉資料庫當中的js木馬:

注:conn.asp自己去寫了。

這裡放入js木馬內容:請記得改為自己資料庫中的js木馬內容。

server.scripttimeout=180

set rstschema = conn.openschema(20)

k=1do until rstschema.eof 遍歷資料庫表

if rstschema("table_type")="table" then

response.write k&"."&rstschema("table_name") & ":" 顯示表名

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 "

"     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注入的特性(會包括")<>0) and instr(lcase(request.form(f_post)),"0>http://")<>0 then

cheack_sqljs=true

exit for

end if

next

end if

if request.querystring<>"" thenquerystring提交時的檢測

function checkdatafrom()檢查提交資料**:true為資料從站外提交過來的

資料庫掛馬

sql語句如下 資料庫掛馬 用游標遍歷所有表裡如下資料型別的字段,然後update掛馬。全部是允許寫入字元的字段 xtype 99 ntext xtype 35 text xtype 231 nvarchar xtype 167 varchar yd的分割 declare t varchar 255...

ASP資料庫插馬小議

隨著技術的發展,asp資料庫插馬也不是什麼新鮮的東東了,相信閣下也玩過這個的吧。呵呵,那你有沒有遇到過插入的 asp 被空格拆開的情況呢 即插入的每個字元之間都出現了空格 現在,就讓我們來解決這個問題。經過對多例實際情況的分析,我發現只要出現 被空格隔開的資料庫,相應的字段的 unicode 壓縮屬...

ASP資料庫程式設計技巧

asp資料庫程式設計技巧 一 與資料庫建立連線 我們常用的資料庫一般為microsoft access或sql server,為了使用這兩種資料庫,我們通常需要先建立和配置odbc資料來源,但事實上,asp指令碼可以使用old db的其他驅動程式直接把ado繫結到資料庫而不使用odbc作為乙個附加層...