• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

sqlserver 数据库被注入解决方案_sqlserver

sqlserver 搞代码 3年前 (2018-06-17) 150次浏览 已收录 0个评论
复制代码 代码如下:
declare @delStr nvarchar(500)
set @delStr='<script src=http://www.kansm.com/js/common.js></script>’ –这里被注入的字段串
/****************************************/

/**********以下为操作实体************/

http://www.gaodaima.com/?p=37461sqlserver 数据库被注入解决方案_sqlserver

set nocount on

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

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
select name from syscolumns where xtype in (231,167,239,175, 35, 99) and [email protected]
open cur1
fetch next from cur1 into @columnName
while @@fetch_status=0
begin
set @sql=’update [‘ + @tableName + ‘] set [‘+ @columnName +’]= SUBSTRING([‘ + @columnName + ‘],’ + ‘1, PATINDEX( ”%’ + @delStr + ‘%”, [‘ + @columnName + ‘])-1) + ‘ + ‘SUBSTRING([‘ + @columnName + ‘], PATINDEX( ”%’ + @delStr + ‘%”, [‘ + @columnName + ‘]) + ‘ + ‘len(”’ + @delStr + ”’) , datalength([‘ + @columnName + ‘])) where [‘[email protected]+’] like ”%’[email protected]+’%”’

exec sp_executesql @sql
set @iRow=@@rowcount
set @[email protected][email protected]
if @iRow>0
begin
print ‘表:’[email protected]+’,列:’[email protected]+’被更新’+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

欢迎大家阅读《sqlserver 数据库被注入解决方案_sqlserver》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址