现在,网站流行最广的入侵应该是SQL注入吧,在程序上如果没有做好SQL注入防范,很容易给黑客入侵,如果网站的数据库给入侵注入js等恶意网址代码的话,怎么办呢?本文是其中一种解决方法:
--解决并清除SQL被注入<script>恶意病毒代码的语句
declare @t varchar(255),@c varchar(255) 
declare table_cursor cursor for select a.name,b.name  
from sysobjects a,syscolumns b ,systypes c  
where a.id=b.id and a.xtype='u' and c.name  
in ('char', 'nchar', 'nvarchar', 'varchar','text','ntext') 
declare @str varchar(500),@str2 varchar(500)  
set @str='<script src=http://r01.3322.org/c.js></script>'/*要替换的内容*/ 
set @str2=''  
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)),''' @str ''','''  @str2  ''')') 
fetch next from table_cursor  
into @t,@c end close table_cursor deallocate table_cursor;

首先替换代码里面的<script src=http://r01.3322.org/c.js></script>为你的数据库表里面被注入的内容,打开MSSQL的SQL查询分析器执行以下代码就可以了。

相关文章:

  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2021-08-15
  • 2021-04-04
  • 2021-10-03
  • 2022-02-26
猜你喜欢
  • 2021-10-02
  • 2022-03-04
  • 2021-05-17
  • 2021-11-30
  • 2021-11-30
  • 2021-11-13
相关资源
相似解决方案