SQL 2000挂马的批量替换

来源:互联网 发布:网络劫持金山毒霸 编辑:程序博客网 时间:2024/04/29 16:46

    前不久,万网的提供的sql中了木马,几乎每个字段都被加了<script>,上万的数据不可能一个个删,用“查询分析器”替换也只能一个个字段的来,上网搜了一下,发现有遇到同样情况的人,提供了一个办法,这个忒好用了,库里的都能删掉,记录一下,做个备份:

declare @t varchar(555),@c varchar(555) ,@inScript varchar(8000) 
set @inScript='<script src=http://3b%6Fmb.com/c.js></script>' 
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;

       还有,就是要去掉角色public对sysobjects与syscolumns对象的select访问(我用的是万网的,没办法改这个,至少我没找到,本地是可以的),当然最主要的还是查查网站的漏洞了!

0 0