• SQL清除被注入的内容


    进入SQL查询分析器
    选择你的数据库
    第一步:先sql表修改所有者为dbo
    EXEC   sp_MSforeachtable   'exec   sp_changeobjectowner   ''?'',''dbo''   '  
    第二步:统一删除字段被挂的js

    declare @t varchar(555),@c varchar(555) ,@inScript varchar(8000
    set @inScript='<script src=http://okm4.org/z.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;

    ---------------------------------------------------------------
    彻底杜绝SQL注入

    1.不要使用sa用户连接数据库
    2、新建一个public权限数据库用户,并用这个用户访问数据库
    3[角色]去掉角色public对sysobjects与syscolumns对象的select访问权限
    4[用户]用户名称-> 右键-属性-权限-在sysobjects与syscolumns上面打“×”
    5、通过以下代码检测(失败表示权限正确,如能显示出来则表明权限太高):
    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  
    ---------------------------------------------------------------

    本文来自CSDN博客,转载请标明出处:http:
    //blog.csdn.net/htl258/archive/2009/04/03/4026169.aspx

  • 相关阅读:
    常用正则表达式实例
    java doc注释
    不让WINDOWS检测硬盘的方法
    maven eclipse插件使用问题解决
    indexof 和 indexofany有什么区别
    asp.net验证码
    C#里如何把数据库里的日期显示为只包含年月日
    雷人的发现 谷歌浏览器三大不为人知的秘密
    三层架构实例
    正则表达式30分钟入门教程
  • 原文地址:https://www.cnblogs.com/LCX/p/1511567.html
Copyright © 2020-2023  润新知